Xonotic
intermission.qh File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

float DoNextMapOverride (float reinit)
 
void FixIntermissionClient (entity e)
 
string GetGametype ()
 
string GetMapname ()
 
string GetNextMap ()
 
string GotoMap (string m)
 
void GotoNextMap (float reinit)
 
void IntermissionThink (entity this)
 
void Map_Goto (float reinit)
 
void Map_Goto_SetStr (string nextmapname)
 
bool Map_IsRecent (string m)
 
void Map_MarkAsRecent (string m)
 
void ShuffleMaplist ()
 

Variables

bool alreadychangedlevel
 
bool autocvar_lastlevel
 
string autocvar_nextmap
 
bool autocvar_samelevel
 
bool autocvar_sv_autoscreenshot
 
string autocvar_sv_intermission_cdtrack
 
float intermission_exittime
 
bool intermission_running
 

Function Documentation

◆ DoNextMapOverride()

float DoNextMapOverride ( float  reinit)

Definition at line 312 of file intermission.qc.

References alreadychangedlevel, autocvar_g_campaign, autocvar_lastlevel, autocvar_nextmap, autocvar_quit_and_redirect, autocvar_quit_when_empty, autocvar_samelevel, autocvar_sv_vote_gametype, CampaignPostIntermission(), currentbots, cvar_set(), cvar_settemp_restore(), gametypevote, GameTypeVote_MapInfo_FixName(), localcmd, Map_Goto(), Map_Goto_SetStr(), MapInfo_CheckMap(), player_count, redirection_target, and strzone().

Referenced by GotoFirstMap(), GotoMap(), and MapVote_Think().

313 {
315  {
317  alreadychangedlevel = true;
318  return true;
319  }
321  {
323  {
324  localcmd("quit\n");
325  alreadychangedlevel = true;
326  return true;
327  }
328  }
330  {
332  alreadychangedlevel = true;
333  return true;
334  }
335  if (!reinit && autocvar_samelevel) // if samelevel is set, stay on same level
336  {
337  localcmd("restart\n");
338  alreadychangedlevel = true;
339  return true;
340  }
341  if(autocvar_nextmap != "")
342  {
343  string m;
345  cvar_set("nextmap",m);
346 
347  if(!m || gametypevote)
348  return false;
350  {
351  Map_Goto_SetStr(m);
352  return false;
353  }
354 
355  if(MapInfo_CheckMap(m))
356  {
357  Map_Goto_SetStr(m);
358  Map_Goto(reinit);
359  alreadychangedlevel = true;
360  return true;
361  }
362  }
363  if(!reinit && autocvar_lastlevel)
364  {
366  localcmd("set lastlevel 0\ntogglemenu 1\n");
367  alreadychangedlevel = true;
368  return true;
369  }
370  return false;
371 }
bool autocvar_lastlevel
Definition: intermission.qh:3
int player_count
Definition: api.qh:103
bool autocvar_quit_when_empty
Definition: world.qh:14
void Map_Goto_SetStr(string nextmapname)
string GameTypeVote_MapInfo_FixName(string m)
Definition: mapvoting.qc:95
string autocvar_nextmap
Definition: intermission.qh:4
int currentbots
Definition: api.qh:104
string redirection_target
Definition: world.qh:61
void Map_Goto(float reinit)
void CampaignPostIntermission()
Definition: campaign.qc:244
float MapInfo_CheckMap(string s)
Definition: mapinfo.qc:1170
float gametypevote
Definition: mapvoting.qc:40
bool alreadychangedlevel
Definition: intermission.qh:11
bool autocvar_samelevel
Definition: intermission.qh:5
bool autocvar_g_campaign
Definition: campaign.qh:6
int cvar_settemp_restore()
Definition: util.qc:736
string autocvar_quit_and_redirect
Definition: world.qh:12
bool autocvar_sv_vote_gametype
Definition: mapvoting.qh:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FixIntermissionClient()

void FixIntermissionClient ( entity  e)

Definition at line 453 of file intermission.qc.

References autocvar_sv_intermission_cdtrack, EF_NODRAW, effects, FOREACH_WORD, IS_REAL_CLIENT, MAX_WEAPONSLOTS, msg_entity, MSG_ONE, RandomSelection_AddString, RandomSelection_chosen_string, RandomSelection_Init(), RES_HEALTH, SetResourceExplicit(), stuffcmd, SVC_INTERMISSION, time, weaponentities, and WriteByte().

