Xonotic
announcer.qc File Reference
+ Include dependency graph for announcer.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ANNOUNCER_CHECKMINUTE(minute)
 

Functions

void Announcer ()
 
void Announcer_Countdown (entity this)
 
void Announcer_Gamestart ()
 
void Announcer_Time ()
 
string AnnouncerOption ()
 

Variables

bool announcer_1min
 
bool announcer_5min
 
entity announcer_countdown
 
float previous_game_starttime
 Checks whether the server initiated a map restart (stat_game_starttime changed) More...
 

Macro Definition Documentation

◆ ANNOUNCER_CHECKMINUTE

#define ANNOUNCER_CHECKMINUTE (   minute)
Value:
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
if(IS_DEAD(this))
Definition: impulse.qc:92

Definition at line 114 of file announcer.qc.

Referenced by Announcer_Time().

Function Documentation

◆ Announcer()

void Announcer ( )

Definition at line 166 of file announcer.qc.

References Announcer_Gamestart(), and Announcer_Time().

Referenced by CSQC_UpdateView().

167 {
169  Announcer_Time();
170 }
void Announcer_Time()
Definition: announcer.qc:126
void Announcer_Gamestart()
Definition: announcer.qc:73
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Announcer_Countdown()

void Announcer_Countdown ( entity  this)

Definition at line 20 of file announcer.qc.

References announcer_countdown, floor(), Local_Notification(), nextthink, NULL, starttime, and time.

Referenced by Announcer_Gamestart().

21 {
22  float starttime = STAT(GAMESTARTTIME);
23  float roundstarttime = STAT(ROUNDSTARTTIME);
24  if(roundstarttime == -1)
25  {
26  Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_ROUNDSTOP);
27  delete(this);
29  return;
30  }
31 
32  bool inround = (roundstarttime && time >= starttime);
33  float countdown = (inround ? roundstarttime - time : starttime - time);
34  float countdown_rounded = floor(0.5 + countdown);
35 
36  if(countdown <= 0) // countdown has finished, starttime is now
37  {
38  Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_BEGIN);
39  Local_Notification(MSG_MULTI, MULTI_COUNTDOWN_BEGIN);
40  delete(this);
42  return;
43  }
44  else // countdown is still going
45  {
46  if(inround)
47  {
48  Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_ROUNDSTART, countdown_rounded);
49  Notification annce_num = Announcer_PickNumber(CNT_ROUNDSTART, countdown_rounded);
50  if(annce_num != NULL)
51  Local_Notification(MSG_ANNCE, annce_num);
52  this.nextthink = (roundstarttime - (countdown - 1));
53  }
54  else
55  {
56  Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_GAMESTART, countdown_rounded);
57  Notification annce_num = Announcer_PickNumber(CNT_GAMESTART, countdown_rounded);
58  if(!roundstarttime && annce_num != NULL) // Don't announce game start in round based modes
59  Local_Notification(MSG_ANNCE, annce_num);
60  this.nextthink = (starttime - (countdown - 1));
61  }
62  }
63 }
entity announcer_countdown
Definition: announcer.qc:18
#define NULL
Definition: post.qh:17
float nextthink
Definition: csprogsdefs.qc:121
entity Notification
always last
Definition: all.qh:82
void Local_Notification(MSG net_type, Notification net_name,...count)
Definition: all.qc:1185
float time
Definition: csprogsdefs.qc:16
float starttime
Definition: strafehud.qc:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Announcer_Gamestart()

void Announcer_Gamestart ( )

Definition at line 73 of file announcer.qc.

References announcer_countdown, Announcer_Countdown(), centerprint_Kill(), floor(), intermission, Local_Notification(), NULL, ORDINAL, previous_game_starttime, setthink, and time.

Referenced by Announcer().

