Xonotic
intermission.qc File Reference
#include "mapvoting.qh"
#include <common/mapinfo.qh>
#include <common/util.qh>
#include <server/bot/api.qh>
#include <server/bot/default/cvars.qh>
#include <server/campaign.qh>
#include <server/client.qh>
#include <server/scores_rules.qh>
#include <server/world.qh>
+ Include dependency graph for intermission.qc:
+ 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 ()
 
int GetMaplistPosition ()
 
string GetMapname ()
 
string GetNextMap ()
 
string GotoMap (string m)
 
void GotoNextMap (float reinit)
 
void IntermissionThink (entity this)
 
bool Map_Check (int position, float pass)
 
string Map_Filename (int position)
 
void Map_Goto (float reinit)
 
void Map_Goto_SetFloat (float position)
 
void Map_Goto_SetStr (string nextmapname)
 
bool Map_IsRecent (string m)
 
void Map_MarkAsRecent (string m)
 
bool MapHasRightSize (string map)
 
void Maplist_Init ()
 
float MaplistMethod_Iterate ()
 
float MaplistMethod_Random ()
 
float MaplistMethod_Repeat ()
 
float MaplistMethod_Shuffle (float exponent)
 
void ShuffleMaplist ()
 

Variables

float autoscreenshot
 
float Map_Count
 
float Map_Current
 
string Map_Current_Name
 

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:

◆ GetMaplistPosition()

int GetMaplistPosition ( )

Definition at line 27 of file intermission.qc.

References argv(), autocvar_g_maplist_index, GetMapname(), and Map_Count.

Referenced by Maplist_Init().

28 {
29  string map = GetMapname();
30  int idx = autocvar_g_maplist_index;
31 
32  if(idx >= 0)
33  {
34  if(idx < Map_Count)
35  {
36  if(map == argv(idx))
37  {
38  return idx;
39  }
40  }
41  }
42 
43  for(int pos = 0; pos < Map_Count; ++pos)
44  {
45  if(map == argv(pos))
46  return pos;
47  }
48 
49  // resume normal maplist rotation if current map is not in g_maplist
50  return idx;
51 }
string GetMapname()
Definition: intermission.qc:18
float Map_Count
Definition: intermission.qc:23
int autocvar_g_maplist_index
Definition: mapvoting.qh:5
+ 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_Check()

bool Map_Check ( int  position,
float  pass 
)

Definition at line 118 of file intermission.qc.

References argv(), LOG_DEBUG, Map_Filename(), Map_IsRecent(), MapHasRightSize(), and MapInfo_CheckMap().

Referenced by Maplist_Init(), MaplistMethod_Iterate(), MaplistMethod_Random(), MaplistMethod_Repeat(), and MaplistMethod_Shuffle().

119 {
120  string filename;
121  string map_next;
122  map_next = argv(position);
123  if(pass <= 1)
124  {
125  if(Map_IsRecent(map_next))
126  return false;
127  }
128  filename = Map_Filename(position);
129  if(MapInfo_CheckMap(map_next))
130  {
131  if(pass == 2)
132  return true;
133  if(MapHasRightSize(map_next))
134  return true;
135  return false;
136  }
137  else
138  LOG_DEBUG( "Couldn't select '", filename, "'..." );
139 
140  return false;
141 }
string Map_Filename(int position)
bool MapHasRightSize(string map)
Definition: intermission.qc:53
float MapInfo_CheckMap(string s)
Definition: mapinfo.qc:1170
bool Map_IsRecent(string m)
#define pass(name, colormin, colormax)
#define LOG_DEBUG(...)
Definition: log.qh:85
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Map_Filename()

string Map_Filename ( int  position)

Definition at line 103 of file intermission.qc.

References argv(), and strcat().

Referenced by Map_Check().

104 {
105  return strcat("maps/", argv(position), ".bsp");
106 }
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
+ 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_SetFloat()