Referenced by IntermissionThink(), and NextLevel().

454 {
455  if(!e.autoscreenshot) // initial call
456  {
457  e.autoscreenshot = time + 0.8; // used for autoscreenshot
458  SetResourceExplicit(e, RES_HEALTH, -2342); // health in the first intermission phase
459  for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
460  {
461  .entity weaponentity = weaponentities[slot];
462  if(e.(weaponentity))
463  {
464  e.(weaponentity).effects = EF_NODRAW;
465  if (e.(weaponentity).weaponchild)
466  e.(weaponentity).weaponchild.effects = EF_NODRAW;
467  }
468  }
469  if(IS_REAL_CLIENT(e))
470  {
471  stuffcmd(e, "\nscr_printspeed 1000000\n");
474  RandomSelection_AddString(it, 1, 1);
475  });
477  {
478  stuffcmd(e, sprintf("\ncd loop %s\n", RandomSelection_chosen_string));
479  }
480  msg_entity = e;
482  }
483  }
484 }
string RandomSelection_chosen_string
Definition: random.qh:7
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
Definition: cl_resources.qc:15
ERASEABLE void RandomSelection_Init()
Definition: random.qc:4
#define RandomSelection_AddString(s, weight, priority)
Definition: random.qh:16
float effects
Definition: csprogsdefs.qc:111
#define FOREACH_WORD(words, cond, body)
Definition: iter.qh:33
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
RES_HEALTH
Definition: ent_cs.qc:126
const float EF_NODRAW
Definition: csprogsdefs.qc:305
entity msg_entity
Definition: progsdefs.qc:63
const int MAX_WEAPONSLOTS
Definition: weapon.qh:13
#define stuffcmd(cl,...)
Definition: progsdefs.qh:23
entity weaponentities[MAX_WEAPONSLOTS]
Definition: weapon.qh:14
float SVC_INTERMISSION
Definition: progsdefs.qc:340
float time
Definition: csprogsdefs.qc:16
string autocvar_sv_intermission_cdtrack
Definition: intermission.qh:7
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetGametype()

string GetGametype ( )

Definition at line 13 of file intermission.qc.

References MapInfo_LoadedGametype, and MapInfo_Type_ToString().

Referenced by DumpStats(), readlevelcvars(), spawnfunc(), WeaponStats_ready(), WinningConditionHelper(), and write_recordmarker().

14 {
16 }
string MapInfo_Type_ToString(Gametype t)
Definition: mapinfo.qc:616
Gametype MapInfo_LoadedGametype
Definition: mapinfo.qh:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetMapname()

string GetMapname ( )

Definition at line 18 of file intermission.qc.

References mapname.

Referenced by Campaign_Invalid(), checkpoint_passed(), ctf_CaptureRecord(), ctf_Initialize(), DumpStats(), GameCommand_delrec(), GetMaplistPosition(), getrankings(), IntermissionThink(), race_deleteTime(), race_send_recordtime(), race_SendAll(), race_SendRanking(), race_SendTime(), race_setTime(), race_SpeedAwardFrame(), sandbox_Database_Load(), sandbox_Database_Save(), spawnfunc(), trigger_race_checkpoint_verify(), and WeaponStats_ready().

19 {
20  return mapname;
21 }
string mapname
Definition: csprogsdefs.qc:26
+ Here is the caller graph for this function:

◆ GetNextMap()

string GetNextMap ( )

Definition at line 284 of file intermission.qc.

References autocvar_g_maplist_selectrandom, autocvar_g_maplist_shuffle, getmapname_stored, Map_Goto_SetFloat(), Maplist_Init(), MaplistMethod_Iterate(), MaplistMethod_Random(), MaplistMethod_Repeat(), and MaplistMethod_Shuffle().

Referenced by GotoNextMap(), and MapVote_Init().

285 {
286  Maplist_Init();
287  float nextMap = -1;
288 
289  if(nextMap == -1)
292 
293  if(nextMap == -1)
295  nextMap = MaplistMethod_Random();
296 
297  if(nextMap == -1)
298  nextMap = MaplistMethod_Iterate();
299 
300  if(nextMap == -1)
301  nextMap = MaplistMethod_Repeat();
302 
303  if(nextMap >= 0)
304  {
305  Map_Goto_SetFloat(nextMap);
306  return getmapname_stored;
307  }
308 
309  return "";
310 }
float MaplistMethod_Repeat()
float MaplistMethod_Random()
void Maplist_Init()
float MaplistMethod_Shuffle(float exponent)
bool autocvar_g_maplist_selectrandom
Definition: mapvoting.qh:8
float MaplistMethod_Iterate()
float autocvar_g_maplist_shuffle
Definition: mapvoting.qh:9
void Map_Goto_SetFloat(float position)
string getmapname_stored
Definition: mapvoting.qh:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GotoMap()

