Fix conflicting step up/down code

This commit is contained in:
James R 2020-10-25 17:02:32 -07:00
parent 2c35034960
commit e5a9bfc968

View file

@ -2525,60 +2525,57 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
floatok = true; floatok = true;
thingtop = thing->z + thing->height; if (maxstep > 0)
// Step up
if (thing->z < tmfloorz)
{ {
if (tmfloorz - thing->z <= maxstep) thingtop = thing->z + thing->height;
{
thing->z = thing->floorz = tmfloorz;
thing->floorrover = tmfloorrover;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
else
{
return false; // mobj must raise itself to fit
}
}
else if (tmceilingz < thingtop)
return false; // mobj must lower itself to fit
// Ramp test // Step up
if ((maxstep > 0) && !(P_MobjTouchingSectorSpecial(thing, 1, 14, false))) if (thing->z < tmfloorz)
{
// If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS
// step down! Formerly required a Section1:13 sector for the full MAXSTEPMOVE, but no more.
if (thingtop == thing->ceilingz && tmceilingz > thingtop && tmceilingz - thingtop <= maxstep)
{ {
if (tmfloorstep <= maxstep)
{
thing->z = thing->floorz = tmfloorz;
thing->floorrover = tmfloorrover;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
else
{
return false; // mobj must raise itself to fit
}
}
else if (tmceilingz < thingtop)
{
if (tmceilingstep <= maxstep)
{
thing->z = ( thing->ceilingz = tmceilingz ) - thing->height;
thing->ceilingrover = tmceilingrover;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
else
{
return false; // mobj must lower itself to fit
}
}
else if (!(P_MobjTouchingSectorSpecial(thing, 1, 14, false))) // Step down
{
// If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS
// step down! Formerly required a Section1:13 sector for the full MAXSTEPMOVE, but no more.
if (thingtop == thing->ceilingz && tmceilingz > thingtop && thing->ceilingdrop <= maxstep) if (thingtop == thing->ceilingz && tmceilingz > thingtop && thing->ceilingdrop <= maxstep)
{ {
thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; thing->z = (thing->ceilingz = tmceilingz) - thing->height;
thing->ceilingrover = tmceilingrover; thing->ceilingrover = tmceilingrover;
thing->eflags |= MFE_JUSTSTEPPEDDOWN; thing->eflags |= MFE_JUSTSTEPPEDDOWN;
thing->ceilingdrop = 0; thing->ceilingdrop = 0;
} }
else if (tmceilingz < thingtop && tmceilingstep <= maxstep) else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->floordrop <= maxstep)
{ {
thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; thing->z = thing->floorz = tmfloorz;
thing->ceilingrover = tmceilingrover; thing->floorrover = tmfloorrover;
thing->eflags |= MFE_JUSTSTEPPEDDOWN; thing->eflags |= MFE_JUSTSTEPPEDDOWN;
thing->floordrop = 0;
} }
} }
else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->floordrop <= maxstep)
{
thing->z = thing->floorz = tmfloorz;
thing->floorrover = tmfloorrover;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
thing->floordrop = 0;
}
else if (tmfloorz > thing->z && tmfloorstep <= maxstep)
{
thing->z = thing->floorz = tmfloorz;
thing->floorrover = tmfloorrover;
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
}
} }
if (!allowdropoff && !(thing->flags & MF_FLOAT) && thing->type != MT_SKIM && !tmfloorthing) if (!allowdropoff && !(thing->flags & MF_FLOAT) && thing->type != MT_SKIM && !tmfloorthing)