]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/command/common.qc
Merge branch 'master' into z411/bai-server
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / common.qc
index 5dff9f5f5b370ed6bb0424c2a76133d49eb879cf..7c30baa02687681805b9f167c9ee2bac29c84ac2 100644 (file)
@@ -213,16 +213,33 @@ void timeout_handler_think(entity this)
                                if (timeout_time == autocvar_sv_timeout_resumetime) // play a warning sound when only <sv_timeout_resumetime> seconds are left
                                        Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_PREPARE);
 
-                               this.nextthink = time + TIMEOUT_SLOWMO_VALUE;       // think again in one second
+                               //this.nextthink = time + TIMEOUT_SLOWMO_VALUE;       // think again in one second
+                               this.nextthink = time + 1;
                                timeout_time -= 1;                                  // decrease the time counter
                        }
+                       else if (timeout_time == -1)  // infinite timer
+                       {
+                               Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_TIMEOUT_ONGOING);
+                               this.nextthink = time + TIMEOUT_SLOWMO_VALUE;
+                       }
                        else  // time to end the timeout
                        {
                                Kill_Notification(NOTIF_ALL, NULL, MSG_CENTER, CPID_TIMEIN);
                                timeout_status = TIMEOUT_INACTIVE;
+                               float total_time = time - timeout_last;
 
                                // reset the slowmo value back to normal
-                               cvar_set("slowmo", ftos(orig_slowmo));
+                               // z411 TODO
+                               //cvar_set("slowmo", ftos(orig_slowmo));
+                               
+                               // Disable timeout and fix times
+                               game_timeout = false;
+                               timeout_total_time += total_time;
+                               game_starttime += total_time;
+                               if(round_handler && round_handler_GetEndTime() > 0)
+                                       round_handler.round_endtime += total_time;
+                                       
+                               LOG_INFOF("Timeout lasted %d secs", total_time);
 
                                // unlock the view for players so they can move around again
                                FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
@@ -249,7 +266,12 @@ void timeout_handler_think(entity this)
                                timeout_status = TIMEOUT_ACTIVE;
 
                                // set the slowmo value to the timeout default slowmo value
-                               cvar_set("slowmo", ftos(TIMEOUT_SLOWMO_VALUE));
+                               //cvar_set("slowmo", ftos(TIMEOUT_SLOWMO_VALUE));
+                               game_timeout = true;
+                               timeout_last = time;
+                               
+                               // play timeout sound
+                               sound(NULL, CH_INFO, SND_TIMEOUT, VOL_BASE, ATTN_NONE);
 
                                // reset all the flood variables
                                FOREACH_CLIENT(true, {
@@ -682,7 +704,7 @@ void CommonCommand_timein(int request, entity caller)
                                                {
                                                        timeout_time = autocvar_sv_timeout_resumetime;
                                                        timeout_handler.nextthink = time;  // timeout_handler has to take care of it immediately
-                                                       bprint(strcat("^1Attention: ^7", GetCallerName(caller), " resumed the game! Prepare for battle!\n"));
+                                                       bprint(strcat("\{1}^1Attention: ^7", GetCallerName(caller), " resumed the game! Prepare for battle!\n"));
                                                        return;
                                                }
 
@@ -746,7 +768,7 @@ void CommonCommand_timeout(int request, entity caller)  // DEAR GOD THIS COMMAND
                                {
                                        if (caller)   CS(caller).allowed_timeouts -= 1;
                                        // write a bprint who started the timeout (and how many they have left)
-                                       bprint(GetCallerName(caller), " ^7called a timeout", (caller ? strcat(" (", ftos(CS(caller).allowed_timeouts), " timeout(s) left)") : ""), "!\n");
+                                       bprint("\{1}", GetCallerName(caller), " ^7called a timeout", (caller ? strcat(" (", ftos(CS(caller).allowed_timeouts), " timeout(s) left)") : ""), "!\n");
 
                                        timeout_status = TIMEOUT_LEADTIME;
                                        timeout_caller = caller;
@@ -756,7 +778,7 @@ void CommonCommand_timeout(int request, entity caller)  // DEAR GOD THIS COMMAND
                                        timeout_handler = new(timeout_handler);
                                        setthink(timeout_handler, timeout_handler_think);
                                        timeout_handler.nextthink = time;  // always let the entity think asap
-
+                                       
                                        Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_TIMEOUT);
                                }
                        }