diff --git a/src/g_game.c b/src/g_game.c index bb803209b..9d250f120 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3208,6 +3208,14 @@ void G_ExitLevel(void) } else if (grandprixinfo.gp == true && grandprixinfo.eventmode == GPEVENT_NONE) { + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && !players[i].spectator) + { + K_PlayerFinishGrandPrix(&players[i]); + } + } + doretry = (grandprixinfo.wonround != true); } diff --git a/src/k_grandprix.c b/src/k_grandprix.c index 61044aa68..213e108b5 100644 --- a/src/k_grandprix.c +++ b/src/k_grandprix.c @@ -18,6 +18,7 @@ #include "k_bot.h" #include "k_kart.h" #include "m_random.h" +#include "p_local.h" #include "r_things.h" struct grandprixinfo grandprixinfo; @@ -722,3 +723,51 @@ boolean K_CanChangeRules(boolean allowdemos) return true; } + +/*-------------------------------------------------- + void K_PlayerFinishGrandPrix(player_t *player); + + See header file for description. +--------------------------------------------------*/ +void K_PlayerFinishGrandPrix(player_t *player) +{ + if (player->exiting == false) + { + // You did not finish + return; + } + + if (player->bot) + { + // Bots are going to get harder... :) + K_IncreaseBotDifficulty(player); + return; + } + + if (K_IsPlayerLosing(player)) + { + return; + } + + // YOU WIN + grandprixinfo.wonround = true; + + // Increase your total rings + if (RINGTOTAL(player) > 0) + { + player->totalring += RINGTOTAL(player); + grandprixinfo.rank.rings += RINGTOTAL(player); + } + + if (grandprixinfo.eventmode == GPEVENT_NONE) + { + grandprixinfo.rank.winPoints += K_CalculateGPRankPoints(player->position, grandprixinfo.rank.totalPlayers); + grandprixinfo.rank.laps += player->lapPoints; + } + else if (grandprixinfo.eventmode == GPEVENT_SPECIAL) + { + grandprixinfo.rank.specialWon = true; + } + + P_GivePlayerLives(player, player->xtralife); +} diff --git a/src/k_grandprix.h b/src/k_grandprix.h index 9bfc982e5..891efc85c 100644 --- a/src/k_grandprix.h +++ b/src/k_grandprix.h @@ -182,6 +182,21 @@ void K_PlayerLoseLife(player_t *player); boolean K_CanChangeRules(boolean allowdemos); +/*-------------------------------------------------- + void K_PlayerFinishGrandPrix(player_t *player); + + Increases rank and bot difficulties, wins the round. + + Input Arguments:- + player - Player to do this for. + + Return:- + None +--------------------------------------------------*/ + +void K_PlayerFinishGrandPrix(player_t *player); + + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/p_setup.c b/src/p_setup.c index 40a68144a..94820188e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -7402,6 +7402,8 @@ static void P_InitPlayers(void) { G_SpawnPlayer(i); } + + players[i].xtralife = 0; // extra lives do not ever carry over from the previous round } K_UpdateAllPlayerPositions(); @@ -7474,6 +7476,8 @@ static void P_InitGametype(void) lastLowestLap = 0; spbplace = -1; + G_ClearRetryFlag(); + // Start recording replay in multiplayer with a temp filename //@TODO I'd like to fix dedis crashing when recording replays for the future too... if (gamestate == GS_LEVEL && !demo.playback && multiplayer && !dedicated) diff --git a/src/p_user.c b/src/p_user.c index 823a65dc4..1ad2240bb 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1349,46 +1349,17 @@ void P_DoPlayerExit(player_t *player) exitcountdown = raceexittime+2; } - if (grandprixinfo.gp == true) + if (grandprixinfo.gp == true && player->bot == false && losing == false) { - if (player->bot) + const UINT8 lifethreshold = 20; + + const UINT8 oldExtra = player->totalring / lifethreshold; + const UINT8 extra = (player->totalring + RINGTOTAL(player)) / lifethreshold; + + if (extra > oldExtra) { - // Bots are going to get harder... :) - K_IncreaseBotDifficulty(player); - } - else if (!losing) - { - const UINT8 lifethreshold = 20; - UINT8 extra = 0; - - // YOU WIN - grandprixinfo.wonround = true; - - // Increase your total rings - if (RINGTOTAL(player) > 0) - { - player->totalring += RINGTOTAL(player); - grandprixinfo.rank.rings += RINGTOTAL(player); - - extra = player->totalring / lifethreshold; - - if (extra > player->xtralife) - { - P_GivePlayerLives(player, extra - player->xtralife); - S_StartSound(NULL, sfx_cdfm73); - player->xtralife = extra; - } - } - - if (grandprixinfo.eventmode == GPEVENT_NONE) - { - grandprixinfo.rank.winPoints += K_CalculateGPRankPoints(player->position, grandprixinfo.rank.totalPlayers); - grandprixinfo.rank.laps += player->lapPoints; - } - else if (grandprixinfo.eventmode == GPEVENT_SPECIAL) - { - grandprixinfo.rank.specialWon = true; - } + S_StartSound(NULL, sfx_cdfm73); + player->xtralife = (extra - oldExtra); } } }