From: bones_was_here Date: Tue, 11 Oct 2022 14:19:15 +0000 (+1000) Subject: Convert g_warmup to an autocvar and related refactoring X-Git-Tag: xonotic-v0.8.6~179^2~14 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7e08fc9d61c6f434a3ad35775e7f4b94464d5470;p=xonotic%2Fxonotic-data.pk3dir.git Convert g_warmup to an autocvar and related refactoring --- diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index b360f34d3..03fbb019f 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -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); } diff --git a/qcsrc/server/world.qc b/qcsrc/server/world.qc index 47198b7d9..c4acd0fdc 100644 --- a/qcsrc/server/world.qc +++ b/qcsrc/server/world.qc @@ -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"); diff --git a/qcsrc/server/world.qh b/qcsrc/server/world.qh index 271f394ad..aab133a19 100644 --- a/qcsrc/server/world.qh +++ b/qcsrc/server/world.qh @@ -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")