mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Refactor P_PushableCheckBustables
This commit is contained in:
parent
bc2d0dcea6
commit
ddb4c2c97f
1 changed files with 64 additions and 61 deletions
125
src/p_mobj.c
125
src/p_mobj.c
|
@ -1674,77 +1674,80 @@ static void P_PushableCheckBustables(mobj_t *mo)
|
|||
|
||||
for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
|
||||
{
|
||||
ffloor_t *rover;
|
||||
fixed_t topheight, bottomheight;
|
||||
|
||||
if (!node->m_sector)
|
||||
break;
|
||||
|
||||
if (node->m_sector->ffloors)
|
||||
if (!node->m_sector->ffloors)
|
||||
continue;
|
||||
|
||||
for (rover = node->m_sector->ffloors; rover; rover = rover->next)
|
||||
{
|
||||
ffloor_t *rover;
|
||||
fixed_t topheight, bottomheight;
|
||||
if (!(rover->flags & FF_EXISTS))
|
||||
continue;
|
||||
|
||||
for (rover = node->m_sector->ffloors; rover; rover = rover->next)
|
||||
if (!(rover->flags & FF_BUSTUP))
|
||||
continue;
|
||||
|
||||
// Needs ML_EFFECT4 flag for pushables to break it
|
||||
if (!(rover->master->flags & ML_EFFECT4))
|
||||
continue;
|
||||
|
||||
if (rover->master->frontsector->crumblestate != CRUMBLE_NONE)
|
||||
continue;
|
||||
|
||||
topheight = P_GetFOFTopZ(mo, node->m_sector, rover, mo->x, mo->y, NULL);
|
||||
bottomheight = P_GetFOFBottomZ(mo, node->m_sector, rover, mo->x, mo->y, NULL);
|
||||
|
||||
// Height checks
|
||||
if (rover->flags & FF_SHATTERBOTTOM)
|
||||
{
|
||||
if (!(rover->flags & FF_EXISTS)) continue;
|
||||
if (mo->z + mo->momz + mo->height < bottomheight)
|
||||
continue;
|
||||
|
||||
if (!(rover->flags & FF_BUSTUP)) continue;
|
||||
|
||||
// Needs ML_EFFECT4 flag for pushables to break it
|
||||
if (!(rover->master->flags & ML_EFFECT4)) continue;
|
||||
|
||||
if (rover->master->frontsector->crumblestate == CRUMBLE_NONE)
|
||||
{
|
||||
topheight = P_GetFOFTopZ(mo, node->m_sector, rover, mo->x, mo->y, NULL);
|
||||
bottomheight = P_GetFOFBottomZ(mo, node->m_sector, rover, mo->x, mo->y, NULL);
|
||||
// Height checks
|
||||
if (rover->flags & FF_SHATTERBOTTOM)
|
||||
{
|
||||
if (mo->z+mo->momz + mo->height < bottomheight)
|
||||
continue;
|
||||
|
||||
if (mo->z+mo->height > bottomheight)
|
||||
continue;
|
||||
}
|
||||
else if (rover->flags & FF_SPINBUST)
|
||||
{
|
||||
if (mo->z+mo->momz > topheight)
|
||||
continue;
|
||||
|
||||
if (mo->z+mo->height < bottomheight)
|
||||
continue;
|
||||
}
|
||||
else if (rover->flags & FF_SHATTER)
|
||||
{
|
||||
if (mo->z+mo->momz > topheight)
|
||||
continue;
|
||||
|
||||
if (mo->z+mo->momz + mo->height < bottomheight)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mo->z >= topheight)
|
||||
continue;
|
||||
|
||||
if (mo->z+mo->height < bottomheight)
|
||||
continue;
|
||||
}
|
||||
|
||||
EV_CrumbleChain(NULL, rover); // node->m_sector
|
||||
|
||||
// Run a linedef executor??
|
||||
if (rover->master->flags & ML_EFFECT5)
|
||||
P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), mo, node->m_sector);
|
||||
|
||||
goto bustupdone;
|
||||
}
|
||||
if (mo->z + mo->height > bottomheight)
|
||||
continue;
|
||||
}
|
||||
else if (rover->flags & FF_SPINBUST)
|
||||
{
|
||||
if (mo->z + mo->momz > topheight)
|
||||
continue;
|
||||
|
||||
if (mo->z + mo->height < bottomheight)
|
||||
continue;
|
||||
}
|
||||
else if (rover->flags & FF_SHATTER)
|
||||
{
|
||||
if (mo->z + mo->momz > topheight)
|
||||
continue;
|
||||
|
||||
if (mo->z + mo->momz + mo->height < bottomheight)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mo->z >= topheight)
|
||||
continue;
|
||||
|
||||
if (mo->z + mo->height < bottomheight)
|
||||
continue;
|
||||
}
|
||||
|
||||
EV_CrumbleChain(NULL, rover); // node->m_sector
|
||||
|
||||
// Run a linedef executor??
|
||||
if (rover->master->flags & ML_EFFECT5)
|
||||
P_LinedefExecute((INT16)(P_AproxDistance(rover->master->dx, rover->master->dy)>>FRACBITS), mo, node->m_sector);
|
||||
|
||||
P_UnsetThingPosition(mo);
|
||||
mo->x = oldx;
|
||||
mo->y = oldy;
|
||||
P_SetThingPosition(mo);
|
||||
return;
|
||||
}
|
||||
}
|
||||
bustupdone:
|
||||
P_UnsetThingPosition(mo);
|
||||
mo->x = oldx;
|
||||
mo->y = oldy;
|
||||
P_SetThingPosition(mo);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue