Add ReadyRestart support to Assault in campaign mode since it's a requirement now...
authorterencehill <piuntn@gmail.com>
Thu, 12 May 2022 14:01:13 +0000 (16:01 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 12 May 2022 14:01:13 +0000 (16:01 +0200)
qcsrc/common/gamemodes/gamemode/assault/sv_assault.qc
qcsrc/server/command/vote.qc
qcsrc/server/mutators/events.qh

index 5edfd5ff1863362ecaf53354431793598c11e228..e9fb0a48dea9b2988e4bf22135d457b143a65d22 100644 (file)
@@ -255,7 +255,7 @@ int WinningCondition_Assault()
 
                        TeamScore_AddToTeam(assault_attacker_team, ST_ASSAULT_OBJECTIVES, 666 - TeamScore_AddToTeam(assault_attacker_team, ST_ASSAULT_OBJECTIVES, 0));
 
-                       if(ent.cnt == 1 || autocvar_g_campaign) // this was the second round
+                       if(ent.cnt == 1 || autocvar_g_campaign) // this was the second round or the only round in campaign
                        {
                                status = WINNING_YES;
                        }
@@ -630,5 +630,8 @@ 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
+       if (autocvar_g_campaign)
+               return false;
        return true;
 }
index 01758efe5e4630e357962b9e9b65b330cb740480..12e130c9e80ddf25aa17ba4da4583762ddcb95bd 100644 (file)
@@ -486,7 +486,13 @@ void ReadyRestart_force(bool is_fake_round_start)
 
 void ReadyRestart(bool forceWarmupEnd)
 {
-       if (MUTATOR_CALLHOOK(ReadyRestart_Deny) || intermission_running || race_completing) localcmd("restart\n");
+       if (MUTATOR_CALLHOOK(ReadyRestart_Deny) || intermission_running || race_completing)
+       {
+               // 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");
 
        if(forceWarmupEnd || autocvar_g_campaign)
index 6feb8113233dd0280b964a3b7f7e0687a324b89a..9c5c86993e9da3e9fde7190dc3fc00be0655e5dd 100644 (file)
@@ -1153,7 +1153,10 @@ MUTATOR_HOOKABLE(ChatMessage, EV_ChatMessage);
     /**/
 MUTATOR_HOOKABLE(ChatMessageTo, EV_ChatMessageTo);
 
-/** return true to just restart the match, for modes that don't support readyrestart */
+/**
+ * return true to restart the match instead of restarting the server, for modes that don't support readyrestart.
+ * NOTE: ReadyRestart support is mandatory in campaign
+ */
 MUTATOR_HOOKABLE(ReadyRestart_Deny, EV_NO_ARGS);
 
 /** called when a fusion reactor is validating its target */