string GotoMap ( string  m)

Definition at line 393 of file intermission.qc.

References alreadychangedlevel, autocvar_sv_vote_gametype, cvar_set(), DoNextMapOverride(), GameTypeVote_MapInfo_FixName(), MapInfo_CheckMap(), and mapvote_initialized.

Referenced by GameCommand_gotomap().

394 {
396  if (!m)
397  return "The map you suggested is not available on this server.";
399  if(!MapInfo_CheckMap(m))
400  return "The map you suggested does not support the current game mode.";
401  cvar_set("nextmap", m);
402  cvar_set("_endmatch", "1");
404  {
405  if(DoNextMapOverride(0))
406  return "Map switch initiated.";
407  else
408  return "Hm... no. For some reason I like THIS map more.";
409  }
410  else
411  return "Map switch will happen after scoreboard.";
412 }
string GameTypeVote_MapInfo_FixName(string m)
Definition: mapvoting.qc:95
float DoNextMapOverride(float reinit)
float MapInfo_CheckMap(string s)
Definition: mapinfo.qc:1170
bool alreadychangedlevel
Definition: intermission.qh:11
float mapvote_initialized
Definition: mapvoting.qh:39
bool autocvar_sv_vote_gametype
Definition: mapvoting.qh:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GotoNextMap()

void GotoNextMap ( float  reinit)

Definition at line 373 of file intermission.qc.

References alreadychangedlevel, error(), GetNextMap(), and Map_Goto().

Referenced by GotoFirstMap(), MapVote_Think(), and SelectSpawnPoint().

374 {
375  //string nextmap;
376  //float n, nummaps;
377  //string s;
379  return;
380  alreadychangedlevel = true;
381 
382  string nextMap = GetNextMap();
383  if(nextMap == "")
384  error("Everything is broken - cannot find a next map. Please report this to the developers.");
385  Map_Goto(reinit);
386 }
string GetNextMap()
void Map_Goto(float reinit)
bool alreadychangedlevel
Definition: intermission.qh:11
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IntermissionThink()

void IntermissionThink ( entity  this)

Definition at line 423 of file intermission.qc.

References autocvar_sv_autoscreenshot, autoscreenshot, CS_CVAR, FixIntermissionClient(), GetMapname(), intermission_exittime, IS_REAL_CLIENT, mapvote_initialized, MapVote_Start(), PHYS_INPUT_BUTTON_ATCK, PHYS_INPUT_BUTTON_ATCK2, PHYS_INPUT_BUTTON_HOOK, PHYS_INPUT_BUTTON_JUMP, PHYS_INPUT_BUTTON_USE, strftime_s(), stuffcmd, and time.

Referenced by PlayerPreThink(), and PlayerThink().

424 {
425  FixIntermissionClient(this);
426 
427  float server_screenshot = (autocvar_sv_autoscreenshot && CS_CVAR(this).cvar_cl_autoscreenshot);
428  float client_screenshot = (CS_CVAR(this).cvar_cl_autoscreenshot == 2);
429 
430  if( (server_screenshot || client_screenshot)
431  && ((this.autoscreenshot > 0) && (time > this.autoscreenshot)) )
432  {
433  this.autoscreenshot = -1;
434  if(IS_REAL_CLIENT(this))
435  {
436  string num = strftime_s(); // strftime(false, "%s") isn't reliable, see strftime_s description
437  stuffcmd(this, sprintf("\nscreenshot screenshots/autoscreenshot/%s-%s.jpg; "
438  "echo \"^5A screenshot has been taken at request of the server.\"\n", GetMapname(), num));
439  }
440  return;
441  }
442 
444  return;
445 
448  return;
449 
450  MapVote_Start();
451 }
#define PHYS_INPUT_BUTTON_ATCK2(s)
Definition: player.qh:148
#define PHYS_INPUT_BUTTON_JUMP(s)
Definition: player.qh:147
float intermission_exittime
Definition: intermission.qh:10
#define PHYS_INPUT_BUTTON_HOOK(s)
Definition: player.qh:151
string GetMapname()
Definition: intermission.qc:18
#define CS_CVAR(this)
Definition: state.qh:51
#define IS_REAL_CLIENT(v)
Definition: utils.qh:17
#define PHYS_INPUT_BUTTON_USE(s)
Definition: player.qh:154
bool autocvar_sv_autoscreenshot
Definition: intermission.qh:6
#define PHYS_INPUT_BUTTON_ATCK(s)
Definition: player.qh:146
#define stuffcmd(cl,...)
Definition: progsdefs.qh:23
void FixIntermissionClient(entity e)
void MapVote_Start()
Definition: mapvoting.qc:632
float mapvote_initialized
Definition: mapvoting.qh:39
float time
Definition: csprogsdefs.qc:16
ERASEABLE string strftime_s()
Definition: string.qh:91
float autoscreenshot
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Map_Goto()

