]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/announcer.qc
Remove some of that useless code kids are always talking about
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / announcer.qc
index 6074bf89a4f85955818cbeb3825e04168c68d2f1..abfb070a717ef4213b80e451a01db3c9df36d713 100644 (file)
@@ -1,40 +1,36 @@
-float previous_announcement_time;
-float previous_game_starttime;
-string previous_announcement;
-
-// remaining maptime announcer sounds, true when sound was already played
 float announcer_1min;
 float announcer_5min;
-
-void Announcer_Play(string announcement)
+void Announcer_Countdown() 
 {
-       if((announcement != previous_announcement) || (time >= (previous_announcement_time + autocvar_cl_announcer_antispam)))
+       float starttime = getstatf(STAT_GAMESTARTTIME);
+       float roundstarttime = getstatf(STAT_ROUNDSTARTTIME);
+       if(roundstarttime == -1)
        {
-               sound(world, CH_INFO, strcat("announcer/", autocvar_cl_announcer, "/", announcement, ".wav"), VOL_BASEVOICE, ATTN_NONE);
-
-               if(previous_announcement) { strunzone(previous_announcement); }
-               
-               previous_announcement = strzone(announcement);
-               previous_announcement_time = time;
+               Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_ROUNDSTOP);
+               remove(self);
+               return;
        }
-}
+       if(roundstarttime >= starttime)
+               starttime = roundstarttime;
+       if(starttime <= time && roundstarttime != starttime) // game start time has passed
+               announcer_5min = announcer_1min = FALSE; // reset maptime announcers now as well
 
-void Announcer_Countdown() 
-{
-       float starttime = getstatf(STAT_GAMESTARTTIME);
        float countdown = (starttime - time);
        float countdown_rounded = floor(0.5 + countdown);
-       
+
        if(countdown <= 0) // countdown has finished, starttime is now
        {
-               Local_Notification(MSG_MULTI, MULTI_BEGIN); 
-               announcer_5min = announcer_1min = FALSE; // reset maptime announcers now as well
+               Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_BEGIN); 
+               Local_Notification(MSG_MULTI, MULTI_COUNTDOWN_BEGIN); 
                remove(self);
                return;
        }
        else // countdown is still going
        {
-               Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_GAMESTART, countdown_rounded);
+               if(roundstarttime == starttime)
+                       Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_ROUNDSTART, countdown_rounded);
+               else
+                       Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_GAMESTART, countdown_rounded);
 
                switch(countdown_rounded)
                {
@@ -54,20 +50,28 @@ void Announcer_Countdown()
  * timelimit, fraglimit and game_starttime! Requires engine changes (remove STAT_TIMELIMIT
  * and STAT_FRAGLIMIT to be auto-sent)
  */
+ float previous_game_starttime;
 void Announcer_Gamestart() 
 {
        float startTime = getstatf(STAT_GAMESTARTTIME);
-       
+       float roundstarttime = getstatf(STAT_ROUNDSTARTTIME);
+       if(roundstarttime > startTime)
+               startTime = roundstarttime;
+
        if(previous_game_starttime != startTime) 
        {
                if((time + 5.0) < startTime) // if connecting to server while restart was active don't always play prepareforbattle
                        Local_Notification(MSG_ANNCE, ANNCE_PREPARE);
-               
+
                if(time < startTime) 
                {
-                       entity e;
-                       e = spawn();
-                       e.think = Announcer_Countdown;
+                       entity e = find(world, classname, "announcer_countdown");
+                       if not(e)
+                       {
+                               e = spawn();
+                               e.classname = "announcer_countdown";
+                               e.think = Announcer_Countdown;
+                       }
                        e.nextthink = startTime - floor(startTime - time); //synchronize nextthink to startTime
                }
        }
@@ -139,8 +143,3 @@ void Announcer()
        Announcer_Gamestart();
        Announcer_Time();
 }
-
-void Announcer_Precache () 
-{
-       // NOTHING
-}