void Map_Goto_SetFloat ( float  position)

Definition at line 153 of file intermission.qc.

References argv(), cvar_set(), ftos(), and Map_Goto_SetStr().

Referenced by GetNextMap().

154 {
155  cvar_set("g_maplist_index", ftos(position));
156  Map_Goto_SetStr(argv(position));
157 }
void Map_Goto_SetStr(string nextmapname)
+ 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:

◆ MapHasRightSize()

bool MapHasRightSize ( string  map)

Definition at line 53 of file intermission.qc.

References autocvar_bot_number, autocvar_g_maplist_check_waypoints, autocvar_g_maplist_ignore_sizes, autocvar_g_maplist_sizes_count_bots, autocvar_g_maplist_sizes_count_maxplayers, autocvar_minplayers, autocvar_minplayers_per_team, AvailableTeams(), currentbots, fclose(), fexists(), fgets(), FILE_READ, floor(), fopen(), GetPlayerLimit(), LOG_TRACE, max(), min(), player_count, stoi, strcat(), and teamplay.

Referenced by Map_Check().

54 {
55  int minplayers = max(0, floor(autocvar_minplayers));
56  if (teamplay)
59  && (currentbots || autocvar_bot_number || player_count < minplayers))
60  {
61  string checkwp_msg = strcat("checkwp ", map);
62  if(!fexists(strcat("maps/", map, ".waypoints")))
63  {
64  LOG_TRACE(checkwp_msg, ": no waypoints");
65  return false;
66  }
67  LOG_TRACE(checkwp_msg, ": has waypoints");
68  }
69 
71  return true;
72 
73  // open map size restriction file
74  string opensize_msg = strcat("opensize ", map);
75  float fh = fopen(strcat("maps/", map, ".sizes"), FILE_READ);
76  int player_limit = ((autocvar_g_maplist_sizes_count_maxplayers) ? GetPlayerLimit() : 0);
77  int pcount = ((player_limit > 0) ? min(player_count, player_limit) : player_count); // bind it to the player limit so that forced spectators don't influence the limits
79  pcount -= currentbots;
80  if(fh >= 0)
81  {
82  opensize_msg = strcat(opensize_msg, ": ok, ");
83  int mapmin = stoi(fgets(fh));
84  int mapmax = stoi(fgets(fh));
85  fclose(fh);
86  if(pcount < mapmin)
87  {
88  LOG_TRACE(opensize_msg, "not enough");
89  return false;
90  }
91  if(mapmax && pcount > mapmax)
92  {
93  LOG_TRACE(opensize_msg, "too many");
94  return false;
95  }
96  LOG_TRACE(opensize_msg, "right size");
97  return true;
98  }
99  LOG_TRACE(opensize_msg, ": not found");
100  return true;
101 }
int player_count
Definition: api.qh:103
int GetPlayerLimit()
Definition: client.qc:1990
const float FILE_READ
Definition: csprogsdefs.qc:231
int autocvar_minplayers
Definition: cvars.qh:71
int currentbots
Definition: api.qh:104
#define stoi(s)
Definition: int.qh:4
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
int autocvar_bot_number
Definition: cvars.qh:67
int AvailableTeams()
Definition: scores_rules.qc:22
float teamplay
Definition: progsdefs.qc:31
bool autocvar_g_maplist_check_waypoints
Definition: mapvoting.qh:4
#define LOG_TRACE(...)
Definition: log.qh:81
int autocvar_minplayers_per_team
Definition: cvars.qh:72
bool autocvar_g_maplist_ignore_sizes
Definition: mapvoting.qh:18
bool autocvar_g_maplist_sizes_count_bots
Definition: mapvoting.qh:20
ERASEABLE bool fexists(string f)
Definition: file.qh:4
bool autocvar_g_maplist_sizes_count_maxplayers
Definition: mapvoting.qh:19
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Maplist_Init()

