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

Go to the source code of this file.

Macros

#define autocvar_g_maplist   cvar_string("g_maplist")
 
#define autocvar_g_maplist_votable   cvar("g_maplist_votable")
 

Functions

float GameTypeVote_Finished (float pos)
 
string GameTypeVote_MapInfo_FixName (string m)
 
float GameTypeVote_Start ()
 
void MapVote_SendPicture (entity to, int id)
 
void MapVote_Spawn ()
 
void MapVote_Start ()
 
void MapVote_Think ()
 

Variables

bool autocvar_g_maplist_check_waypoints
 
bool autocvar_g_maplist_ignore_sizes
 
int autocvar_g_maplist_index
 
string autocvar_g_maplist_mostrecent
 
int autocvar_g_maplist_mostrecent_count
 
bool autocvar_g_maplist_selectrandom
 
float autocvar_g_maplist_shuffle
 
bool autocvar_g_maplist_sizes_count_bots = true
 
bool autocvar_g_maplist_sizes_count_maxplayers = true
 
bool autocvar_g_maplist_votable_abstain
 
float autocvar_g_maplist_votable_keeptwotime
 
bool autocvar_g_maplist_votable_nodetail
 
string autocvar_g_maplist_votable_screenshot_dir
 
bool autocvar_g_maplist_votable_suggestions
 
bool autocvar_g_maplist_votable_suggestions_override_mostrecent
 
float autocvar_g_maplist_votable_timeout
 
int autocvar_rescan_pending
 
bool autocvar_sv_vote_gametype
 
bool autocvar_sv_vote_gametype_default_current
 
float autocvar_sv_vote_gametype_keeptwotime
 
string autocvar_sv_vote_gametype_options
 
float autocvar_sv_vote_gametype_timeout
 
float gametypevote
 
string getmapname_stored
 
float mapvote_initialized
 

Macro Definition Documentation

◆ autocvar_g_maplist

#define autocvar_g_maplist   cvar_string("g_maplist")

◆ autocvar_g_maplist_votable

#define autocvar_g_maplist_votable   cvar("g_maplist_votable")

Definition at line 10 of file mapvoting.qh.

Referenced by MapVote_Init(), and MapVote_Think().

Function Documentation

◆ GameTypeVote_Finished()

float GameTypeVote_Finished ( float  pos)

◆ GameTypeVote_MapInfo_FixName()

string GameTypeVote_MapInfo_FixName ( string  m)

Definition at line 95 of file mapvoting.qc.

References _MapInfo_FilterGametype(), autocvar_sv_vote_gametype, GameTypeVote_GetMask(), MapInfo_Enumerate(), MapInfo_FixName(), MapInfo_ForbiddenFlags(), and MapInfo_RequiredFlags().

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

