Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
intermission.qh File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define get_nextmap()

Functions

float DoNextMapOverride (float reinit)
void FixIntermissionClient (entity e)
string GetGametype ()
string GetMapname ()
string GetNextMap (void)
string GotoMap (string m)
void GotoNextMap (float reinit)
void IntermissionThink (entity this)
bool Map_Check (string m, float pass)
void Map_Goto (float reinit)
void Map_Goto_SetStr (string nextmapname)
bool Map_IsRecent (string m)
void Map_MarkAsRecent (string m)
void Maplist_Close ()
int Maplist_Init (void)
void Send_NextMap_To_Player (entity pl)
void Set_NextMap (string mapname)

Variables

string _nextmap
bool alreadychangedlevel
bool autocvar_lastlevel
bool autocvar_samelevel
bool autocvar_sv_autoscreenshot
string autocvar_sv_intermission_cdtrack
float intermission_exittime
bool intermission_running
int maplist_buffer

Macro Definition Documentation

◆ get_nextmap

Function Documentation

◆ DoNextMapOverride()

float DoNextMapOverride ( float reinit)

Definition at line 345 of file intermission.qc.

346{
348 {
350 alreadychangedlevel = true;
351 return true;
352 }
354 {
356 {
357 localcmd("quit\n");
358 alreadychangedlevel = true;
359 return true;
360 }
361 }
363 {
365 alreadychangedlevel = true;
366 return true;
367 }
368 if (!reinit && autocvar_samelevel) // if samelevel is set, stay on same level
369 {
370 localcmd("restart\n");
371 alreadychangedlevel = true;
372 return true;
373 }
374 if(get_nextmap() != "")
375 {
376 string m;
378 if (m != get_nextmap())
379 Set_NextMap(m);
380
381 if(!m || gametypevote)
382 return false;
384 {
386 return false;
387 }
388
389 if(MapInfo_CheckMap(m))
390 {
392 Map_Goto(reinit);
393 alreadychangedlevel = true;
394 return true;
395 }
396 }
397 if(!reinit && autocvar_lastlevel)
398 {
400 localcmd("set lastlevel 0\ntogglemenu 1\n");
401 alreadychangedlevel = true;
402 return true;
403 }
404 return false;
405}
int currentbots
Definition api.qh:104
int player_count
Definition api.qh:103
bool gametypevote
Definition mapvoting.qc:48
int cvar_settemp_restore()
Definition util.qc:851
void Set_NextMap(string mapname)
void Map_Goto_SetStr(string nextmapname)
void Map_Goto(float reinit)
bool autocvar_samelevel
bool alreadychangedlevel
bool autocvar_lastlevel
#define get_nextmap()
float MapInfo_CheckMap(string s)
Definition mapinfo.qc:1510
bool autocvar_g_campaign
Definition menu.qc:747
void localcmd(string command,...)
string strzone(string s)
void CampaignPostIntermission()
Definition campaign.qc:239
string GameTypeVote_MapInfo_FixName(string m)
Definition mapvoting.qc:103
bool autocvar_sv_vote_gametype
Definition mapvoting.qh:24
string autocvar_quit_and_redirect
Definition world.qh:13
bool autocvar_quit_when_empty
Definition world.qh:15
string redirection_target
Definition world.qh:67

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

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

◆ FixIntermissionClient()

void FixIntermissionClient ( entity e)

Definition at line 509 of file intermission.qc.

510{
511 if(!e.autoscreenshot) // initial call
512 {
513 e.autoscreenshot = time + 0.1;
514 SetResourceExplicit(e, RES_HEALTH, -2342); // health in the first intermission phase
515 for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
516 {
517 .entity weaponentity = weaponentities[slot];
518 if(e.(weaponentity))
519 {
520 e.(weaponentity).effects = EF_NODRAW;
521 if (e.(weaponentity).weaponchild)
522 e.(weaponentity).weaponchild.effects = EF_NODRAW;
523 }
524 }
525 if(IS_REAL_CLIENT(e))
526 {
527 stuffcmd(e, "\nscr_printspeed 1000000\n");
531 });
533 {
534 stuffcmd(e, sprintf("\ncd loop %s\n", RandomSelection_chosen_string));
535 }
536 msg_entity = e;
538 }
539 }
540}
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
float effects
float time
const float EF_NODRAW
string autocvar_sv_intermission_cdtrack
#define FOREACH_WORD(words, cond, body)
Definition iter.qh:33
float MSG_ONE
Definition menudefs.qc:56
void WriteByte(float data, float dest, float desto)
entity msg_entity
Definition progsdefs.qc:63
float SVC_INTERMISSION
Definition progsdefs.qc:340
#define stuffcmd(cl,...)
Definition progsdefs.qh:23
ERASEABLE void RandomSelection_Init()
Definition random.qc:4
string RandomSelection_chosen_string
Definition random.qh:7
#define RandomSelection_AddString(s, weight, priority)
Definition random.qh:16
#define IS_REAL_CLIENT(v)
Definition utils.qh:17
entity weaponchild
Definition all.qh:376
const int MAX_WEAPONSLOTS
Definition weapon.qh:16
entity weaponentities[MAX_WEAPONSLOTS]
Definition weapon.qh:17

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

