]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Convert g_warmup to an autocvar and related refactoring
authorbones_was_here <bones_was_here@xonotic.au>
Tue, 11 Oct 2022 14:19:15 +0000 (00:19 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Fri, 6 Jan 2023 07:16:05 +0000 (17:16 +1000)
qcsrc/server/command/vote.qc
qcsrc/server/world.qc
qcsrc/server/world.qh

index b360f34d3f325133ee88629f26110d54a5f508d8..03fbb019f379a6c2492a55146dd93f24cbeb6ef5 100644 (file)
@@ -498,7 +498,7 @@ void ReadyRestart(bool forceWarmupEnd)
        if(forceWarmupEnd || autocvar_g_campaign)
                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
+               warmup_stage = autocvar_g_warmup; // go into warmup if it's enabled, otherwise restart into match stage
 
        ReadyRestart_force(false);
 }
index 47198b7d98fd8c790ff81084038625bb4f0a8fea..c4acd0fdccdf5a3b8ed11af82e1edf00a6f020a6 100644 (file)
@@ -660,10 +660,9 @@ void GameplayMode_DelayedInit(entity this)
                        int u = AVAILABLE_TEAMS - d;
                        map_minplayers += (u < d && u + map_minplayers <= m) ? u : -d;
                }
-               warmup_limit = -1;
        }
        else
-               map_minplayers = 0; // don't display a minimum if it's not used
+               map_minplayers = 0; // don't display a minimum if it's not used (g_maxplayers < 0 && g_warmup >= 0)
 }
 
 void InitGameplayMode()
@@ -865,9 +864,6 @@ spawnfunc(worldspawn)
 
        GameRules_limit_fallbacks();
 
-       if(warmup_limit == 0)
-               warmup_limit = autocvar_timelimit * 60;
-
        player_count = 0;
        bot_waypoints_for_items = autocvar_g_waypoints_for_items;
        if(bot_waypoints_for_items == 1)
@@ -2106,11 +2102,21 @@ void readlevelcvars()
 
        sv_ready_restart_after_countdown = cvar("sv_ready_restart_after_countdown");
 
-       warmup_stage = cvar("g_warmup");
-       warmup_limit = cvar("g_warmup_limit");
-
        if(cvar("g_campaign"))
                warmup_stage = 0; // no warmup during campaign
+       else
+       {
+               warmup_stage = autocvar_g_warmup;
+               if (warmup_stage < 0 || warmup_stage > 1)
+                       warmup_limit = -1; // don't start until there's enough players
+               else if (warmup_stage == 1)
+               {
+                       // this code is duplicated in ReadyCount()
+                       warmup_limit = cvar("g_warmup_limit");
+                       if(warmup_limit == 0)
+                               warmup_limit = autocvar_timelimit * 60;
+               }
+       }
 
        g_pickup_respawntime_weapon = cvar("g_pickup_respawntime_weapon");
        g_pickup_respawntime_superweapon = cvar("g_pickup_respawntime_superweapon");
index 271f394adaa91c84f801a48db1856032781ca485..aab133a19a06791233cf9644a202ead0c4ebe678 100644 (file)
@@ -6,6 +6,7 @@ bool autocvar__sv_init;
 bool autocvar__endmatch;
 bool autocvar_g_use_ammunition;
 bool autocvar_g_jetpack;
+int autocvar_g_warmup;
 bool autocvar_g_warmup_allguns;
 bool autocvar_g_warmup_allow_timeout;
 #define autocvar_g_weaponarena cvar_string("g_weaponarena")