Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
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 (int pos)
string GameTypeVote_MapInfo_FixName (string m)
bool GameTypeVote_SetGametype (entity type, string gametype_string, bool call_hooks)
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
int autocvar_g_maplist_votable_detail
int autocvar_g_maplist_votable_reduce_count
float autocvar_g_maplist_votable_reduce_time
string autocvar_g_maplist_votable_screenshot_dir
bool autocvar_g_maplist_votable_show_suggester
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
int autocvar_sv_vote_gametype_detail
bool autocvar_sv_vote_gametype_maplist_reset = true
string autocvar_sv_vote_gametype_options
int autocvar_sv_vote_gametype_reduce_count
float autocvar_sv_vote_gametype_reduce_time
float autocvar_sv_vote_gametype_timeout
bool gametypevote
string getmapname_stored
float mapvote_initialized

Macro Definition Documentation

◆ autocvar_g_maplist

#define autocvar_g_maplist   cvar_string("g_maplist")

Definition at line 3 of file mapvoting.qh.

Referenced by getmaplist(), and Maplist_Init().

◆ 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 ( int pos)

Definition at line 896 of file mapvoting.qc.

897{
899 return false;
900
904
906
907 // save to a cvar so it can be applied back when gametype is temporary
908 // changed on gametype vote end of the next game
910 cvar_set("_sv_vote_gametype_custom", voted_gametype_string);
911
913
914 return true;
915}
bool gametypevote
Definition mapvoting.qc:48
const int GTV_CUSTOM
Definition constants.qh:65
Gametype MapInfo_CurrentGametype()
Definition mapinfo.qc:1490
void cvar_set(string name, string value)
Gametype match_gametype
Definition mapvoting.qc:276
Gametype voted_gametype
Definition mapvoting.qc:275
bool GameTypeVote_SetGametype(Gametype type, string gametype_string, bool call_hooks)
Definition mapvoting.qc:835
string voted_gametype_string
Definition mapvoting.qc:274
bool gametypevote_finished
Definition mapvoting.qc:895
Gametype GameTypeVote_Type_FromString(string type_name)
Definition mapvoting.qc:54
string mapvote_maps[MAPVOTE_COUNT]
Definition mapvoting.qc:29
int mapvote_maps_flags[MAPVOTE_COUNT]
Definition mapvoting.qc:37
#define strcpy(this, s)
Definition string.qh:52

References cvar_set(), gametypevote, gametypevote_finished, GameTypeVote_SetGametype(), GameTypeVote_Type_FromString(), GTV_CUSTOM, MapInfo_CurrentGametype(), mapvote_maps, mapvote_maps_flags, match_gametype, strcpy, voted_gametype, and voted_gametype_string.

Referenced by MapVote_Finished().

◆ GameTypeVote_MapInfo_FixName()

string GameTypeVote_MapInfo_FixName ( string m)

Definition at line 103 of file mapvoting.qc.