void Maplist_Init ( )

Definition at line 252 of file intermission.qc.

References argv(), autocvar_g_maplist, autocvar_g_maplist_shuffle, bound(), bprint(), cvar_set(), error(), GetMaplistPosition(), localcmd, Map_Check(), Map_Count, Map_Current, Map_Current_Name, MAPINFO_FLAG_NOAUTOMAPLIST, MapInfo_ForbiddenFlags(), MapInfo_ListAllAllowedMaps(), MapInfo_RequiredFlags(), server_is_dedicated, ShuffleMaplist(), strcpy, and tokenizebyseparator.

Referenced by GetNextMap().

253 {
254  float i = Map_Count = 0;
255  if(autocvar_g_maplist != "")
256  {
258  for (i = 0; i < Map_Count; ++i)
259  {
260  if (Map_Check(i, 2))
261  break;
262  }
263  }
264 
265  if (i == Map_Count)
266  {
267  bprint( "Maplist contains no usable maps! Resetting it to default map list.\n" );
270  ShuffleMaplist();
272  localcmd("\nmenu_cmd sync\n");
273  Map_Count = tokenizebyseparator(autocvar_g_maplist, " ");
274  }
275  if(Map_Count == 0)
276  error("empty maplist, cannot select a new map");
277  Map_Current = bound(0, GetMaplistPosition(), Map_Count - 1);
278 
279  strcpy(Map_Current_Name, argv(Map_Current)); // will be automatically freed on exit thanks to DP
280  // this may or may not be correct, but who cares, in the worst case a map
281  // isn't chosen in the first pass that should have been
282 }
int MapInfo_RequiredFlags()
Definition: mapinfo.qc:1339
string MapInfo_ListAllAllowedMaps(float pRequiredFlags, float pForbiddenFlags)
Definition: mapinfo.qc:1216
int MapInfo_ForbiddenFlags()
Definition: mapinfo.qc:1324
float Map_Count
Definition: intermission.qc:23
#define strcpy(this, s)
Definition: string.qh:49
float Map_Current
Definition: intermission.qc:23
bool Map_Check(int position, float pass)
#define autocvar_g_maplist
Definition: mapvoting.qh:3
void ShuffleMaplist()
#define tokenizebyseparator
Definition: dpextensions.qh:21
float autocvar_g_maplist_shuffle
Definition: mapvoting.qh:9
int GetMaplistPosition()
Definition: intermission.qc:27
string Map_Current_Name
Definition: intermission.qc:24
const int MAPINFO_FLAG_NOAUTOMAPLIST
Definition: mapinfo.qh:142
bool server_is_dedicated
Definition: world.qh:37
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MaplistMethod_Iterate()

float MaplistMethod_Iterate ( )

Definition at line 167 of file intermission.qc.

References LOG_TRACE, Map_Check(), Map_Count, Map_Current, and pass.

Referenced by GetNextMap().

168 {
169  float pass, i;
170 
171  LOG_TRACE("Trying MaplistMethod_Iterate");
172 
173  for(pass = 1; pass <= 2; ++pass)
174  {
175  for(i = 1; i < Map_Count; ++i)
176  {
177  float mapindex;
178  mapindex = (i + Map_Current) % Map_Count;
179  if(Map_Check(mapindex, pass))
180  return mapindex;
181  }
182  }
183  return -1;
184 }
float Map_Count
Definition: intermission.qc:23
float Map_Current
Definition: intermission.qc:23
bool Map_Check(int position, float pass)
#define LOG_TRACE(...)
Definition: log.qh:81
#define pass(name, colormin, colormax)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MaplistMethod_Random()

float MaplistMethod_Random ( )

Definition at line 195 of file intermission.qc.

References floor(), LOG_TRACE, Map_Check(), Map_Count, Map_Current, and random().

Referenced by GetNextMap().