Referenced by IntermissionThink(), and NextLevel().

◆ GetGametype()

◆ GetMapname()

◆ GetNextMap()

string GetNextMap ( void )

Definition at line 323 of file intermission.qc.

324{
325 int nextMap = -1;
326
327 if(nextMap == -1 && autocvar_g_maplist_selectrandom)
328 nextMap = MaplistMethod_Random();
329
330 if(nextMap == -1)
331 nextMap = MaplistMethod_Iterate();
332
333 if(nextMap == -1)
334 nextMap = MaplistMethod_Repeat();
335
336 if(nextMap >= 0)
337 {
338 Map_Goto_SetIndex(nextMap);
339 return getmapname_stored;
340 }
341
342 return "";
343}
void Map_Goto_SetIndex(int position)
int MaplistMethod_Iterate(void)
int MaplistMethod_Random(void)
int MaplistMethod_Repeat(void)
string getmapname_stored
Definition mapvoting.qh:45
bool autocvar_g_maplist_selectrandom
Definition mapvoting.qh:8

References autocvar_g_maplist_selectrandom, getmapname_stored, Map_Goto_SetIndex(), MaplistMethod_Iterate(), MaplistMethod_Random(), and MaplistMethod_Repeat().

Referenced by GotoNextMap(), and MapVote_AddVotable().

◆ GotoMap()

string GotoMap ( string m)

Definition at line 424 of file intermission.qc.

425{
427 if (!m)
428 return "The map you suggested is not available on this server.";
430 if (!MapInfo_CheckMap(m))
431 return "The map you suggested does not support the current gametype.";
432 if (m != get_nextmap())
433 Set_NextMap(m);
435 cvar_set("_endmatch", "1");
437 {
438 if(DoNextMapOverride(0))
439 return "Map switch initiated.";
440 else
441 return "Hm... no. For some reason I like THIS map more.";
442 }
443 else
444 return "Map switch will happen after scoreboard.";
445}
float DoNextMapOverride(float reinit)
bool intermission_running
void cvar_set(string name, string value)
float mapvote_initialized
Definition mapvoting.qh:46

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

Referenced by GameCommand_gotomap().

◆ GotoNextMap()

void GotoNextMap ( float reinit)

Definition at line 407 of file intermission.qc.

408{
409 //string nextmap;
410 //float n, nummaps;
411 //string s;
413 return;
414 alreadychangedlevel = true;
415
416 Maplist_Init();
417 string nextMap = GetNextMap();
419 if(nextMap == "")
420 error("Everything is broken - cannot find a next map. Please report this to the developers.");
421 Map_Goto(reinit);
422}
void Maplist_Close()
int Maplist_Init(void)
string GetNextMap(void)
#define error
Definition pre.qh:6

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

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

◆ IntermissionThink()

void IntermissionThink ( entity this)

Definition at line 456 of file intermission.qc.

