Refactor P_PushableCheckBustables
This commit is contained in:
parent
bc2d0dcea6
commit
ddb4c2c97f
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)
|
for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next)
|
||||||
{
|
{
|
||||||
|
ffloor_t *rover;
|
||||||
|
fixed_t topheight, bottomheight;
|
||||||
|
|
||||||
if (!node->m_sector)
|
if (!node->m_sector)
|
||||||
break;
|
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;
|
if (!(rover->flags & FF_EXISTS))
|
||||||
fixed_t topheight, bottomheight;
|
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;
|
if (mo->z + mo->height > bottomheight)
|
||||||
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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 New Issue