]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Soft reset: Fix warmup limit and repeatable restart
authorz411 <z411@omaera.org>
Thu, 18 Nov 2021 15:40:12 +0000 (12:40 -0300)
committerz411 <z411@omaera.org>
Thu, 18 Nov 2021 15:40:12 +0000 (12:40 -0300)
qcsrc/client/hud/panel/timer.qc
qcsrc/server/command/sv_cmd.qc
qcsrc/server/command/vote.qc
qcsrc/server/main.qc
qcsrc/server/world.qc
qcsrc/server/world.qh

index 0cdfefa7899af591aaf4f3ef3c567152d02e41ac..f1c4dcfe807b89e456ba230abc91e59bc7b276bf 100644 (file)
@@ -51,7 +51,7 @@ void HUD_Timer()
        {
                float warmup_timelimit = STAT(WARMUP_TIMELIMIT);
                if(warmup_timelimit > 0)
-                       warmup_timeleft = max(0, warmup_timelimit - time);
+                       warmup_timeleft = max(0, warmup_timelimit - time + STAT(GAMESTARTTIME));
                else if(warmup_timelimit == 0)
                        warmup_timeleft = timeleft;
                warmup_timeleft = ceil(warmup_timeleft);
index e1070ad9ad51790792f95479bb376b8abb91d6ca..3e4195e509491e8cf41b9fcfb8850d63acab9228 100644 (file)
@@ -163,8 +163,7 @@ void GameCommand_allready(int request)
                {
                        if(warmup_stage)
                        {
-                               warmup_stage = 0;
-                               ReadyRestart();
+                               ReadyRestart(true);
                        }
                        else
                                LOG_INFO("Not in warmup.");
@@ -1313,8 +1312,7 @@ void GameCommand_reset(int request)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       warmup_stage = cvar("g_warmup");
-                       ReadyRestart();
+                       ReadyRestart(false);
                        return;
                }
 
index 6276d2e3c93f3e97575b4551ff719817696cfbe1..ec8011a8fc236f99069de611cf55473e271b364b 100644 (file)
@@ -437,10 +437,15 @@ void ReadyRestart_force()
                cvar_set("timelimit", ftos(autocvar_timelimit - (checkrules_overtimesadded * autocvar_timelimit_overtime)));
        checkrules_suddendeathend = checkrules_overtimesadded = checkrules_suddendeathwarning = 0;
        
-       if(!warmup_stage)
+       if(warmup_stage) {
+               // Warmup: No countdown in warmup
+               game_starttime = time;
+               readyrestart_happened = false;
+       } else {
+               // Go into match mode
+               readyrestart_happened = true;
                game_starttime = time + RESTART_COUNTDOWN;
-       else
-               game_starttime = time; // No countdown in warmup
+       }
 
        // clear player attributes
        FOREACH_CLIENT(IS_PLAYER(it), {
@@ -483,7 +488,7 @@ void ReadyRestart_force()
        if (autocvar_sv_eventlog) GameLogEcho(":restart");
 }
 
-void ReadyRestart()
+void ReadyRestart(bool endWarmup)
 {
        if (MUTATOR_CALLHOOK(ReadyRestart_Deny) || intermission_running || race_completing) localcmd("restart\n");
        else localcmd("\nsv_hook_readyrestart\n");
@@ -491,6 +496,12 @@ void ReadyRestart()
        // Reset ALL scores, but only do that at the beginning of the countdown if sv_ready_restart_after_countdown is off!
        // Otherwise scores could be manipulated during the countdown.
        if (!sv_ready_restart_after_countdown) Score_ClearAll();
+
+       if(endWarmup)
+               warmup_stage = 0; // forcefully end warmup and go to match stage
+       else
+               warmup_stage = cvar("g_warmup"); // go into warmup if it's enabled, otherwise restart into match stage anyway
+
        ReadyRestart_force();
 }
 
@@ -512,11 +523,7 @@ void ReadyCount()
        ready_needed_factor = bound(0.5, cvar("g_warmup_majority_factor"), 0.999);
        ready_needed_count = floor(t_players * ready_needed_factor) + 1;
 
-       if (readycount >= ready_needed_count)
-       {
-               warmup_stage = 0;
-               ReadyRestart();
-       }
+       if (readycount >= ready_needed_count) ReadyRestart(true);
 }
 
 
index cf91b9de4bafd7d6b250a860732702a82222f409..2b29422b8969362356b6a552106158c9b881d0e7 100644 (file)
@@ -331,8 +331,8 @@ void StartFrame()
        CreatureFrame_All();
        CheckRules_World();
 
-       if (warmup_stage && !game_stopped && warmup_limit > 0 && time >= warmup_limit) {
-               ReadyRestart();
+       if (warmup_stage && !game_stopped && warmup_limit > 0 && time - game_starttime >= warmup_limit) {
+               ReadyRestart(true);
                return;
        }
 
index 02c059ea808c0d00ab4c3113c5fccb9e1249990a..e2f2fd32b79813d659990a9d1befa4cd653b4fee 100644 (file)
@@ -1644,7 +1644,7 @@ void CheckRules_World()
                                if(readyplayers || playerswithlaps >= 2)
                                {
                                        checkrules_suddendeathend = 0;
-                                       ReadyRestart(); // go to race
+                                       ReadyRestart(true); // go to race
                                        return;
                                }
                                else
index bdaac8c271e5ae08f79af6ba5f32e02fa8fb717c..e87edd6af58a0126a86da9908f8b893f4935ff16 100644 (file)
@@ -134,7 +134,7 @@ const int WINNING_STARTSUDDENDEATHOVERTIME = 3; // no winner, enter suddendeath
 
 float WinningCondition_Scores(float limit, float leadlimit);
 void SetWinners(.float field, float value);
-void ReadyRestart();
+void ReadyRestart(bool endWarmup);
 
 void DumpStats(float final);