Fix Stepup issues for the most aprt.
This fixes midtexture stepover and extreme stepup such as the jank line in greenhils
This commit is contained in:
parent
da4f6c62a2
commit
0495190a08
1 changed files with 65 additions and 40 deletions
105
src/p_map.c
105
src/p_map.c
|
|
@ -2520,6 +2520,20 @@ fixed_t P_GetThingStepUp(mobj_t *thing, fixed_t destX, fixed_t destY)
|
|||
return maxstep;
|
||||
}
|
||||
|
||||
// Used for averging height values for step up.
|
||||
static fixed_t avgheight(fixed_t a, fixed_t b)
|
||||
{
|
||||
if (((b > 0) && (a > (INT32_MAX - b))) ||
|
||||
((b < 0) && (a < (INT32_MIN - b))))
|
||||
{
|
||||
return b + (a - b) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (a + b) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
static boolean
|
||||
increment_move
|
||||
( mobj_t * thing,
|
||||
|
|
@ -2624,51 +2638,62 @@ increment_move
|
|||
|
||||
thingtop = thing->z + thing->height;
|
||||
|
||||
// Step up
|
||||
if (thing->z < g_tm.floorz)
|
||||
if (maxstep > 0)
|
||||
{
|
||||
if (g_tm.floorz - thing->z <= maxstep)
|
||||
{
|
||||
thing->z = thing->floorz = g_tm.floorz;
|
||||
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false; // mobj must raise itself to fit
|
||||
}
|
||||
}
|
||||
else if (g_tm.ceilingz < thingtop)
|
||||
{
|
||||
if (thingtop - g_tm.ceilingz <= maxstep)
|
||||
{
|
||||
thing->z = ( thing->ceilingz = g_tm.ceilingz ) - thing->height;
|
||||
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false; // mobj must lower itself to fit
|
||||
}
|
||||
}
|
||||
else if (maxstep > 0 && !(
|
||||
thing->player && (
|
||||
P_MobjTouchingSectorSpecialFlag(thing, SSF_NOSTEPDOWN)
|
||||
|| (R_PointInSubsector(x, y)->sector->specialflags & SSF_NOSTEPDOWN))
|
||||
)) // 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.
|
||||
fixed_t stepheight;
|
||||
|
||||
if (thingtop == thing->ceilingz && g_tm.ceilingz > thingtop && g_tm.ceilingz - thingtop <= maxstep)
|
||||
// Step up
|
||||
if (thing->z < g_tm.floorz)
|
||||
{
|
||||
thing->z = (thing->ceilingz = g_tm.ceilingz) - thing->height;
|
||||
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
|
||||
thing->ceilingdrop = 0;
|
||||
stepheight = avgheight(g_tm.floorz - thing->z, g_tm.floorstep);
|
||||
|
||||
if (stepheight <= maxstep)
|
||||
{
|
||||
thing->z = thing->floorz = g_tm.floorz;
|
||||
thing->floorrover = g_tm.floorrover;
|
||||
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false; // mobj must raise itself to fit
|
||||
}
|
||||
}
|
||||
else if (thing->z == thing->floorz && g_tm.floorz < thing->z && thing->z - g_tm.floorz <= maxstep)
|
||||
else if (g_tm.ceilingz < thingtop)
|
||||
{
|
||||
thing->z = thing->floorz = g_tm.floorz;
|
||||
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
|
||||
thing->floordrop = 0;
|
||||
stepheight = avgheight(thingtop - g_tm.ceilingz, g_tm.ceilingstep);
|
||||
|
||||
if (stepheight <= maxstep)
|
||||
{
|
||||
thing->z = ( thing->ceilingz = g_tm.ceilingz ) - thing->height;
|
||||
thing->ceilingrover = g_tm.ceilingrover;
|
||||
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false; // mobj must lower itself to fit
|
||||
}
|
||||
}
|
||||
else if (thing->momz * P_MobjFlip(thing) <= 0 // Step down requires moving down.
|
||||
&& !(P_MobjTouchingSectorSpecialFlag(thing, SSF_NOSTEPDOWN)
|
||||
|| (R_PointInSubsector(x, y)->sector->specialflags & SSF_NOSTEPDOWN)))
|
||||
{
|
||||
// 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 && g_tm.ceilingz > thingtop && g_tm.ceilingz - thingtop <= maxstep)
|
||||
{
|
||||
thing->z = (thing->ceilingz = g_tm.ceilingz) - thing->height;
|
||||
thing->ceilingrover = g_tm.ceilingrover;
|
||||
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
|
||||
thing->ceilingdrop = 0;
|
||||
}
|
||||
else if (thing->z == thing->floorz && g_tm.floorz < thing->z && thing->z - g_tm.floorz <= maxstep)
|
||||
{
|
||||
thing->z = thing->floorz = g_tm.floorz;
|
||||
thing->floorrover = g_tm.floorrover;
|
||||
thing->eflags |= MFE_JUSTSTEPPEDDOWN;
|
||||
thing->floordrop = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue