]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix #2850 "xonotic crashes when pressing restart level after match end in campaign"
authorterencehill <piuntn@gmail.com>
Sun, 9 Jul 2023 08:39:26 +0000 (10:39 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 9 Jul 2023 08:39:26 +0000 (10:39 +0200)
qcsrc/common/gamemodes/gamemode/assault/sv_assault.qc
qcsrc/server/command/vote.qc

index e9fb0a48dea9b2988e4bf22135d457b143a65d22..882be18ea93a1600e636dfaf8dc0a9f2d099c470 100644 (file)
@@ -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;
index a3d146c75f7529cbe8a9e9689e717a983ceefe43..e8c6812c2c4faaf38c380314de00c43a8095cfdd 100644 (file)
@@ -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