457{
459
460 float server_screenshot = (autocvar_sv_autoscreenshot && CS_CVAR(this).cvar_cl_autoscreenshot);
461 float client_screenshot = (CS_CVAR(this).cvar_cl_autoscreenshot == 2);
462
463 if( (server_screenshot || client_screenshot)
464 && ((this.autoscreenshot > 0) && (time > this.autoscreenshot)) )
465 {
466 this.autoscreenshot = -1;
467 if(IS_REAL_CLIENT(this))
468 {
469 // in old clients "cl_autoscreenshot_screenshot_s %s %s;" takes the screenshot
470 // "cl_autoscreenshot_screenshot %s %s;" does nothing because the cl_autoscreenshot_screenshot alias
471 // doesn't exist; the cl_autoscreenshot_screenshot dummy cvar is created
472 // so that "cl_autoscreenshot_screenshot %s %s" doesn't print any warning in console
473
474 // in new clients "cl_autoscreenshot_screenshot %s %s;" takes the screenshot
475 // even if the cl_autoscreenshot_screenshot cvar is created, only the cl_autoscreenshot_screenshot alias
476 // is executed since only the alias is executed if a cvar with the same name exists
477 // cl_autoscreenshot_screenshot_s is not run as cl_autoscreenshot_screenshot alias clears it
478 // (it doesn't delete it so that "unalias cl_autoscreenshot_screenshot_s;" doesn't print any warning)
479
480 // this stuffcmd is needed only for Xonotic 0.8.6 or lower
481 // the s in cl_autoscreenshot_screenshot_s stands for server alias (alias name can't be longer than 32)
482 stuffcmd(this, sprintf("\n"
483 "alias cl_autoscreenshot_screenshot_s \"screenshot screenshots/autoscreenshot/%s-%s.jpg\";"
484 "set cl_autoscreenshot_screenshot 0;", GetMapname(), matchid));
485
486 // keep only this stuffcmd after the next release
487 stuffcmd(this, sprintf("\ncl_autoscreenshot_screenshot %s %s;"
488 "echo \"^5A screenshot has been taken at request of the server.\"\n", GetMapname(), matchid));
489
490 // this stuffcmd is needed only for Xonotic 0.8.6 or lower
491 stuffcmd(this, "\n"
492 "cl_autoscreenshot_screenshot_s %s %s;"
493 "unset cl_autoscreenshot_screenshot;"
494 "unalias cl_autoscreenshot_screenshot_s;");
495 }
496 return;
497 }
498
500 return;
501
504 return;
505
507}
#define PHYS_INPUT_BUTTON_JUMP(s)
Definition player.qh:151
#define PHYS_INPUT_BUTTON_HOOK(s)
Definition player.qh:155
#define PHYS_INPUT_BUTTON_USE(s)
Definition player.qh:158
#define PHYS_INPUT_BUTTON_ATCK(s)
Definition player.qh:150
#define PHYS_INPUT_BUTTON_ATCK2(s)
Definition player.qh:152
string GetMapname()
void FixIntermissionClient(entity e)
float autoscreenshot
float intermission_exittime
bool autocvar_sv_autoscreenshot
void MapVote_Start()
Definition mapvoting.qc:743
#define CS_CVAR(this)
Definition state.qh:51
string matchid
Definition world.qh:63

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

Referenced by PlayerPreThink(), and PlayerThink().

◆ Map_Check()

bool Map_Check ( string m,
float pass )

References pass.

◆ Map_Goto()

void Map_Goto ( float reinit)

Definition at line 178 of file intermission.qc.

179{
181}
void MapInfo_LoadMap(string s, float reinit)
Definition mapinfo.qc:1523

References getmapname_stored, and MapInfo_LoadMap().

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

◆ Map_Goto_SetStr()

void Map_Goto_SetStr ( string nextmapname)

Definition at line 161 of file intermission.qc.

162{
163 if(getmapname_stored != "")
165 if(nextmapname == "")
167 else
168 getmapname_stored = strzone(nextmapname);
169}
void strunzone(string s)

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

Referenced by DoNextMapOverride(), Map_Goto_SetIndex(), MapVote_Finished(), and MapVote_Think().

◆ Map_IsRecent()

bool Map_IsRecent ( string m)

Definition at line 127 of file intermission.qc.

128{
130 return false;
132}
string autocvar_g_maplist_mostrecent
Definition mapvoting.qh:6
#define strhasword(s, w)
Definition string.qh:370

References autocvar_g_maplist_mostrecent, and strhasword.

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

◆ Map_MarkAsRecent()

void Map_MarkAsRecent ( string m)

Definition at line 122 of file intermission.qc.

123{
125}
float max(float f,...)
int autocvar_g_maplist_mostrecent_count
Definition mapvoting.qh:7
ERASEABLE string strwords(string s, int w)
Definition string.qh:361
ERASEABLE string cons(string a, string b)
Definition string.qh:276

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

Referenced by spawnfunc().

◆ Maplist_Close()

void Maplist_Close ( )

Definition at line 317 of file intermission.qc.

318{
319 buf_del(maplist_buffer);
320}
int maplist_buffer

References maplist_buffer.

Referenced by GotoNextMap(), and MapVote_AddVotableMaps().

◆ Maplist_Init()

int Maplist_Init ( void )

Definition at line 239 of file intermission.qc.