104{
106 {
109 }
110 return MapInfo_FixName(m);
111}
int MapInfo_RequiredFlags()
Definition mapinfo.qc:1679
float _MapInfo_FilterGametype(vector pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
Definition mapinfo.qc:181
int MapInfo_ForbiddenFlags()
Definition mapinfo.qc:1664
void MapInfo_Enumerate()
Definition mapinfo.qc:134
string MapInfo_FixName(string s)
Definition mapinfo.qc:1474
vector GameTypeVote_GetMask()
Definition mapvoting.qc:89
bool autocvar_sv_vote_gametype
Definition mapvoting.qh:24

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().

◆ GameTypeVote_SetGametype()

bool GameTypeVote_SetGametype ( entity type,
string gametype_string,
bool call_hooks )

References entity().

◆ GameTypeVote_Start()

float GameTypeVote_Start ( )

Definition at line 936 of file mapvoting.qc.

937{
940
941 mapvote_count = 0;
943 mapvote_abstain = false;
945
947 n = min(MAPVOTE_COUNT, n);
948
949 int really_available = 0;
950 int which_available = -1;
951 int i;
952 for (i = 0; i < n; ++i)
953 {
956 {
957 ++really_available;
958 which_available = i;
959 }
960 }
961
963
964 gametypevote = true;
965
966 const string current_gametype_string = (gametype_custom_enabled)
969
970 if (really_available == 0)
971 {
972 if (mapvote_count > 0)
974 mapvote_maps[0] = strzone(current_gametype_string);
976 //GameTypeVote_Finished(0);
978 return false;
979 }
980 if (really_available == 1)
981 {
982 current_gametype_index = which_available;
983 //GameTypeVote_Finished(which_available);
985 return false;
986 }
988 if (autocvar_sv_vote_gametype_default_current) // find current gametype index
989 for (i = 0; i < mapvote_count_real; ++i)
990 if (mapvote_maps[i] == current_gametype_string)
991 {
993 break;
994 }
995
997
1002
1003 MapVote_Spawn();
1004
1005 return true;
1006}
const int MAPVOTE_COUNT
Definition constants.qh:52
const int GTV_AVAILABLE
Definition constants.qh:64
float time
#define tokenizebyseparator
string MapInfo_Type_ToString(Gametype t)
Definition mapinfo.qc:656
float min(float f,...)
void strunzone(string s)
string strzone(string s)
string argv(float n)
int mapvote_count_real
Definition mapvoting.qc:28
float mapvote_reduce_time
Definition mapvoting.qc:20
int current_gametype_index
Definition mapvoting.qc:277
void MapVote_ClearAllVotes()
Definition mapvoting.qc:113
int mapvote_detail
Definition mapvoting.qc:46
bool MapVote_Finished(int mappos)
Definition mapvoting.qc:517
int mapvote_count
Definition mapvoting.qc:27
int mapvote_reduce_count
Definition mapvoting.qc:21
float mapvote_timeout
Definition mapvoting.qc:22
bool mapvote_abstain
Definition mapvoting.qc:47
void MapVote_Spawn()
Definition mapvoting.qc:495
void MapVote_UnzoneStrings()
Definition mapvoting.qc:120
bool GameTypeVote_AddVotable(string nextMode)
Definition mapvoting.qc:917
float autocvar_sv_vote_gametype_reduce_time
Definition mapvoting.qh:27
float autocvar_sv_vote_gametype_timeout
Definition mapvoting.qh:25
string autocvar_sv_vote_gametype_options
Definition mapvoting.qh:26
bool autocvar_sv_vote_gametype_default_current
Definition mapvoting.qh:30
int autocvar_sv_vote_gametype_reduce_count
Definition mapvoting.qh:28
int autocvar_sv_vote_gametype_detail
Definition mapvoting.qh:29
string loaded_gametype_custom_string
Definition world.qh:53
bool gametype_custom_enabled
Definition world.qh:52

References argv(), autocvar_sv_vote_gametype_default_current, autocvar_sv_vote_gametype_detail, autocvar_sv_vote_gametype_options, autocvar_sv_vote_gametype_reduce_count, autocvar_sv_vote_gametype_reduce_time, autocvar_sv_vote_gametype_timeout, current_gametype_index, gametype_custom_enabled, gametypevote, GameTypeVote_AddVotable(), GTV_AVAILABLE, loaded_gametype_custom_string, MapInfo_CurrentGametype(), MapInfo_Type_ToString(), mapvote_abstain, MapVote_ClearAllVotes(), MAPVOTE_COUNT, mapvote_count, mapvote_count_real, mapvote_detail, MapVote_Finished(), mapvote_maps, mapvote_maps_flags, mapvote_reduce_count, mapvote_reduce_time, MapVote_Spawn(), mapvote_timeout, MapVote_UnzoneStrings(), min(), strunzone(), strzone(), time, and tokenizebyseparator.

Referenced by MapVote_Think().

◆ MapVote_SendPicture()

void MapVote_SendPicture ( entity to,
int id )

Definition at line 332 of file mapvoting.qc.

333{
334 msg_entity = to;
335 WriteHeader(MSG_ONE, TE_CSQC_PICTURE);
336 WriteByte(MSG_ONE, id);
338}
#define WriteHeader(to, id)
Definition net.qh:221
float MSG_ONE
Definition menudefs.qc:56
void WriteByte(float data, float dest, float desto)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
entity msg_entity
Definition progsdefs.qc:63
int mapvote_maps_screenshot_dir[MAPVOTE_COUNT]
Definition mapvoting.qc:30
string mapvote_screenshot_dirs[MAPVOTE_SCREENSHOT_DIRS_COUNT]
Definition mapvoting.qc:24

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

Referenced by ClientCommand_mv_getpicture().

◆ MapVote_Spawn()

void MapVote_Spawn ( )

Definition at line 495 of file mapvoting.qc.

496{
498}
void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
Definition net.qh:123
bool MapVote_SendEntity(entity this, entity to, int sf)
Definition mapvoting.qc:413
entity mapvote_ent
Definition mapvoting.qc:51

References mapvote_ent, MapVote_SendEntity(), and Net_LinkEntity().

Referenced by GameTypeVote_Start(), and MapVote_Init().

◆ MapVote_Start()

void MapVote_Start ( )

Definition at line 743 of file mapvoting.qc.

744{
745 // if mapvote is already running, don't do this initialization again
746 if (mapvote_run)
747 return;
748
749 // don't start mapvote until after playerstats gamereport is sent
751 return;
752
755 mapvote_run = true;
756}
float MapInfo_FilterGametype(Gametype pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
Definition mapinfo.qc:177
int MapInfo_CurrentFeatures()
Definition mapinfo.qc:1480
bool PlayerStats_GameReport_DelayMapVote
bool mapvote_run
Definition mapvoting.qc:45

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

Referenced by CheckRules_World(), and IntermissionThink().

◆ MapVote_Think()

void MapVote_Think ( )

Definition at line 758 of file mapvoting.qc.

759{
760 if (!mapvote_run)
761 return;
762
764 {
765 if (time > mapvote_winner_time + 1)
766 {
767 if (voted_gametype)
768 {
769 // clear match_gametype so that GameTypeVote_SetGametype
770 // prints the gametype switch message
773 }
774
776 Map_Goto(0);
778 }
779 return;
780 }
781
783 return;
784
786 return;
787 //dprint("tick\n");
788
789 mapvote_nextthink = time + 0.5;
790 if (mapvote_nextthink > mapvote_timeout - 0.1) // make sure there's no delay when map vote times out
792
794 {
796 {
797 cvar_set("rescan_pending", "2");
798 localcmd("\nfs_rescan\nrescan_pending 3\n");
799 return;
800 }
801 else if (autocvar_rescan_pending == 2)
802 {
803 return;
804 }
805 else if (autocvar_rescan_pending == 3)
806 {
807 // now build missing mapinfo files
809 return;
810
811 // we're done, start the timer
812 cvar_set("rescan_pending", "0");
813 }
814
815 mapvote_initialized = true;
816 if (DoNextMapOverride(0))
817 return;
819 {
820 GotoNextMap(0);
821 return;
822 }
823
826 else if (get_nextmap() == "")
827 MapVote_Init();
828 }
829
830 MapVote_Tick();
831}
int player_count
Definition api.qh:103
void MapVote_Init()
Definition mapvoting.qc:795
void Map_Goto_SetStr(string nextmapname)
void Map_Goto(float reinit)
float DoNextMapOverride(float reinit)
void GotoNextMap(float reinit)
bool alreadychangedlevel
#define get_nextmap()
void localcmd(string command,...)
#define NULL
Definition post.qh:14
int mapvote_winner
Definition mapvoting.qc:411
float mapvote_winner_time
Definition mapvoting.qc:412
void MapVote_Tick()
Definition mapvoting.qc:702
bool GameTypeVote_Start()
Definition mapvoting.qc:936
float mapvote_nextthink
Definition mapvoting.qc:19
#define autocvar_g_maplist_votable
Definition mapvoting.qh:10
int autocvar_rescan_pending
Definition mapvoting.qh:23
float mapvote_initialized
Definition mapvoting.qh:46
#define strfree(this)
Definition string.qh:59

References alreadychangedlevel, autocvar_g_maplist_votable, autocvar_rescan_pending, autocvar_sv_vote_gametype, cvar_set(), DoNextMapOverride(), GameTypeVote_SetGametype(), GameTypeVote_Start(), get_nextmap, GotoNextMap(), localcmd(), Map_Goto(), Map_Goto_SetStr(), MapInfo_CurrentFeatures(), MapInfo_CurrentGametype(), MapInfo_FilterGametype(), MapInfo_ForbiddenFlags(), MapInfo_RequiredFlags(), MapVote_Init(), mapvote_initialized, mapvote_maps, mapvote_nextthink, mapvote_run, MapVote_Tick(), mapvote_timeout, mapvote_winner, mapvote_winner_time, match_gametype, NULL, player_count, strfree, time, voted_gametype, and voted_gametype_string.

Referenced by CheckRules_World().

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 20 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

Definition at line 9 of file mapvoting.qh.

Referenced by Maplist_Init().

◆ autocvar_g_maplist_sizes_count_bots

bool autocvar_g_maplist_sizes_count_bots = true

Definition at line 22 of file mapvoting.qh.

Referenced by MapHasRightSize().

◆ autocvar_g_maplist_sizes_count_maxplayers

bool autocvar_g_maplist_sizes_count_maxplayers = true

Definition at line 21 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_detail

int autocvar_g_maplist_votable_detail

Definition at line 15 of file mapvoting.qh.

Referenced by MapVote_Init().

◆ autocvar_g_maplist_votable_reduce_count

int autocvar_g_maplist_votable_reduce_count

Definition at line 14 of file mapvoting.qh.

Referenced by MapVote_Init().

◆ autocvar_g_maplist_votable_reduce_time

float autocvar_g_maplist_votable_reduce_time

Definition at line 13 of file mapvoting.qh.

Referenced by MapVote_Init().

◆ autocvar_g_maplist_votable_screenshot_dir

string autocvar_g_maplist_votable_screenshot_dir

Definition at line 16 of file mapvoting.qh.

Referenced by MapVote_Init().

◆ autocvar_g_maplist_votable_show_suggester

bool autocvar_g_maplist_votable_show_suggester

Definition at line 12 of file mapvoting.qh.

Referenced by MapVote_Init().

◆ autocvar_g_maplist_votable_suggestions

bool autocvar_g_maplist_votable_suggestions

Definition at line 17 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 18 of file mapvoting.qh.

Referenced by MapVote_Suggest().

◆ autocvar_g_maplist_votable_timeout

float autocvar_g_maplist_votable_timeout

Definition at line 19 of file mapvoting.qh.

Referenced by MapVote_Init().

◆ autocvar_rescan_pending

int autocvar_rescan_pending

Definition at line 23 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 30 of file mapvoting.qh.

Referenced by GameTypeVote_Start().

◆ autocvar_sv_vote_gametype_detail

int autocvar_sv_vote_gametype_detail

Definition at line 29 of file mapvoting.qh.

Referenced by GameTypeVote_Start().

◆ autocvar_sv_vote_gametype_maplist_reset

bool autocvar_sv_vote_gametype_maplist_reset = true

Definition at line 31 of file mapvoting.qh.

Referenced by GameTypeVote_SetGametype().

◆ autocvar_sv_vote_gametype_options

string autocvar_sv_vote_gametype_options

Definition at line 26 of file mapvoting.qh.

Referenced by GameTypeVote_GetMask(), and GameTypeVote_Start().

◆ autocvar_sv_vote_gametype_reduce_count

int autocvar_sv_vote_gametype_reduce_count

Definition at line 28 of file mapvoting.qh.

Referenced by GameTypeVote_Start().

◆ autocvar_sv_vote_gametype_reduce_time

float autocvar_sv_vote_gametype_reduce_time

Definition at line 27 of file mapvoting.qh.

Referenced by GameTypeVote_Start().

◆ autocvar_sv_vote_gametype_timeout

float autocvar_sv_vote_gametype_timeout

Definition at line 25 of file mapvoting.qh.

Referenced by GameTypeVote_Start().

◆ gametypevote

bool gametypevote

Definition at line 44 of file mapvoting.qh.

◆ getmapname_stored

string getmapname_stored

Definition at line 45 of file mapvoting.qh.

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

◆ mapvote_initialized

float mapvote_initialized

Definition at line 46 of file mapvoting.qh.

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