void Map_Goto ( float  reinit)

Definition at line 159 of file intermission.qc.

References getmapname_stored, and MapInfo_LoadMap().

Referenced by DoNextMapOverride(), GotoNextMap(), and MapVote_Finished().

160 {
162 }
void MapInfo_LoadMap(string s, float reinit)
Definition: mapinfo.qc:1183
string getmapname_stored
Definition: mapvoting.qh:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Map_Goto_SetStr()

void Map_Goto_SetStr ( string  nextmapname)

Definition at line 143 of file intermission.qc.

References getmapname_stored, strunzone(), and strzone().

Referenced by DoNextMapOverride(), Map_Goto_SetFloat(), and MapVote_Finished().

144 {
145  if(getmapname_stored != "")
147  if(nextmapname == "")
148  getmapname_stored = "";
149  else
150  getmapname_stored = strzone(nextmapname);
151 }
string getmapname_stored
Definition: mapvoting.qh:38
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Map_IsRecent()

bool Map_IsRecent ( string  m)

Definition at line 113 of file intermission.qc.

References autocvar_g_maplist_mostrecent, and strhasword.

Referenced by Map_Check(), MapVote_Suggest(), and ValidateMap().

114 {
116 }
string autocvar_g_maplist_mostrecent
Definition: mapvoting.qh:6
#define strhasword(s, w)
Definition: string.qh:352
+ Here is the caller graph for this function:

◆ Map_MarkAsRecent()

void Map_MarkAsRecent ( string  m)

Definition at line 108 of file intermission.qc.

References autocvar_g_maplist_mostrecent, autocvar_g_maplist_mostrecent_count, cons(), cvar_set(), max(), and strwords().

Referenced by spawnfunc().

109 {
111 }
string autocvar_g_maplist_mostrecent
Definition: mapvoting.qh:6
ERASEABLE string strwords(string s, int w)
Definition: string.qh:343
ERASEABLE string cons(string a, string b)
Definition: string.qh:257
int autocvar_g_maplist_mostrecent_count
Definition: mapvoting.qh:7
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ShuffleMaplist()

void ShuffleMaplist ( )

Definition at line 388 of file intermission.qc.

References autocvar_g_maplist, cvar_set(), and shufflewords().

Referenced by GameTypeVote_SetGametype(), GotoFirstMap(), Maplist_Init(), and MapVote_Init().

389 {
391 }
ERASEABLE string shufflewords(string str)
Definition: string.qh:307
#define autocvar_g_maplist
Definition: mapvoting.qh:3
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ alreadychangedlevel

bool alreadychangedlevel

◆ autocvar_lastlevel

bool autocvar_lastlevel

Definition at line 3 of file intermission.qh.

Referenced by DoNextMapOverride().

◆ autocvar_nextmap

◆ autocvar_samelevel

bool autocvar_samelevel

Definition at line 5 of file intermission.qh.

Referenced by DoNextMapOverride().

◆ autocvar_sv_autoscreenshot

bool autocvar_sv_autoscreenshot

Definition at line 6 of file intermission.qh.

Referenced by IntermissionThink().

◆ autocvar_sv_intermission_cdtrack

string autocvar_sv_intermission_cdtrack

Definition at line 7 of file intermission.qh.

Referenced by FixIntermissionClient().

◆ intermission_exittime

float intermission_exittime

Definition at line 10 of file intermission.qh.

Referenced by IntermissionThink(), and NextLevel().

◆ intermission_running