From b8f2fe4bcc7162714cd212c2f1b054acf5c162fc Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Fri, 24 Jul 2020 15:04:55 +0200 Subject: [PATCH] Fix respawns in antigrav --- src/k_respawn.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/k_respawn.c b/src/k_respawn.c index 6c20c8f62..71b96e085 100644 --- a/src/k_respawn.c +++ b/src/k_respawn.c @@ -34,13 +34,22 @@ fixed_t K_RespawnOffset(player_t *player, boolean flip) if (flip == true) { - player->mo->flags2 |= MF2_OBJECTFLIP; + // 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); + z -= ((128 * mapobjectscale) + (player->mo->height)); } else { - player->mo->flags2 &= ~MF2_OBJECTFLIP; + + if (P_GetMobjGravity(player->mo) > 0) + player->mo->flags2 &= ~MF2_OBJECTFLIP; // See comment above, ditto. + player->mo->eflags &= ~MFE_VERTICALFLIP; z += (128 * mapobjectscale); } @@ -75,7 +84,7 @@ static void K_RespawnAtWaypoint(player_t *player, waypoint_t *waypoint) player->respawn.pointx = waypoint->mobj->x; player->respawn.pointy = waypoint->mobj->y; player->respawn.pointz = waypoint->mobj->z; - player->respawn.flip = (waypoint->mobj->flags2 & MF2_OBJECTFLIP); + player->respawn.flip = (waypoint->mobj->flags2 & MF2_OBJECTFLIP) ? true : false; // K_RespawnOffset wants a boolean! player->respawn.pointz += K_RespawnOffset(player, player->respawn.flip); } @@ -301,7 +310,7 @@ static void K_MovePlayerToRespawnPoint(player_t *player) // Reduce by the amount we needed to get to this waypoint stepamt -= dist; - // We've reached the destination point, + // We've reached the destination point, P_UnsetThingPosition(player->mo); player->mo->x = dest.x; player->mo->y = dest.y;