]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud/panel/timer.qc
Merge branch 'master' into z411/bai-server
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / timer.qc
index 8679742b49a4f46e4482d163fd9fc802da9fea28..a9512a42fd73be39fbc9f613d09d26c84f3fc698 100644 (file)
@@ -4,6 +4,8 @@
 #include <client/view.qh>
 
 // Timer (#5)
+float last_timeleft;
+int autocvar_cl_timer_countdown = 3; // 0 = disabled, 1 = always on, 2 = only spec, 3 = as dictated by server
 
 void HUD_Timer_Export(int fh)
 {
@@ -37,17 +39,32 @@ void HUD_Timer()
        }
 
        string timer_sub = "";
-       bool game_timeout;
        float timelimit, timeleft, minutesLeft, overtimes, timeout_last;
 
        timelimit = STAT(TIMELIMIT);
        overtimes = STAT(OVERTIMESADDED);
-       game_timeout = STAT(GAME_TIMEOUT);
        timeout_last = STAT(TIMEOUT_LAST);
 
        timeleft = max(0, timelimit * 60 + STAT(GAMESTARTTIME) - time);
+       timeleft = min(timeleft, timelimit * 60);
        timeleft = ceil(timeleft);
 
+       // countdown sound
+       // if 3 use server dictated option, otherwise the client's
+       int countdown_type;
+       if(autocvar_cl_timer_countdown == 3)
+               countdown_type = sv_timer_countdown;
+       else
+               countdown_type = autocvar_cl_timer_countdown;
+       
+       if(countdown_type && !warmup_stage && timeleft > 0 && timeleft != last_timeleft && timeleft <= 10)
+       {
+               if(countdown_type == 1 || (countdown_type == 2 && spectatee_status))
+                       sound(NULL, CH_INFO, SND_ENDCOUNT, VOL_BASE, ATTN_NONE);
+               
+               last_timeleft = timeleft;
+       }
+
        minutesLeft = floor(timeleft / 60);
 
        float warmup_timeleft = 0;
@@ -73,7 +90,7 @@ void HUD_Timer()
                timer = max(0, floor(intermission_time - STAT(GAMESTARTTIME)));
                timer_sub = "Intermission";
        //} else if (autocvar_hud_panel_timer_increment || (!warmup_stage && timelimit == 0) || (warmup_stage && warmup_timeleft <= 0)) {
-       } else if (game_timeout) {
+       } else if (timeout_last) {
                if(autocvar_hud_panel_timer_increment)
                        timer = max(0, floor(timeout_last - STAT(GAMESTARTTIME)));
                else
@@ -93,12 +110,7 @@ void HUD_Timer()
                        else
                                timer = warmup_timeleft;
                } else {
-                       if (time < STAT(GAMESTARTTIME))
-                               timer = floor(timelimit * 60);
-                       //else if (overtimes > 0)
-                       //      timer = floor(time - STAT(OVERTIMESTARTTIME));
-                       else
-                               timer = timeleft;
+                       timer = timeleft;
                }
        }