Skip to content

Commit

Permalink
Add checks in P_Move()
Browse files Browse the repository at this point in the history
The `z` movement in `P_Move()` would seemingly not account for the possibility of things being over/under other things. This commit appears to fix that.
  • Loading branch information
MrAlaux committed Nov 26, 2023
1 parent 3f39013 commit 1e60f24
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/p_enemy.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,25 @@ static boolean P_Move(mobj_t *actor, boolean dropoff) // killough 9/12/98

if (actor->flags & MF_FLOAT && floatok)
{
const mobj_t *onmo; // [Nugget]

if (actor->z < tmfloorz) // must adjust height
actor->z += FLOATSPEED;
{
actor->z += FLOATSPEED;

// [Nugget]
if ((onmo = P_CheckOnmobj(actor)))
{ actor->z = onmo->z - actor->height; }
}
else
{
actor->z -= FLOATSPEED;

// [Nugget]
if ((onmo = P_CheckOnmobj(actor)))
{ actor->z = onmo->z + onmo->height; }
}

actor->flags |= MF_INFLOAT;

return true;
Expand Down
4 changes: 3 additions & 1 deletion src/p_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -2548,7 +2548,9 @@ mobj_t *P_CheckOnmobj(mobj_t *thing)
{
int xl, xh, yl, yh, bx, by;
subsector_t *newsubsec;
mobj_t oldmo = *thing; // Save the old mobj before the fake movement
const mobj_t oldmo = *thing; // Save the old mobj before the fake movement

if (!(casual_play && over_under)) { return NULL; }

tmx = thing->x;
tmy = thing->y;
Expand Down

0 comments on commit 1e60f24

Please sign in to comment.