196 {
197  float i, imax;
198 
199  LOG_TRACE("Trying MaplistMethod_Random");
200 
201  imax = 42;
202 
203  for(i = 0; i <= imax; ++i)
204  {
205  float mapindex;
206  mapindex = (Map_Current + floor(random() * (Map_Count - 1) + 1)) % Map_Count; // any OTHER map
207  if(Map_Check(mapindex, 1))
208  return mapindex;
209  }
210  return -1;
211 }
float Map_Count
Definition: intermission.qc:23
float Map_Current
Definition: intermission.qc:23
bool Map_Check(int position, float pass)
#define LOG_TRACE(...)
Definition: log.qh:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MaplistMethod_Repeat()

float MaplistMethod_Repeat ( )

Definition at line 186 of file intermission.qc.

References LOG_TRACE, Map_Check(), and Map_Current.

Referenced by GetNextMap().

187 {
188  LOG_TRACE("Trying MaplistMethod_Repeat");
189 
190  if(Map_Check(Map_Current, 2))
191  return Map_Current;
192  return -2;
193 }
float Map_Current
Definition: intermission.qc:23
bool Map_Check(int position, float pass)
#define LOG_TRACE(...)
Definition: log.qh:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MaplistMethod_Shuffle()

float MaplistMethod_Shuffle ( float  exponent)

Definition at line 213 of file intermission.qc.

References argv(), autocvar_g_maplist, ceil(), cvar_set(), ftos(), LOG_TRACE, Map_Check(), Map_Count, Map_Current, random(), strcat(), strlen(), substring(), and tokenizebyseparator.

Referenced by GetNextMap().

216 {
217  float i, j, imax, insertpos;
218 
219  LOG_TRACE("Trying MaplistMethod_Shuffle");
220 
221  imax = 42;
222 
223  for(i = 0; i <= imax; ++i)
224  {
225  string newlist;
226 
227  // now reinsert this at another position
228  insertpos = (random() ** (1 / exponent)); // ]0, 1]
229  insertpos = insertpos * (Map_Count - 1); // ]0, Map_Count - 1]
230  insertpos = ceil(insertpos) + 1; // {2, 3, 4, ..., Map_Count}
231  LOG_TRACE("SHUFFLE: insert pos = ", ftos(insertpos));
232 
233  // insert the current map there
234  newlist = "";
235  for(j = 1; j < insertpos; ++j) // i == 1: no loop, will be inserted as first; however, i == 1 has been excluded above
236  newlist = strcat(newlist, " ", argv(j));
237  newlist = strcat(newlist, " ", argv(0)); // now insert the just selected map
238  for(j = insertpos; j < Map_Count; ++j) // i == Map_Count: no loop, has just been inserted as last
239  newlist = strcat(newlist, " ", argv(j));
240  newlist = substring(newlist, 1, strlen(newlist) - 1);
241  cvar_set("g_maplist", newlist);
242  Map_Count = tokenizebyseparator(autocvar_g_maplist, " ");
243 
244  // NOTE: the selected map has just been inserted at (insertpos-1)th position
245  Map_Current = insertpos - 1; // this is not really valid, but this way the fallback has a chance of working
246  if(Map_Check(Map_Current, 1))
247  return Map_Current;
248  }
249  return -1;
250 }
float Map_Count
Definition: intermission.qc:23
float Map_Current
Definition: intermission.qc:23
bool Map_Check(int position, float pass)
#define autocvar_g_maplist
Definition: mapvoting.qh:3
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
#define LOG_TRACE(...)
Definition: log.qh:81
#define tokenizebyseparator
Definition: dpextensions.qh:21
+ 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

◆ autoscreenshot

float autoscreenshot

Definition at line 422 of file intermission.qc.

Referenced by IntermissionThink().

◆ Map_Count

◆ Map_Current

◆ Map_Current_Name

string Map_Current_Name

Definition at line 24 of file intermission.qc.

Referenced by Maplist_Init().