From: terencehill Date: Sun, 9 Jul 2023 08:39:26 +0000 (+0200) Subject: Fix #2850 "xonotic crashes when pressing restart level after match end in campaign" X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d7e0a1d59f86db1ee3018030badefe4508f84f33;p=xonotic%2Fxonotic-data.pk3dir.git Fix #2850 "xonotic crashes when pressing restart level after match end in campaign" --- diff --git a/qcsrc/common/gamemodes/gamemode/assault/sv_assault.qc b/qcsrc/common/gamemodes/gamemode/assault/sv_assault.qc index e9fb0a48d..882be18ea 100644 --- a/qcsrc/common/gamemodes/gamemode/assault/sv_assault.qc +++ b/qcsrc/common/gamemodes/gamemode/assault/sv_assault.qc @@ -255,6 +255,7 @@ int WinningCondition_Assault() TeamScore_AddToTeam(assault_attacker_team, ST_ASSAULT_OBJECTIVES, 666 - TeamScore_AddToTeam(assault_attacker_team, ST_ASSAULT_OBJECTIVES, 0)); + // in campaign the game ends when the player destroys the objective, there's no second round if(ent.cnt == 1 || autocvar_g_campaign) // this was the second round or the only round in campaign { status = WINNING_YES; @@ -629,8 +630,9 @@ MUTATOR_HOOKFUNCTION(as, OnEntityPreSpawn) MUTATOR_HOOKFUNCTION(as, ReadyRestart_Deny) { - // readyrestart not supported (yet) - // it's supported only in campaign mode (single round mode), since campaign requires it + // readyrestart not supported + // it's allowed only in campaign since the campaign requires readyrestart support + // to do so Assault is played in single round mode if (autocvar_g_campaign) return false; return true; diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index a3d146c75..e8c6812c2 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -499,14 +499,17 @@ void ReadyRestart_force(bool is_fake_round_start) void ReadyRestart(bool forceWarmupEnd) { - if (MUTATOR_CALLHOOK(ReadyRestart_Deny) || intermission_running || race_completing) + if (MUTATOR_CALLHOOK(ReadyRestart_Deny)) { // NOTE: ReadyRestart support is mandatory in campaign if (autocvar_g_campaign) error("ReadyRestart must be supported in campaign mode!"); localcmd("restart\n"); // if ReadyRestart is denied, restart the server } - else localcmd("\nsv_hook_readyrestart\n"); + else if (intermission_running || race_completing) // game is over, ReadyRestart no longer available + localcmd("restart\n"); + else + localcmd("\nsv_hook_readyrestart\n"); if(forceWarmupEnd || autocvar_g_campaign) warmup_stage = 0; // forcefully end warmup and go to match stage