]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'terencehill/warmup_limit' into 'master'
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 23 Mar 2016 20:30:57 +0000 (20:30 +0000)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 23 Mar 2016 20:30:57 +0000 (20:30 +0000)
Warmup limit stat

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)

See merge request !295

qcsrc/client/announcer.qc
qcsrc/client/autocvars.qh
qcsrc/client/hud/panel/timer.qc
qcsrc/common/stats.qh
qcsrc/server/defs.qh
qcsrc/server/miscfunctions.qh
qcsrc/server/sv_main.qc

index 522d1729f40bac71c5b13e92d5469500aebce4e4..a7b0e47499595474c6c8e90aae4c40eb3a85887b 100644 (file)
@@ -116,63 +116,37 @@ void Announcer_Gamestart()
        previous_game_starttime = startTime;
 }
 
+#define ANNOUNCER_CHECKMINUTE(minute) MACRO_BEGIN { \
+       if(announcer_##minute##min) { \
+               if(timeleft > minute * 60) \
+                       announcer_##minute##min = false; \
+       } else { \
+               if(timeleft < minute * 60 && timeleft > minute * 60 - 1) { \
+                       announcer_##minute##min = true; \
+                       Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_##minute); \
+               } \
+       } \
+} MACRO_END
 
-// Plays the 1 minute or 5 minutes (of maptime) remaining sound, if client wants it
 void Announcer_Time()
 {
-       float timelimit = STAT(TIMELIMIT);
-       float timeleft = max(0, timelimit * 60 + STAT(GAMESTARTTIME) - time);
-       float warmup_timeleft = 0;
-
+       float timeleft;
        if(warmup_stage)
-               if(autocvar_g_warmup_limit > 0)
-                       warmup_timeleft = max(0, autocvar_g_warmup_limit + STAT(GAMESTARTTIME) - time);
-
-       // 5 minute check
-       if(autocvar_cl_announcer_maptime >= 2)
        {
-               // 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;
-               }
+               float warmup_timelimit = STAT(WARMUP_TIMELIMIT);
+               if(warmup_timelimit > 0)
+                       timeleft = max(0, warmup_timelimit - time);
                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 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);
-                               }
-                       }
-               }
+                       timeleft = 0;
        }
+       else
+               timeleft = max(0, STAT(TIMELIMIT) * 60 + STAT(GAMESTARTTIME) - time);
+
+       if(autocvar_cl_announcer_maptime >= 2)
+               ANNOUNCER_CHECKMINUTE(5);
 
-       // 1 minute check
        if((autocvar_cl_announcer_maptime == 1) || (autocvar_cl_announcer_maptime == 3))
-       {
-               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;
-               }
-               else if(((!warmup_stage || autocvar_g_warmup_limit == 0) && timelimit > 0 && timeleft < 60)
-                       || (warmup_stage && autocvar_g_warmup_limit > 0 && warmup_timeleft < 60))
-               {
-                       // if we're in warmup mode, check whether there's a warmup timelimit
-                       if(!(autocvar_g_warmup_limit == -1 && warmup_stage))
-                       {
-                               announcer_1min = true;
-                               Local_Notification(MSG_ANNCE, ANNCE_REMAINING_MIN_1);
-                       }
-               }
-       }
+               ANNOUNCER_CHECKMINUTE(1);
 }
 
 void Announcer()
index 4b2571135ddd19481172e867e56e865608f7518d..ac02e4c1d00c67ac79946ba435d60251adbc3719 100644 (file)
@@ -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;
index dc40368179d36f6e235175b786d26c8958593cb9..b61f3c4c177ff2b8bafa7d280167dac7b898548d 100644 (file)
@@ -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);
index a3cb49ed2c71d3b513276ab7e6e64a34941fcaf6..e9828c69ee4329575a11715eff10594efdc8c069 100644 (file)
@@ -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
index 843eeb99e16e99dc85b9105d6c7cbf71ee5dfb7c..65447c7d635bfd0e3472199faed7df509bb2897f 100644 (file)
@@ -1,5 +1,6 @@
 #pragma once
 
+float warmup_limit;
 #include <common/weapons/all.qh>
 #include <common/stats.qh>
 
@@ -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;
index 4d4bf4a616967dc0c3a8549f160fa09b046c4af4..d828d70f900257421daefaa973ceef1581b76b47 100644 (file)
@@ -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");
 
index cf090833a5ff61c165eb160007f3070bb038d2e0..792885070ebe329e9ec2a59d7ac2505fb1558285 100644 (file)
@@ -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;