diff --git a/src/doomstat.h b/src/doomstat.h index f6b501145..484e773a7 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -636,6 +636,7 @@ struct exitcondition_t { boolean losing; boolean retry; + boolean hasfinished; }; // For racing diff --git a/src/g_game.c b/src/g_game.c index 113e481fa..2bc4bca35 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3244,6 +3244,10 @@ void G_AddPlayer(INT32 playernum, INT32 console) void G_BeginLevelExit(void) { + if (g_exit.hasfinished) + return; // the round has already finished! + + g_exit.hasfinished = true; g_exit.losing = true; g_exit.retry = false; @@ -3285,13 +3289,7 @@ void G_BeginLevelExit(void) } } } - } - - exitcountdown = raceexittime+1; - - if (g_exit.losing) - { if (!g_exit.retry) { ACS_RunGameOverScript(); diff --git a/src/p_saveg.c b/src/p_saveg.c index faf60c1a1..f0ec19a4e 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -5396,10 +5396,11 @@ static void P_NetArchiveMisc(savebuffer_t *save, boolean resending) WRITEUINT32(save->p, racecountdown); WRITEUINT32(save->p, exitcountdown); - + // exitcondition_t WRITEUINT8(save->p, g_exit.losing); WRITEUINT8(save->p, g_exit.retry); + WRITEUINT8(save->p, g_exit.hasfinished); WRITEFIXED(save->p, gravity); WRITEFIXED(save->p, mapobjectscale); @@ -5789,7 +5790,8 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(savebuffer_t *save, bool // exitcondition_t g_exit.losing = READUINT8(save->p); g_exit.retry = READUINT8(save->p); - + g_exit.hasfinished = READUINT8(save->p); + gravity = READFIXED(save->p); mapobjectscale = READFIXED(save->p); diff --git a/src/p_setup.c b/src/p_setup.c index 8503349f1..99c182af1 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -8106,8 +8106,7 @@ static void P_InitLevelSettings(boolean reloadinggamestate) racecountdown = exitcountdown = exitfadestarted = 0; curlap = bestlap = 0; // SRB2Kart - g_exit.losing = false; - g_exit.retry = false; + g_exit.losing = g_exit.retry = g_exit.hasfinished = false; // SRB2Kart: map load variables if (grandprixinfo.gp == true) diff --git a/src/p_user.c b/src/p_user.c index 51a944793..e977f9ba4 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1282,23 +1282,22 @@ void P_DoPlayerExit(player_t *player, pflags_t flags) if (P_IsLocalPlayer(player) && (!player->spectator && !demo.playback)) legitimateexit = true; - + if (player->griefstrikes > 0) player->griefstrikes--; // Remove a strike for finishing a race normally - player->exiting = 1; - if (!player->spectator && (gametyperules & GTR_CIRCUIT)) // Special Race-like handling { K_UpdateAllPlayerPositions(); } - + losing = K_IsPlayerLosing(player); // HEY!!!! Set it AFTER K_UpdateAllPlayerPositions!!!! if (!player->spectator) { if ((gametyperules & GTR_CIRCUIT)) // If in Race Mode, allow { + player->exiting = raceexittime+2; if (cv_kartvoices.value) { const INT32 sfx_id = (losing ? sfx_klose : sfx_kwin); @@ -1309,21 +1308,22 @@ void P_DoPlayerExit(player_t *player, pflags_t flags) if (!K_CanChangeRules() || cv_inttime.value > 0) P_EndingMusic(player); - if (P_CheckRacers() && !exitcountdown) + if (P_CheckRacers()) { + player->exiting = raceexittime+1; G_BeginLevelExit(); } } else if ((gametyperules & GTR_BUMPERS)) // Battle Mode exiting { - if (!exitcountdown) - exitcountdown = battleexittime+1; + player->exiting = battleexittime+1; + G_BeginLevelExit(); P_EndingMusic(player); } else // Accidental death safeguard??? { - if (!exitcountdown) - G_BeginLevelExit(); + player->exiting = raceexittime+2; + G_BeginLevelExit(); } if (grandprixinfo.gp == true) @@ -3603,7 +3603,10 @@ void P_DoTimeOver(player_t *player) P_EndingMusic(player); if (!exitcountdown) + { G_BeginLevelExit(); + exitcountdown = 5*TICRATE; + } } // SRB2Kart: These are useful functions, but we aren't using them yet. @@ -3940,6 +3943,36 @@ void P_PlayerThink(player_t *player) player->kickstartaccel = ACCEL_KICKSTART+1; } + // MKWii-styled icon spinouts: do a full 360 rotation before stopping. + if (P_PlayerInPain(player)) + { + if (player->spinoutrot < MAXSPINROT) + { + if ((player->spinoutrot + SPINOUTROTSPEED) >= MAXSPINROT) + { + player->spinoutrot = (player->spinoutrot + SPINOUTROTSPEED) % MAXSPINROT; + } + else + { + player->spinoutrot += SPINOUTROTSPEED; + } + } + } + else + { + if ((player->spinoutrot) && (player->spinoutrot < MAXSPINROT)) + { + if ((player->spinoutrot + SPINOUTROTSPEED) >= MAXSPINROT) + { + player->spinoutrot = 0; + } + else + { + player->spinoutrot += SPINOUTROTSPEED; + } + } + } + #ifdef PARANOIA if (player->playerstate == PST_REBORN) I_Error("player %s is in PST_REBORN\n", sizeu1(playeri)); @@ -3989,36 +4022,6 @@ void P_PlayerThink(player_t *player) } } - // MKWii-styled icon spinouts: do a full 360 rotation before stopping. - if (P_PlayerInPain(player)) - { - if (player->spinoutrot < MAXSPINROT) - { - if ((player->spinoutrot + SPINOUTROTSPEED) >= MAXSPINROT) - { - player->spinoutrot = (player->spinoutrot + SPINOUTROTSPEED) % MAXSPINROT; - } - else - { - player->spinoutrot += SPINOUTROTSPEED; - } - } - } - else - { - if ((player->spinoutrot) && (player->spinoutrot < MAXSPINROT)) - { - if ((player->spinoutrot + SPINOUTROTSPEED) >= MAXSPINROT) - { - player->spinoutrot = 0; - } - else - { - player->spinoutrot += SPINOUTROTSPEED; - } - } - } - // If it is set, start subtracting // Don't allow it to go back to 0 if (player->exiting > 1 && (player->exiting < raceexittime+2 || !(gametyperules & GTR_CIRCUIT))) // SRB2kart - "&& player->exiting > 1"