From 3b755b7153d0d44ef2c90ebda5577168e84a9963 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Tue, 16 Jan 2024 20:08:37 -0500 Subject: [PATCH] Reorganize P_DoPlayerExit I tried to fix the GP ending weirdness a long time ago by recalculating all player positions at time of exit... and then K_IsPlayerLosing gets to a variable before the recalculation and a bunch of crap uses it and completely undoes anything this might've fixed. DON'T DO THAT! --- src/k_grandprix.c | 2 +- src/p_user.c | 45 ++++++++++++++++++++++++--------------------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/k_grandprix.c b/src/k_grandprix.c index 7ede8533c..5b45c8176 100644 --- a/src/k_grandprix.c +++ b/src/k_grandprix.c @@ -845,7 +845,7 @@ void K_PlayerLoseLife(player_t *player) return; } - if (player->spectator || (player->exiting && !(player->pflags & PF_NOCONTEST)) || player->bot || player->lives <= 0 || (player->pflags & PF_LOSTLIFE)) + if (player->spectator || player->bot || player->lives <= 0 || (player->pflags & PF_LOSTLIFE)) { return; } diff --git a/src/p_user.c b/src/p_user.c index 350ded74c..a491fca98 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1270,9 +1270,6 @@ void P_DoPlayerExit(player_t *player, pflags_t flags) player->pflags |= flags; - const boolean losing = K_IsPlayerLosing(player); - const boolean specialout = (specialstageinfo.valid == true && losing == true); - if (P_IsLocalPlayer(player) && (!player->spectator && !demo.playback)) { legitimateexit = true; @@ -1280,6 +1277,30 @@ void P_DoPlayerExit(player_t *player, pflags_t flags) gamedata->deferredconditioncheck = true; } + player->exiting = 1; + + if (!player->spectator) + { + ClearFakePlayerSkin(player); + + if ((gametyperules & GTR_CIRCUIT)) // Special Race-like handling + { + K_UpdateAllPlayerPositions(); + + if (P_CheckRacers() && !exitcountdown) + { + G_BeginLevelExit(); + } + } + else if (!exitcountdown) // All other gametypes + { + G_BeginLevelExit(); + } + } + + const boolean losing = K_IsPlayerLosing(player); // HEY!!!! Set it AFTER K_UpdateAllPlayerPositions!!!! + const boolean specialout = (specialstageinfo.valid == true && losing == true); + if (G_GametypeUsesLives() && losing) { // Remove a life from the losing player @@ -1292,12 +1313,8 @@ void P_DoPlayerExit(player_t *player, pflags_t flags) musiccountdown = MUSIC_COUNTDOWN_MAX; } - player->exiting = 1; - if (!player->spectator) { - ClearFakePlayerSkin(player); - if (!(gametyperules & GTR_SPHERES)) { player->hudrings = RINGTOTAL(player); @@ -1320,20 +1337,6 @@ void P_DoPlayerExit(player_t *player, pflags_t flags) } } - if ((gametyperules & GTR_CIRCUIT)) // Special Race-like handling - { - K_UpdateAllPlayerPositions(); - - if (P_CheckRacers() && !exitcountdown) - { - G_BeginLevelExit(); - } - } - else if (!exitcountdown) // All other gametypes - { - G_BeginLevelExit(); - } - if (specialstageinfo.valid == true && losing == false && P_MobjWasRemoved(player->mo) == false) { K_MakeObjectReappear(player->mo);