diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 344c6380b..f938c0119 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -449,6 +449,7 @@ consvar_t cv_kartdebugnodes = CVAR_INIT ("debugnodes", "Off", CV_CHEAT, CV_OnOff consvar_t cv_kartdebugcolorize = CVAR_INIT ("debugcolorize", "Off", CV_CHEAT, CV_OnOff, NULL); consvar_t cv_kartdebugdirector = CVAR_INIT ("debugdirector", "Off", CV_CHEAT, CV_OnOff, NULL); consvar_t cv_spbtest = CVAR_INIT ("spbtest", "Off", CV_CHEAT|CV_NETVAR, CV_OnOff, NULL); +consvar_t cv_gptest = CVAR_INIT ("gptest", "Off", CV_CHEAT|CV_NETVAR, CV_OnOff, NULL); static CV_PossibleValue_t votetime_cons_t[] = {{10, "MIN"}, {3600, "MAX"}, {0, NULL}}; consvar_t cv_votetime = CVAR_INIT ("votetime", "20", CV_NETVAR, votetime_cons_t, NULL); diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 0355722d6..d6aa7fa5b 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -120,7 +120,8 @@ extern consvar_t cv_kartusepwrlv; extern consvar_t cv_votetime; extern consvar_t cv_kartdebugitem, cv_kartdebugamount, cv_kartdebugdistribution, cv_kartdebughuddrop; -extern consvar_t cv_kartdebugnodes, cv_kartdebugcolorize, cv_kartdebugdirector, cv_spbtest; +extern consvar_t cv_kartdebugnodes, cv_kartdebugcolorize, cv_kartdebugdirector; +extern consvar_t cv_spbtest, cv_gptest; extern consvar_t cv_kartdebugwaypoints, cv_kartdebugbotpredict; extern consvar_t cv_itemfinder; diff --git a/src/k_battle.c b/src/k_battle.c index c918daec7..1a4680842 100644 --- a/src/k_battle.c +++ b/src/k_battle.c @@ -133,6 +133,10 @@ void K_CheckBumpers(void) { for (i = 0; i < MAXPLAYERS; i++) { + if (!playeringame[i]) + continue; + if (players[i].spectator) + continue; players[i].pflags |= PF_NOCONTEST; P_DoPlayerExit(&players[i]); } @@ -144,7 +148,8 @@ void K_CheckBumpers(void) if (!battlecapsules) { // Reset map to turn on battle capsules - D_MapChange(gamemap, gametype, encoremode, true, 0, false, false); + if (server) + D_MapChange(gamemap, gametype, encoremode, true, 0, false, false); } else { @@ -152,6 +157,10 @@ void K_CheckBumpers(void) { for (i = 0; i < MAXPLAYERS; i++) { + if (!playeringame[i]) + continue; + if (players[i].spectator) + continue; players[i].pflags |= PF_NOCONTEST; P_DoPlayerExit(&players[i]); } diff --git a/src/k_grandprix.c b/src/k_grandprix.c index a0e8e5af3..0fe0e557f 100644 --- a/src/k_grandprix.c +++ b/src/k_grandprix.c @@ -651,7 +651,7 @@ void K_FakeBotResults(player_t *bot) } // hey, you "won" - bot->exiting = 2; + bot->exiting = 1; bot->realtime += (bot->distancetofinish / distfactor); bot->distancetofinish = 0; K_IncreaseBotDifficulty(bot); diff --git a/src/p_inter.c b/src/p_inter.c index fd13e38f7..30b0b34f4 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -848,7 +848,7 @@ boolean P_CheckRacers(void) } // Everyone should be done playing at this point now. - racecountdown = exitcountdown = 0; + racecountdown = 0; return true; } @@ -856,7 +856,7 @@ boolean P_CheckRacers(void) { // There might be bots that are still going, // but all of the humans are done, so we can exit now. - racecountdown = exitcountdown = 0; + racecountdown = 0; return true; } diff --git a/src/p_setup.c b/src/p_setup.c index 49deb7cf4..001bd404b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3843,6 +3843,7 @@ static void P_InitPlayers(void) static void P_InitGametype(void) { size_t i; + boolean canchangerules = K_CanChangeRules(); spectateGriefed = 0; K_CashInPowerLevels(); // Pushes power level changes even if intermission was skipped @@ -3852,24 +3853,31 @@ static void P_InitGametype(void) if (modeattacking && !demo.playback) P_LoadRecordGhosts(); - numlaps = 0; if (gametyperules & GTR_CIRCUIT) { - if ((netgame || multiplayer) && cv_numlaps.value + if (canchangerules && cv_numlaps.value && (!(mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE) || (mapheaderinfo[gamemap - 1]->numlaps > cv_numlaps.value))) { numlaps = cv_numlaps.value; } + else if (cv_gptest.value) + { + numlaps = 1; + } else { numlaps = mapheaderinfo[gamemap - 1]->numlaps; } } + else + { + numlaps = 0; + } if ((gametyperules & GTR_TIMELIMIT) && !bossinfo.boss) { - if (K_CanChangeRules() == false) + if (!canchangerules) { timelimitintics = timelimits[gametype] * (60*TICRATE); } diff --git a/src/p_tick.c b/src/p_tick.c index f0ba05546..5f3edd7c5 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -594,20 +594,31 @@ void P_Ticker(boolean run) ps_playerthink_time = I_GetPreciseTime(); +#define PLAYERCONDITION(i) (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) // First loop: Ensure all players' distance to the finish line are all accurate for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) - K_UpdateDistanceFromFinishLine(&players[i]); + { + if (!PLAYERCONDITION(i)) + continue; + K_UpdateDistanceFromFinishLine(&players[i]); + } // Second loop: Ensure all player positions reflect everyone's distances for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) - K_KartUpdatePosition(&players[i]); + { + if (!PLAYERCONDITION(i)) + continue; + K_KartUpdatePosition(&players[i]); + } // OK! Now that we got all of that sorted, players can think! for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) - P_PlayerThink(&players[i]); + { + if (!PLAYERCONDITION(i)) + continue; + P_PlayerThink(&players[i]); + } +#undef PLAYERCONDITION ps_playerthink_time = I_GetPreciseTime() - ps_playerthink_time; } @@ -690,7 +701,13 @@ void P_Ticker(boolean run) racecountdown--; if (exitcountdown > 1) + { exitcountdown--; + if (server && exitcountdown == 1) + { + SendNetXCmd(XD_EXITLEVEL, NULL, 0); + } + } K_RunItemCooldowns(); diff --git a/src/p_user.c b/src/p_user.c index 30090ac8e..418ac6543 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1261,9 +1261,10 @@ void P_DoPlayerExit(player_t *player) K_PlayerLoseLife(player); } + player->exiting = 1; + if ((gametyperules & GTR_CIRCUIT)) // If in Race Mode, allow { - player->exiting = raceexittime+2; K_KartUpdatePosition(player); if (cv_kartvoices.value) @@ -1289,16 +1290,20 @@ void P_DoPlayerExit(player_t *player) if (!K_CanChangeRules() || cv_inttime.value > 0) P_EndingMusic(player); - if (P_CheckRacers()) - player->exiting = raceexittime+1; + if (P_CheckRacers() && !exitcountdown) + exitcountdown = raceexittime+1; } else if ((gametyperules & GTR_BUMPERS)) // Battle Mode exiting { - player->exiting = battleexittime+1; + if (!exitcountdown) + exitcountdown = battleexittime+1; P_EndingMusic(player); } - else - player->exiting = raceexittime+2; // Accidental death safeguard??? + else // Accidental death safeguard??? + { + if (!exitcountdown) + exitcountdown = raceexittime+2; + } if (grandprixinfo.gp == true) { @@ -3946,21 +3951,6 @@ void P_PlayerThink(player_t *player) { if (gametyperules & GTR_CIRCUIT) { - INT32 i; - - // Check if all the players in the race have finished. If so, end the level. - for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && !players[i].spectator) - { - if (!players[i].exiting && !(players[i].pflags & PF_NOCONTEST) && players[i].lives > 0) - break; - } - } - - if (i == MAXPLAYERS && player->exiting == raceexittime+2) // finished - player->exiting = raceexittime+1; - #if 0 // If 10 seconds are left on the timer, // begin the drown music for countdown! @@ -3985,22 +3975,6 @@ void P_PlayerThink(player_t *player) } } } - - // 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" - player->exiting--; - - if (player->exiting && exitcountdown) - player->exiting = 99; // SRB2kart - - if (player->exiting == 2 || exitcountdown == 2) - { - if (server) - { - SendNetXCmd(XD_EXITLEVEL, NULL, 0); - } - } } // check water content, set stuff in mobj