From 1e60f242861af2ef9bcef7e4712d1e3786f02e80 Mon Sep 17 00:00:00 2001 From: Alaux <73968015+MrAlaux@users.noreply.github.com> Date: Sun, 26 Nov 2023 08:22:42 -0300 Subject: [PATCH] Add checks in `P_Move()` 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. --- src/p_enemy.c | 16 +++++++++++++++- src/p_map.c | 4 +++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 762a0454b..dc65d4e72 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -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; diff --git a/src/p_map.c b/src/p_map.c index 2b7ff2e4e..5ed314ae7 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -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;