240{
241 bool have_maps = false;
242 if(autocvar_g_maplist != "")
243 {
244 // make sure there is at least one playable map in the list
245 bool needtrim = false;
247 {
248 if(!fexists(Map_Filename(it)))
249 {
250 needtrim = true;
251 if(have_maps)
252 break;
253 continue;
254 }
255 if(have_maps || !Map_Check(it, 2))
256 continue;
257 have_maps = true;
258 if(needtrim)
259 break;
260 });
261
262 // additionally trim any non-existent maps
263 if(needtrim)
264 {
265 int trimmedmaps = 0;
266 string newmaplist = "";
268 {
269 if(!fexists(Map_Filename(it)))
270 {
271 trimmedmaps += 1;
272 continue;
273 }
274 newmaplist = cons(newmaplist, it);
275 });
276 cvar_set("g_maplist", newmaplist);
277 LOG_DEBUGF("Maplist_Init: trimmed %d missing maps from the list", trimmedmaps);
278 }
279 }
280
281 if (!have_maps)
282 {
283 bprint( "Maplist contains no usable maps! Resetting it to default map list.\n" );
286 localcmd("\nmenu_cmd sync\n");
287 }
288
290
291 int _cnt = 0;
293 {
294 // NOTE: inlined maplist_shuffle function to avoid a second buffer, keep both in sync
296 {
297 int _j = floor(random() * (_cnt + 1));
298 if(_j != _cnt)
299 bufstr_set(maplist_buffer, _cnt, bufstr_get(maplist_buffer, _j));
300 bufstr_set(maplist_buffer, _j, it);
301 ++_cnt;
302 }
303 else
304 bufstr_set(maplist_buffer, i, it);
305 });
306
307 Map_Count = buf_getsize(maplist_buffer);
308
309 if(Map_Count == 0)
310 error("empty maplist, cannot select a new map");
311
313
314 return Map_Count;
315}
#define buf_create
ERASEABLE bool fexists(string f)
Definition file.qh:4
string Map_Filename(string m)
int Map_Current
int Map_Count
int GetMaplistPosition()
bool Map_Check(string m, int pass)
#define LOG_DEBUGF(...)
Definition log.qh:81
int MapInfo_RequiredFlags()
Definition mapinfo.qc:1679
Gametype MapInfo_CurrentGametype()
Definition mapinfo.qc:1490
int MapInfo_ForbiddenFlags()
Definition mapinfo.qc:1664
string MapInfo_ListAllowedMaps(Gametype type, float pRequiredFlags, float pForbiddenFlags)
Definition mapinfo.qc:1542
float bound(float min, float value, float max)
float random(void)
void bprint(string text,...)
float floor(float f)
float autocvar_g_maplist_shuffle
Definition mapvoting.qh:9
#define autocvar_g_maplist
Definition mapvoting.qh:3
bool autocvar_sv_dedicated
Definition world.qh:41

References autocvar_g_maplist, autocvar_g_maplist_shuffle, autocvar_sv_dedicated, bound(), bprint(), buf_create, cons(), cvar_set(), error, fexists(), floor(), FOREACH_WORD, GetMaplistPosition(), localcmd(), LOG_DEBUGF, Map_Check(), Map_Count, Map_Current, Map_Filename(), MapInfo_CurrentGametype(), MapInfo_ForbiddenFlags(), MapInfo_ListAllowedMaps(), MapInfo_RequiredFlags(), maplist_buffer, and random().

Referenced by GotoNextMap(), and MapVote_AddVotableMaps().

◆ Send_NextMap_To_Player()

void Send_NextMap_To_Player ( entity pl)

Definition at line 13 of file intermission.qc.

14{
15 stuffcmd(pl, sprintf("\nsettemp _nextmap %s\n", get_nextmap()));
16}

References entity(), get_nextmap, and stuffcmd.

Referenced by ClientConnect(), and Set_NextMap().

◆ Set_NextMap()

void Set_NextMap ( string mapname)

Definition at line 18 of file intermission.qc.

19{
20 if (mapname != "")
22 else
24
26}
void Send_NextMap_To_Player(entity pl)
#define strfree(this)
Definition string.qh:59
#define strcpy(this, s)
Definition string.qh:52
#define FOREACH_CLIENT(cond, body)
Definition utils.qh:50

References _nextmap, FOREACH_CLIENT, IS_REAL_CLIENT, mapname, Send_NextMap_To_Player(), strcpy, and strfree.

Referenced by DoNextMapOverride(), GameCommand_nextmap(), and GotoMap().

Variable Documentation

◆ _nextmap

string _nextmap

Definition at line 5 of file intermission.qh.

Referenced by Set_NextMap().

◆ alreadychangedlevel

bool alreadychangedlevel

◆ autocvar_lastlevel

bool autocvar_lastlevel

Definition at line 3 of file intermission.qh.

Referenced by DoNextMapOverride().

◆ autocvar_samelevel

bool autocvar_samelevel

Definition at line 13 of file intermission.qh.

Referenced by DoNextMapOverride().

◆ autocvar_sv_autoscreenshot

bool autocvar_sv_autoscreenshot

Definition at line 14 of file intermission.qh.

Referenced by IntermissionThink().

◆ autocvar_sv_intermission_cdtrack

string autocvar_sv_intermission_cdtrack

Definition at line 15 of file intermission.qh.

Referenced by FixIntermissionClient().

◆ intermission_exittime

float intermission_exittime

Definition at line 18 of file intermission.qh.

Referenced by IntermissionThink(), and NextLevel().

◆ intermission_running

◆ maplist_buffer