From 56dcfaedf82c2e350245adc1ce52b42010cf2d86 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 24 Apr 2023 17:49:53 -0700 Subject: [PATCH] Respawning: set MF2_OBJECTFLIP directly in P_GetMobjGravity K_RespawnOffset is called before the player is actually at the waypoint's position, so even if P_GetMobjGravity is called there to check, it reflects the player's current sector, which may not necessarily be the waypoint's sector. --- src/k_respawn.c | 17 +++++++---------- src/p_mobj.c | 13 +++++++++++++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/k_respawn.c b/src/k_respawn.c index 8a7d9cc7f..bbb7f2683 100644 --- a/src/k_respawn.c +++ b/src/k_respawn.c @@ -34,20 +34,10 @@ fixed_t K_RespawnOffset(player_t *player, boolean flip) if (flip == true) { - // Lat 24/7/20: Okay so before we even think about applying this flag, check if the sector we're in doesn't already have reverse gravity for that. - // Otherwise, we would reverse the reverse gravity and cancel it out. Yes, this is absolutely fucking dumb. - // I'm honestly not sure if this flag is even necessary anymore but we'll keep it just in case. - - if (P_GetMobjGravity(player->mo) < 0) - player->mo->flags2 |= MF2_OBJECTFLIP; - - player->mo->eflags |= MFE_VERTICALFLIP; z -= ((128 * mapobjectscale) + (player->mo->height)); } else { - player->mo->flags2 &= ~MF2_OBJECTFLIP; - player->mo->eflags &= ~MFE_VERTICALFLIP; z += (128 * mapobjectscale); } @@ -447,6 +437,13 @@ static void K_MovePlayerToRespawnPoint(player_t *player) player->respawn.wp = player->respawn.wp->nextwaypoints[nwp]; K_RespawnAtWaypoint(player, player->respawn.wp); + player->mo->eflags &= ~(MFE_VERTICALFLIP); + + if (player->respawn.flip) + { + player->mo->eflags |= MFE_VERTICALFLIP; + } + dest.x = player->respawn.pointx; dest.y = player->respawn.pointy; dest.z = player->respawn.pointz; diff --git a/src/p_mobj.c b/src/p_mobj.c index a0790e6f8..df6af073f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1119,6 +1119,19 @@ fixed_t P_GetMobjGravity(mobj_t *mo) if (mo->player) { + if (mo->player->respawn.state != RESPAWNST_NONE) + { + // Respawning forces gravity to match waypoint configuration + mo->flags2 &= ~(MF2_OBJECTFLIP); + + // If this sector's gravity doesn't already match + if ((gravityadd > 0) != mo->player->respawn.flip) + { + mo->flags2 |= MF2_OBJECTFLIP; + } + } + + // MF2_OBJECTFLIP is relative -- flips sector reverse gravity back to normal if (mo->flags2 & MF2_OBJECTFLIP) { gravityadd = -gravityadd;