74 {
75  float startTime = STAT(GAMESTARTTIME);
76  float roundstarttime = STAT(ROUNDSTARTTIME);
77  if(roundstarttime > startTime)
78  startTime = roundstarttime;
79  if(intermission)
80  {
82  {
83  centerprint_Kill(ORDINAL(CPID_ROUND));
85  {
86  delete(announcer_countdown);
88  }
89  }
90  return;
91  }
92 
93  if(previous_game_starttime != startTime)
94  {
95  if(time < startTime)
96  {
98  {
101  }
102 
103  if(time + 5.0 < startTime) // if connecting to server while restart was active don't always play prepareforbattle
104  if(time > announcer_countdown.nextthink) // don't play it again if countdown was already going
105  Local_Notification(MSG_ANNCE, ANNCE_PREPARE);
106 
107  announcer_countdown.nextthink = startTime - floor(startTime - time + 0.5); //synchronize nextthink to startTime
108  }
109  }
110 
111  previous_game_starttime = startTime;
112 }
void centerprint_Kill(int id)
Definition: centerprint.qc:126
#define ORDINAL(it)
Definition: enumclass.qh:25
entity announcer_countdown
Definition: announcer.qc:18
float intermission
Definition: csprogsdefs.qc:148
float previous_game_starttime
Checks whether the server initiated a map restart (stat_game_starttime changed)
Definition: announcer.qc:72
#define NULL
Definition: post.qh:17
void Announcer_Countdown(entity this)
Definition: announcer.qc:20
#define setthink(e, f)
void Local_Notification(MSG net_type, Notification net_name,...count)
Definition: all.qc:1185
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Announcer_Time()

void Announcer_Time ( )

Definition at line 126 of file announcer.qc.

References announcer_1min, announcer_5min, ANNOUNCER_CHECKMINUTE, autocvar_cl_announcer_maptime, intermission, max(), starttime, time, and warmup_stage.

Referenced by Announcer().

127 {
128  static bool warmup_stage_prev;
129 
130  if(intermission)
131  return;
132 
133  if (warmup_stage != warmup_stage_prev)
134  {
135  announcer_5min = announcer_1min = false;
136  warmup_stage_prev = warmup_stage;
137  return;
138  }
139 
140  float starttime = STAT(GAMESTARTTIME);
141  if(time < starttime)
142  {
143  announcer_5min = announcer_1min = false;
144  return;
145  }
146 
147  float timeleft;
148  if(warmup_stage)
149  {
150  float warmup_timelimit = STAT(WARMUP_TIMELIMIT);
151  if(warmup_timelimit > 0)
152  timeleft = max(0, warmup_timelimit - time);
153  else
154  timeleft = 0;
155  }
156  else
157  timeleft = max(0, STAT(TIMELIMIT) * 60 + starttime - time);
158 
161 
164 }
float intermission
Definition: csprogsdefs.qc:148
bool warmup_stage
Definition: main.qh:103
bool announcer_1min
Definition: announcer.qc:8
bool announcer_5min
Definition: announcer.qc:9
float autocvar_cl_announcer_maptime
Definition: announcer.qh:5
float time
Definition: csprogsdefs.qc:16
float starttime
Definition: strafehud.qc:38
#define ANNOUNCER_CHECKMINUTE(minute)
Definition: announcer.qc:114
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AnnouncerOption()

string AnnouncerOption ( )

Definition at line 10 of file announcer.qc.

References AnnouncerOption(), autocvar_cl_announcer, M_ARGV, and MUTATOR_CALLHOOK.

Referenced by AnnouncerOption().

11 {
12  string ret = autocvar_cl_announcer;
14  ret = M_ARGV(0, string);
15  return ret;
16 }
#define M_ARGV(x, type)
Definition: events.qh:17
string autocvar_cl_announcer
Definition: announcer.qh:3
#define MUTATOR_CALLHOOK(id,...)
Definition: base.qh:140
string AnnouncerOption()
Definition: announcer.qc:10
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ announcer_1min

bool announcer_1min

Definition at line 8 of file announcer.qc.

Referenced by Announcer_Time().

◆ announcer_5min

bool announcer_5min

Definition at line 9 of file announcer.qc.

Referenced by Announcer_Time().

◆ announcer_countdown

entity announcer_countdown

Definition at line 18 of file announcer.qc.

Referenced by Announcer_Countdown(), and Announcer_Gamestart().

◆ previous_game_starttime

float previous_game_starttime

Checks whether the server initiated a map restart (stat_game_starttime changed)

TODO: Use a better solution where a common shared entitiy is used that contains timelimit, fraglimit and game_starttime! Requires engine changes (remove STAT_TIMELIMIT and STAT_FRAGLIMIT to be auto-sent)

Definition at line 72 of file announcer.qc.

Referenced by Announcer_Gamestart().