From: terencehill Date: Wed, 23 Mar 2016 15:36:44 +0000 (+0100) Subject: Add a stat for warmup limit so the hud timer can show decreasing time and announcer... X-Git-Tag: xonotic-v0.8.2~1036^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=36b51bc6eef2790a1138f70a05bc4c09cff07245;p=xonotic%2Fxonotic-data.pk3dir.git Add a stat for warmup limit so the hud timer can show decreasing time and announcer can properly announce left minutes in warmup stage (it was improperly reading the server's cvar g_warmup_limit) --- diff --git a/qcsrc/client/announcer.qc b/qcsrc/client/announcer.qc index 522d1729f..4287b7e0a 100644 --- a/qcsrc/client/announcer.qc +++ b/qcsrc/client/announcer.qc @@ -122,11 +122,15 @@ void Announcer_Time() { float timelimit = STAT(TIMELIMIT); float timeleft = max(0, timelimit * 60 + STAT(GAMESTARTTIME) - time); - float warmup_timeleft = 0; if(warmup_stage) - if(autocvar_g_warmup_limit > 0) - warmup_timeleft = max(0, autocvar_g_warmup_limit + STAT(GAMESTARTTIME) - time); + { + float warmup_timelimit = STAT(WARMUP_TIMELIMIT); + if(warmup_timelimit > 0) + timeleft = max(0, warmup_timelimit - time); + else + timeleft = 0; + } // 5 minute check if(autocvar_cl_announcer_maptime >= 2) @@ -134,21 +138,15 @@ void Announcer_Time() // make sure that after connect (and e.g. 4 minutes left) we will not get a wrong sound if(announcer_5min) { - if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timeleft > 300) - || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft > 300)) - announcer_5min = false; + if(timeleft > 300) + announcer_5min = false; } else { - if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timelimit > 0 && timeleft < 300 && timeleft > 299) - || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft < 300 && warmup_timeleft > 299)) + if(timeleft < 300 && timeleft > 299) { - //if we're in warmup mode, check whether there's a warmup timelimit - if(!(autocvar_g_warmup_limit == -1 && warmup_stage)) - { - announcer_5min = true; - Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_5); - } + announcer_5min = true; + Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_5); } } } @@ -156,17 +154,14 @@ void Announcer_Time() // 1 minute check if((autocvar_cl_announcer_maptime == 1) || (autocvar_cl_announcer_maptime == 3)) { - if (announcer_1min) + if(announcer_1min) { - if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timeleft > 60) - || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft > 60)) - announcer_1min = false; + if(timeleft > 60) + announcer_1min = false; } - else if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timelimit > 0 && timeleft < 60) - || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft < 60)) + else { - // if we're in warmup mode, check whether there's a warmup timelimit - if(!(autocvar_g_warmup_limit == -1 && warmup_stage)) + if(timeleft < 60 && timeleft > 59) { announcer_1min = true; Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_1); diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 4b2571135..ac02e4c1d 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -153,7 +153,6 @@ float autocvar_crosshair_size; int autocvar_ekg; float autocvar_fov; float autocvar_g_balance_damagepush_speedfactor; -float autocvar_g_warmup_limit; bool autocvar_hud_cursormode = true; float autocvar_hud_colorflash_alpha; bool autocvar_hud_configure_checkcollisions; diff --git a/qcsrc/client/hud/panel/timer.qc b/qcsrc/client/hud/panel/timer.qc index dc4036817..b61f3c4c1 100644 --- a/qcsrc/client/hud/panel/timer.qc +++ b/qcsrc/client/hud/panel/timer.qc @@ -31,6 +31,17 @@ void HUD_Timer() minutesLeft = floor(timeleft / 60); + float warmup_timeleft = 0; + if(warmup_stage) + { + float warmup_timelimit = STAT(WARMUP_TIMELIMIT); + if(warmup_timelimit > 0) + warmup_timeleft = max(0, warmup_timelimit - time); + else if(warmup_timelimit == 0) + warmup_timeleft = timeleft; + warmup_timeleft = ceil(warmup_timeleft); + } + vector timer_color; if(minutesLeft >= 5 || warmup_stage || timelimit == 0) //don't use red or yellow in warmup or when there is no timelimit timer_color = '1 1 1'; //white @@ -39,16 +50,19 @@ void HUD_Timer() else timer_color = '1 0 0'; //red - if (autocvar_hud_panel_timer_increment || timelimit == 0 || warmup_stage) { + if (autocvar_hud_panel_timer_increment || (!warmup_stage && timelimit == 0) || (warmup_stage && warmup_timeleft <= 0)) { if (time < STAT(GAMESTARTTIME)) { //while restart is still active, show 00:00 timer = seconds_tostring(0); } else { - elapsedTime = floor(time - STAT(GAMESTARTTIME)); //127 + elapsedTime = floor(time - STAT(GAMESTARTTIME)); timer = seconds_tostring(elapsedTime); } } else { - timer = seconds_tostring(timeleft); + if(warmup_stage) + timer = seconds_tostring(warmup_timeleft); + else + timer = seconds_tostring(timeleft); } drawstring_aspect(pos, timer, mySize, timer_color, panel_fg_alpha, DRAWFLAG_NORMAL); diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index a3cb49ed2..e9828c69e 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -273,6 +273,7 @@ REGISTER_STAT(MOVEVARS_MAXAIRSTRAFESPEED, float) REGISTER_STAT(MOVEVARS_AIRCONTROL, float) REGISTER_STAT(FRAGLIMIT, float, autocvar_fraglimit) REGISTER_STAT(TIMELIMIT, float, autocvar_timelimit) +REGISTER_STAT(WARMUP_TIMELIMIT, float, warmup_limit) #ifdef SVQC float autocvar_sv_wallfriction; #endif diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 843eeb99e..65447c7d6 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -1,5 +1,6 @@ #pragma once +float warmup_limit; #include #include @@ -8,7 +9,6 @@ // Globals float g_footsteps, g_grappling_hook, g_instagib; -float g_warmup_limit; float g_warmup_allguns; float g_warmup_allow_timeout; float warmup_stage; diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index 4d4bf4a61..d828d70f9 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -261,7 +261,9 @@ void readlevelcvars() sv_taunt = cvar("sv_taunt"); warmup_stage = cvar("g_warmup"); - g_warmup_limit = cvar("g_warmup_limit"); + warmup_limit = cvar("g_warmup_limit"); + if(warmup_limit == 0) + warmup_limit = (autocvar_timelimit > 0) ? autocvar_timelimit * 60 : autocvar_timelimit; g_warmup_allguns = cvar("g_warmup_allguns"); g_warmup_allow_timeout = cvar("g_warmup_allow_timeout"); diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index cf090833a..792885070 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -220,11 +220,7 @@ void StartFrame() CreatureFrame_All(); CheckRules_World(); - // if in warmup stage and limit for warmup is hit start match - if(warmup_stage) - if(!gameover) - if((g_warmup_limit > 0 && time >= g_warmup_limit) - || (g_warmup_limit == 0 && autocvar_timelimit != 0 && time >= autocvar_timelimit * 60)) + if(warmup_stage && !gameover && warmup_limit > 0 && time >= warmup_limit) { ReadyRestart(); return;