diff --git a/src/k_respawn.c b/src/k_respawn.c index 8a7d9cc7f..8f0c756f1 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); } @@ -261,7 +251,7 @@ void K_DoIngameRespawn(player_t *player) s = R_PointInSubsector(beststart->x << FRACBITS, beststart->y << FRACBITS)->sector; - player->respawn.flip = (beststart->options & MTF_OBJECTFLIP); + player->respawn.flip = (beststart->options & MTF_OBJECTFLIP) != 0; if (player->respawn.flip == true) { @@ -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; @@ -560,7 +557,7 @@ static void K_MovePlayerToRespawnPoint(player_t *player) dest.x = laserwp->mobj->x; dest.y = laserwp->mobj->y; dest.z = laserwp->mobj->z; - laserflip = (laserwp->mobj->flags2 & MF2_OBJECTFLIP); + laserflip = (laserwp->mobj->flags2 & MF2_OBJECTFLIP) ? true : false; // K_RespawnOffset wants a boolean! if (laserflip == true) { diff --git a/src/p_mobj.c b/src/p_mobj.c index a0790e6f8..1c67ad98e 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; @@ -11956,7 +11969,7 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing) fixed_t offset = mthing->z << FRACBITS; if (p->respawn.state != RESPAWNST_NONE || p->spectator) - offset += K_RespawnOffset(p, (mthing->options & MTF_OBJECTFLIP)); + offset += K_RespawnOffset(p, (mthing->options & MTF_OBJECTFLIP) != 0); // Setting the spawnpoint's args[0] will make the player start on the ceiling // Objectflip inverts