mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Refactor an unholy piece of code.
This commit is contained in:
parent
d460e1e826
commit
711c35970c
1 changed files with 74 additions and 58 deletions
132
src/p_floor.c
132
src/p_floor.c
|
@ -48,13 +48,7 @@ result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crus
|
||||||
boolean flag;
|
boolean flag;
|
||||||
fixed_t lastpos;
|
fixed_t lastpos;
|
||||||
fixed_t destheight; // used to keep floors/ceilings from moving through each other
|
fixed_t destheight; // used to keep floors/ceilings from moving through each other
|
||||||
// Stuff used for mobj hacks.
|
|
||||||
INT32 secnum = -1;
|
|
||||||
mobj_t *mo = NULL;
|
mobj_t *mo = NULL;
|
||||||
sector_t *sec = NULL;
|
|
||||||
ffloor_t *rover = NULL;
|
|
||||||
boolean sectorisffloor = false;
|
|
||||||
boolean sectorisquicksand = false;
|
|
||||||
|
|
||||||
sector->moved = true;
|
sector->moved = true;
|
||||||
|
|
||||||
|
@ -193,41 +187,37 @@ result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crus
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hack for buggy mobjs to move by gravity with moving planes.
|
// If this is an FOF being checked, check all the affected sectors for moving mobjs.
|
||||||
if (sector->tagline)
|
if (sector->tagline)
|
||||||
sectorisffloor = true;
|
|
||||||
|
|
||||||
// Optimization condition. If the sector is not an FOF, declare sec as the main sector outside of the loop.
|
|
||||||
if (!sectorisffloor)
|
|
||||||
sec = sector;
|
|
||||||
|
|
||||||
// Optimization condition. Only run the logic if there is any Things in the sector.
|
|
||||||
if (sectorisffloor || sec->thinglist)
|
|
||||||
{
|
{
|
||||||
// If this is an FOF being checked, check all the affected sectors for moving mobjs.
|
boolean sectorisquicksand = false;
|
||||||
while ((sectorisffloor ? (secnum = P_FindSectorFromLineTag(sector->tagline, secnum)) : (secnum = 1)) >= 0)
|
sector_t *sec;
|
||||||
{
|
ffloor_t *rover;
|
||||||
if (sectorisffloor)
|
INT32 secnum;
|
||||||
{
|
|
||||||
// Get actual sector from the list of sectors.
|
|
||||||
sec = §ors[secnum];
|
|
||||||
|
|
||||||
// Can't use P_InQuicksand because it will return the incorrect result
|
while (secnum = P_FindSectorFromLineTag(sector->tagline, secnum) >= 0)
|
||||||
// because of checking for heights.
|
{
|
||||||
for (rover = sec->ffloors; rover; rover = rover->next)
|
// Get actual sector from the list of sectors.
|
||||||
|
sec = §ors[secnum];
|
||||||
|
|
||||||
|
if (!sec->thinglist)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Can't use P_InQuicksand because it will return the incorrect result
|
||||||
|
// because of checking for heights.
|
||||||
|
for (rover = sec->ffloors; rover; rover = rover->next)
|
||||||
|
{
|
||||||
|
if (rover->target == sec && (rover->flags & FF_QUICKSAND))
|
||||||
{
|
{
|
||||||
if (rover->target == sec && (rover->flags & FF_QUICKSAND))
|
sectorisquicksand = true;
|
||||||
{
|
break;
|
||||||
sectorisquicksand = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (mo = sec->thinglist; mo; mo = mo->snext)
|
for (mo = sec->thinglist; mo; mo = mo->snext)
|
||||||
{
|
{
|
||||||
// The object should be ready to move as defined by this function.
|
// The object should be ready to move as defined by this function.
|
||||||
if (!P_MobjReadyToMove(mo, sec, sectorisffloor, sectorisquicksand))
|
if (!P_MobjReadyToMove(mo, sec, true, sectorisquicksand))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// The object should not be moving at all.
|
// The object should not be moving at all.
|
||||||
|
@ -237,39 +227,65 @@ result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crus
|
||||||
// These objects will be affected by this condition.
|
// These objects will be affected by this condition.
|
||||||
switch (mo->type)
|
switch (mo->type)
|
||||||
{
|
{
|
||||||
case MT_GOOP: // Egg Slimer's goop objects
|
case MT_GOOP: // Egg Slimer's goop objects
|
||||||
case MT_SPINFIRE: // Elemental Shield flame balls
|
case MT_SPINFIRE: // Elemental Shield flame balls
|
||||||
case MT_SPIKE: // Floor Spike
|
case MT_SPIKE: // Floor Spike
|
||||||
// Is the object hang from the ceiling?
|
// Is the object hang from the ceiling?
|
||||||
// In that case, swap the planes used.
|
// In that case, swap the planes used.
|
||||||
// verticalflip inverts
|
// verticalflip inverts
|
||||||
if (!!(mo->flags & MF_SPAWNCEILING) ^ !!(mo->eflags & MFE_VERTICALFLIP))
|
if (!!(mo->flags & MF_SPAWNCEILING) ^ !!(mo->eflags & MFE_VERTICALFLIP))
|
||||||
{
|
{
|
||||||
if (sectorisffloor && !sectorisquicksand)
|
if (!sectorisquicksand)
|
||||||
mo->z = mo->ceilingz - mo->height;
|
mo->z = mo->ceilingz - mo->height;
|
||||||
else
|
|
||||||
mo->z = mo->ceilingz = mo->subsector->sector->ceilingheight - mo->height;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
mo->z = mo->ceilingz = mo->subsector->sector->ceilingheight - mo->height;
|
||||||
if (sectorisffloor && !sectorisquicksand)
|
}
|
||||||
mo->z = mo->floorz;
|
else
|
||||||
else
|
{
|
||||||
mo->z = mo->floorz = mo->subsector->sector->floorheight;
|
if (!sectorisquicksand)
|
||||||
}
|
mo->z = mo->floorz;
|
||||||
break;
|
else
|
||||||
// Kill warnings...
|
mo->z = mo->floorz = mo->subsector->sector->floorheight;
|
||||||
default:
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Break from loop if there is no FOFs to check.
|
|
||||||
if (!sectorisffloor)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only run the logic if there is any mobjs in the sector.
|
||||||
|
if (sector->thinglist)
|
||||||
|
for (mo = sector->thinglist; mo; mo = mo->snext)
|
||||||
|
{
|
||||||
|
// The object should be ready to move as defined by this function.
|
||||||
|
if (!P_MobjReadyToMove(mo, sector, false, false))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// The object should not be moving at all.
|
||||||
|
if (mo->momx || mo->momy || mo->momz)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// These objects will be affected by this condition.
|
||||||
|
switch (mo->type)
|
||||||
|
{
|
||||||
|
case MT_GOOP: // Egg Slimer's goop objects
|
||||||
|
case MT_SPINFIRE: // Elemental Shield flame balls
|
||||||
|
case MT_SPIKE: // Floor Spike
|
||||||
|
// Is the object hang from the ceiling?
|
||||||
|
// In that case, swap the planes used.
|
||||||
|
// verticalflip inverts
|
||||||
|
if (!!(mo->flags & MF_SPAWNCEILING) ^ !!(mo->eflags & MFE_VERTICALFLIP))
|
||||||
|
mo->z = mo->ceilingz = mo->subsector->sector->ceilingheight - mo->height;
|
||||||
|
else
|
||||||
|
mo->z = mo->floorz = mo->subsector->sector->floorheight;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue