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
|
@ -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,25 +187,22 @@ 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 (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.
|
// If this is an FOF being checked, check all the affected sectors for moving mobjs.
|
||||||
while ((sectorisffloor ? (secnum = P_FindSectorFromLineTag(sector->tagline, secnum)) : (secnum = 1)) >= 0)
|
if (sector->tagline)
|
||||||
{
|
{
|
||||||
if (sectorisffloor)
|
boolean sectorisquicksand = false;
|
||||||
|
sector_t *sec;
|
||||||
|
ffloor_t *rover;
|
||||||
|
INT32 secnum;
|
||||||
|
|
||||||
|
while (secnum = P_FindSectorFromLineTag(sector->tagline, secnum) >= 0)
|
||||||
{
|
{
|
||||||
// Get actual sector from the list of sectors.
|
// Get actual sector from the list of sectors.
|
||||||
sec = §ors[secnum];
|
sec = §ors[secnum];
|
||||||
|
|
||||||
|
if (!sec->thinglist)
|
||||||
|
continue;
|
||||||
|
|
||||||
// Can't use P_InQuicksand because it will return the incorrect result
|
// Can't use P_InQuicksand because it will return the incorrect result
|
||||||
// because of checking for heights.
|
// because of checking for heights.
|
||||||
for (rover = sec->ffloors; rover; rover = rover->next)
|
for (rover = sec->ffloors; rover; rover = rover->next)
|
||||||
|
@ -222,12 +213,11 @@ result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crus
|
||||||
break;
|
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.
|
||||||
|
@ -245,27 +235,53 @@ result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crus
|
||||||
// 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
|
else
|
||||||
mo->z = mo->ceilingz = mo->subsector->sector->ceilingheight - mo->height;
|
mo->z = mo->ceilingz = mo->subsector->sector->ceilingheight - mo->height;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (sectorisffloor && !sectorisquicksand)
|
if (!sectorisquicksand)
|
||||||
mo->z = mo->floorz;
|
mo->z = mo->floorz;
|
||||||
else
|
else
|
||||||
mo->z = mo->floorz = mo->subsector->sector->floorheight;
|
mo->z = mo->floorz = mo->subsector->sector->floorheight;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// Kill warnings...
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Break from loop if there is no FOFs to check.
|
// Only run the logic if there is any mobjs in the sector.
|
||||||
if (!sectorisffloor)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue