]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Using GAME_STOPPED to freeze the round timer
authorz411 <z411@omaera.org>
Sun, 27 Feb 2022 18:56:02 +0000 (15:56 -0300)
committerz411 <z411@omaera.org>
Sun, 27 Feb 2022 18:56:02 +0000 (15:56 -0300)
qcsrc/client/hud/panel/timer.qc
qcsrc/client/view.qc
qcsrc/client/view.qh

index e4deafca14f946d5b4ffede4cf1674ff5334dec3..1b4dc20707704691c510f0b39ace7c8e7d9d6379 100644 (file)
@@ -96,7 +96,7 @@ void HUD_Timer()
                round_timelimit = STAT(ROUND_TIMELIMIT);
 
                // Calculate round time left
-               round_timeleft = round_timelimit + STAT(ROUNDSTARTTIME) - time;
+               round_timeleft = round_timelimit + STAT(ROUNDSTARTTIME) - (game_stopped_time ? game_stopped_time : time);
                if (!autocvar_hud_panel_timer_unbound)
                        round_timeleft = bound(0, round_timeleft, round_timelimit);
                round_timeleft = ceil(round_timeleft);
@@ -109,7 +109,7 @@ void HUD_Timer()
                if (intermission_time) {
                        subtimer = seconds_tostring(max(0, floor(intermission_time - STAT(ROUNDSTARTTIME))));
                } else if (autocvar_hud_panel_timer_increment || round_timelimit <= 0) {
-                       float round_time_elapsed = floor(time - STAT(ROUNDSTARTTIME));
+                       float round_time_elapsed = floor((game_stopped_time ? game_stopped_time : time) - STAT(ROUNDSTARTTIME));
                        if (!autocvar_hud_panel_timer_unbound)
                                round_time_elapsed = max(0, round_time_elapsed);
 
index 34ba8595f050e97c8cbc75e911ed3d25b55fb4ee..90478bb0a305ddb2b2604c26fd493183abcd4f93 100644 (file)
@@ -1639,6 +1639,11 @@ void CSQC_UpdateView(entity this, float w, float h)
        if(intermission && !intermission_time)
                intermission_time = time;
 
+       if(STAT(GAME_STOPPED) && !game_stopped_time)
+               game_stopped_time = time;
+       else if(game_stopped_time && !STAT(GAME_STOPPED))
+               game_stopped_time = 0;
+
        if(intermission && !isdemo() && !(calledhooks & HOOK_END))
        {
                if(calledhooks & HOOK_START)
index 0abcb13fe8d0a7e78708fe478711ff46f662db23..45959383bdf38c893dc30abad243237c01629e79 100644 (file)
@@ -125,3 +125,4 @@ float blurtest_time0, blurtest_time1, blurtest_radius, blurtest_power;
 #endif
 
 float intermission_time;
+float game_stopped_time;