96 {
98  {
101  }
102  return MapInfo_FixName(m);
103 }
int MapInfo_RequiredFlags()
Definition: mapinfo.qc:1339
int MapInfo_ForbiddenFlags()
Definition: mapinfo.qc:1324
int GameTypeVote_GetMask()
Definition: mapvoting.qc:84
string MapInfo_FixName(string s)
Definition: mapinfo.qc:1134
float _MapInfo_FilterGametype(int pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
Definition: mapinfo.qc:162
void MapInfo_Enumerate()
Definition: mapinfo.qc:115
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:

◆ GameTypeVote_Start()

float GameTypeVote_Start ( )

Definition at line 773 of file mapvoting.qc.

References argv(), autocvar_g_maplist_votable_nodetail, autocvar_sv_vote_gametype_keeptwotime, autocvar_sv_vote_gametype_options, autocvar_sv_vote_gametype_timeout, gametypevote, GameTypeVote_AddVotable(), MapInfo_CurrentGametype(), MapInfo_Type_ToString(), mapvote_abstain, MapVote_ClearAllVotes(), mapvote_count, mapvote_count_real, mapvote_detail, MapVote_Finished(), mapvote_keeptwotime, mapvote_maps, mapvote_maps_flags, MapVote_Spawn(), mapvote_timeout, MapVote_UnzoneStrings(), min(), strunzone(), strzone(), time, and tokenizebyseparator.

Referenced by MapVote_Think().

774 {
777 
778  mapvote_count = 0;
780  mapvote_abstain = false;
782 
784  n = min(MAPVOTE_COUNT, n);
785 
786  int really_available, which_available;
787  really_available = 0;
788  which_available = -1;
789  for(int j = 0; j < n; ++j)
790  {
791  if ( GameTypeVote_AddVotable(argv(j)) )
792  if ( mapvote_maps_flags[j] & GTV_AVAILABLE )
793  {
794  really_available++;
795  which_available = j;
796  }
797  }
798 
800 
801  gametypevote = 1;
802 
803  if ( really_available == 0 )
804  {
805  if ( mapvote_count > 0 )
808  //GameTypeVote_Finished(0);
809  MapVote_Finished(0);
810  return false;
811  }
812  if ( really_available == 1 )
813  {
814  //GameTypeVote_Finished(which_available);
815  MapVote_Finished(which_available);
816  return false;
817  }
818 
820 
824 
825  MapVote_Spawn();
826 
827  return true;
828 }
bool mapvote_abstain
Definition: mapvoting.qc:40
string MapInfo_Type_ToString(Gametype t)
Definition: mapinfo.qc:616
string mapvote_maps[MAPVOTE_COUNT]
Definition: mapvoting.qc:29
void MapVote_Spawn()
Definition: mapvoting.qc:407
float autocvar_sv_vote_gametype_timeout
Definition: mapvoting.qh:23
int mapvote_count_real
Definition: mapvoting.qc:28
void MapVote_UnzoneStrings()
Definition: mapvoting.qc:110
string autocvar_sv_vote_gametype_options
Definition: mapvoting.qh:24
Gametype MapInfo_CurrentGametype()
Definition: mapinfo.qc:1150
int mapvote_maps_flags[MAPVOTE_COUNT]
Definition: mapvoting.qc:37
bool MapVote_Finished(int mappos)
Definition: mapvoting.qc:422
bool autocvar_g_maplist_votable_nodetail
Definition: mapvoting.qh:13
int mapvote_count
Definition: mapvoting.qc:27
float gametypevote
Definition: mapvoting.qc:40
bool GameTypeVote_AddVotable(string nextMode)
Definition: mapvoting.qc:751
#define tokenizebyseparator
Definition: dpextensions.qh:21
float autocvar_sv_vote_gametype_keeptwotime
Definition: mapvoting.qh:25
bool mapvote_detail
Definition: mapvoting.qc:39
float time
Definition: csprogsdefs.qc:16
void MapVote_ClearAllVotes()
Definition: mapvoting.qc:105
float mapvote_keeptwotime
Definition: mapvoting.qc:21
float mapvote_timeout
Definition: mapvoting.qc:22
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MapVote_SendPicture()

void MapVote_SendPicture ( entity  to,
int  id 
)

Definition at line 258 of file mapvoting.qc.

References mapvote_maps, mapvote_maps_screenshot_dir, mapvote_screenshot_dirs, msg_entity, MSG_ONE, strcat(), to, and WriteByte().

Referenced by ClientCommand_mv_getpicture().

259 {
260  msg_entity = to;
261  WriteHeader(MSG_ONE, TE_CSQC_PICTURE);
262  WriteByte(MSG_ONE, id);
264 }
string mapvote_maps[MAPVOTE_COUNT]
Definition: mapvoting.qc:29
string mapvote_screenshot_dirs[MAPVOTE_SCREENSHOT_DIRS_COUNT]
Definition: mapvoting.qc:24
entity to
Definition: self.qh:96
entity msg_entity
Definition: progsdefs.qc:63
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 mapvote_maps_screenshot_dir[MAPVOTE_COUNT]
Definition: mapvoting.qc:30
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MapVote_Spawn()

void MapVote_Spawn ( )

Definition at line 407 of file mapvoting.qc.

References mapvote_ent, and MapVote_SendEntity().

Referenced by GameTypeVote_Start(), and MapVote_Init().

408 {
409  Net_LinkEntity(mapvote_ent = new(mapvote_ent), false, 0, MapVote_SendEntity);
410 }
entity mapvote_ent
Definition: mapvoting.qc:43
bool MapVote_SendEntity(entity this, entity to, int sf)
Definition: mapvoting.qc:340
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MapVote_Start()

void MapVote_Start ( )

Definition at line 632 of file mapvoting.qc.

References MapInfo_CurrentFeatures(), MapInfo_CurrentGametype(), MapInfo_Enumerate(), MapInfo_FilterGametype(), MapInfo_ForbiddenFlags(), MapInfo_RequiredFlags(), and mapvote_run.

Referenced by CheckRules_World(), and IntermissionThink().

633 {
634  // if mapvote is already running, don't do this initialization again
635  if(mapvote_run) { return; }
636 
637  // don't start mapvote until after playerstats gamereport is sent
638  if(PlayerStats_GameReport_DelayMapVote) { return; }
639 
642  mapvote_run = true;
643 }
int MapInfo_RequiredFlags()
Definition: mapinfo.qc:1339
bool mapvote_run
Definition: mapvoting.qc:38
int MapInfo_ForbiddenFlags()
Definition: mapinfo.qc:1324
Gametype MapInfo_CurrentGametype()
Definition: mapinfo.qc:1150
int MapInfo_CurrentFeatures()
Definition: mapinfo.qc:1140
float MapInfo_FilterGametype(Gametype pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
Definition: mapinfo.qc:158
void MapInfo_Enumerate()
Definition: mapinfo.qc:115
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MapVote_Think()

void MapVote_Think ( )

Definition at line 645 of file mapvoting.qc.

References alreadychangedlevel, autocvar_g_maplist_votable, autocvar_nextmap, autocvar_rescan_pending, autocvar_sv_vote_gametype, cvar_set(), DoNextMapOverride(), GameTypeVote_Start(), GotoNextMap(), localcmd, MapInfo_CurrentFeatures(), MapInfo_CurrentGametype(), MapInfo_FilterGametype(), MapInfo_ForbiddenFlags(), MapInfo_RequiredFlags(), MapVote_Init(), mapvote_initialized, mapvote_nextthink, mapvote_run, MapVote_Tick(), player_count, and time.

Referenced by CheckRules_World().

646 {
647  if(!mapvote_run)
648  return;
649 
651  return;
652 
653  if(time < mapvote_nextthink)
654  return;
655  //dprint("tick\n");
656 
657  mapvote_nextthink = time + 0.5;
658 
660  {
661  if(autocvar_rescan_pending == 1)
662  {
663  cvar_set("rescan_pending", "2");
664  localcmd("fs_rescan\nrescan_pending 3\n");
665  return;
666  }
667  else if(autocvar_rescan_pending == 2)
668  {
669  return;
670  }
671  else if(autocvar_rescan_pending == 3)
672  {
673  // now build missing mapinfo files
675  return;
676 
677  // we're done, start the timer
678  cvar_set("rescan_pending", "0");
679  }
680 
681  mapvote_initialized = true;
682  if(DoNextMapOverride(0))
683  return;
685  {
686  GotoNextMap(0);
687  return;
688  }
689 
691  else if(autocvar_nextmap == "") { MapVote_Init(); }
692  }
693 
694  MapVote_Tick();
695 }
void MapVote_Tick()
Definition: mapvoting.qc:586
int MapInfo_RequiredFlags()
Definition: mapinfo.qc:1339
bool mapvote_run
Definition: mapvoting.qc:38
void GotoNextMap(float reinit)
#define autocvar_g_maplist_votable
Definition: mapvoting.qh:10
int player_count
Definition: api.qh:103
bool GameTypeVote_Start()
Definition: mapvoting.qc:773
int MapInfo_ForbiddenFlags()
Definition: mapinfo.qc:1324
string autocvar_nextmap
Definition: intermission.qh:4
Gametype MapInfo_CurrentGametype()
Definition: mapinfo.qc:1150
int MapInfo_CurrentFeatures()
Definition: mapinfo.qc:1140
float DoNextMapOverride(float reinit)
float mapvote_nextthink
Definition: mapvoting.qc:20
bool alreadychangedlevel
Definition: intermission.qh:11
void MapVote_Init()
Definition: mapvoting.qc:663
float mapvote_initialized
Definition: mapvoting.qh:39
float MapInfo_FilterGametype(Gametype pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
Definition: mapinfo.qc:158
float time
Definition: csprogsdefs.qc:16
bool autocvar_sv_vote_gametype
Definition: mapvoting.qh:22
int autocvar_rescan_pending
Definition: mapvoting.qh:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ autocvar_g_maplist_check_waypoints

bool autocvar_g_maplist_check_waypoints

Definition at line 4 of file mapvoting.qh.

Referenced by MapHasRightSize().

◆ autocvar_g_maplist_ignore_sizes

bool autocvar_g_maplist_ignore_sizes

Definition at line 18 of file mapvoting.qh.

Referenced by MapHasRightSize().

◆ autocvar_g_maplist_index

int autocvar_g_maplist_index

Definition at line 5 of file mapvoting.qh.

Referenced by GetMaplistPosition().

◆ autocvar_g_maplist_mostrecent

string autocvar_g_maplist_mostrecent

Definition at line 6 of file mapvoting.qh.

Referenced by Map_IsRecent(), and Map_MarkAsRecent().

◆ autocvar_g_maplist_mostrecent_count

int autocvar_g_maplist_mostrecent_count

Definition at line 7 of file mapvoting.qh.

Referenced by Map_MarkAsRecent().

◆ autocvar_g_maplist_selectrandom

bool autocvar_g_maplist_selectrandom

Definition at line 8 of file mapvoting.qh.

Referenced by GetNextMap().

◆ autocvar_g_maplist_shuffle

float autocvar_g_maplist_shuffle

◆ autocvar_g_maplist_sizes_count_bots

bool autocvar_g_maplist_sizes_count_bots = true

Definition at line 20 of file mapvoting.qh.

Referenced by MapHasRightSize().

◆ autocvar_g_maplist_sizes_count_maxplayers

bool autocvar_g_maplist_sizes_count_maxplayers = true

Definition at line 19 of file mapvoting.qh.

Referenced by MapHasRightSize().

◆ autocvar_g_maplist_votable_abstain

bool autocvar_g_maplist_votable_abstain

Definition at line 11 of file mapvoting.qh.

Referenced by MapVote_Init().

◆ autocvar_g_maplist_votable_keeptwotime

float autocvar_g_maplist_votable_keeptwotime

Definition at line 12 of file mapvoting.qh.

Referenced by MapVote_Init().

◆ autocvar_g_maplist_votable_nodetail

bool autocvar_g_maplist_votable_nodetail

Definition at line 13 of file mapvoting.qh.

Referenced by GameTypeVote_Start(), and MapVote_Init().

◆ autocvar_g_maplist_votable_screenshot_dir

string autocvar_g_maplist_votable_screenshot_dir

Definition at line 14 of file mapvoting.qh.

Referenced by MapVote_Init().

◆ autocvar_g_maplist_votable_suggestions

bool autocvar_g_maplist_votable_suggestions

Definition at line 15 of file mapvoting.qh.

Referenced by MapVote_Init(), and MapVote_Suggest().

◆ autocvar_g_maplist_votable_suggestions_override_mostrecent

bool autocvar_g_maplist_votable_suggestions_override_mostrecent

Definition at line 16 of file mapvoting.qh.

Referenced by MapVote_Suggest().

◆ autocvar_g_maplist_votable_timeout

float autocvar_g_maplist_votable_timeout

Definition at line 17 of file mapvoting.qh.

Referenced by MapVote_Init().

◆ autocvar_rescan_pending

int autocvar_rescan_pending

Definition at line 21 of file mapvoting.qh.

Referenced by MapVote_Think().

◆ autocvar_sv_vote_gametype

bool autocvar_sv_vote_gametype

◆ autocvar_sv_vote_gametype_default_current

bool autocvar_sv_vote_gametype_default_current

Definition at line 26 of file mapvoting.qh.

Referenced by MapVote_CheckRules_2().

◆ autocvar_sv_vote_gametype_keeptwotime

float autocvar_sv_vote_gametype_keeptwotime

Definition at line 25 of file mapvoting.qh.

Referenced by GameTypeVote_Start().

◆ autocvar_sv_vote_gametype_options

string autocvar_sv_vote_gametype_options

Definition at line 24 of file mapvoting.qh.

Referenced by GameTypeVote_GetMask(), and GameTypeVote_Start().

◆ autocvar_sv_vote_gametype_timeout

float autocvar_sv_vote_gametype_timeout

Definition at line 23 of file mapvoting.qh.

Referenced by GameTypeVote_Start().

◆ gametypevote

float gametypevote

Definition at line 37 of file mapvoting.qh.

◆ getmapname_stored

string getmapname_stored

Definition at line 38 of file mapvoting.qh.

Referenced by GetNextMap(), Map_Goto(), and Map_Goto_SetStr().

◆ mapvote_initialized

float mapvote_initialized

Definition at line 39 of file mapvoting.qh.

Referenced by GotoMap(), IntermissionThink(), MapVote_Suggest(), MapVote_Think(), and PlayerHealth().