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

Go to the source code of this file.

Classes

class  Gametype

Macros

#define MAPINFO_SETTEMP_ACL_SYSTEM   "-g_mapinfo_* -rcon_* -_* -g_ban* +*"
#define MAPINFO_SETTEMP_ACL_USER   cvar_string("g_mapinfo_settemp_acl")
#define REGISTER_GAMETYPE(NAME, inst)

Functions

vector _GametypeFlags_FromGametype (int a)
float _MapInfo_FilterGametype (vector gametypeFlags, float features, float pFlagsRequired, float pFlagsForbidden, float pAbortOnGenerate)
string _MapInfo_FindArenaFile (string pFilename, string extension)
string _MapInfo_GetDefaultEx (Gametype t)
float _MapInfo_GetTeamPlayBool (Gametype t)
void _MapInfo_Parse_Settemp (string pFilename, string acl, float type, string s, float recurse)
bool _MapInfo_ParseArena (string arena_filename, int fh, string pFilename, Gametype pGametypeToSet, bool isdefi, bool isgenerator)
string MapInfo_BSPName_ByID (float i)
void MapInfo_Cache_Create ()
void MapInfo_Cache_Destroy ()
void MapInfo_Cache_Invalidate ()
float MapInfo_CheckMap (string s)
void MapInfo_ClearTemps ()
int MapInfo_CurrentFeatures ()
Gametype MapInfo_CurrentGametype ()
void MapInfo_Enumerate ()
float MapInfo_FilterGametype (Gametype gametypeFlags, float features, float pFlagsRequired, float pFlagsForbidden, float pAbortOnGenerate)
void MapInfo_FilterString (string sf)
float MapInfo_FindName (string s)
string MapInfo_FixName (string s)
int MapInfo_ForbiddenFlags ()
bool MapInfo_Get_ByID (int i)
int MapInfo_Get_ByName (string s, float allowGenerate, Gametype gametypeToSet)
string MapInfo_ListAllAllowedMaps (float pFlagsRequired, float pFlagsForbidden)
string MapInfo_ListAllowedMaps (Gametype type, float pFlagsRequired, float pFlagsForbidden)
void MapInfo_LoadMap (string s, float reinit)
void MapInfo_LoadMapSettings (string s)
int MapInfo_RequiredFlags ()
void MapInfo_Shutdown ()
void MapInfo_SwitchGameType (Gametype t)
string MapInfo_Type_Description (Gametype t)
Gametype MapInfo_Type_FromString (string t, bool dowarn, bool is_q3compat)
string MapInfo_Type_ToString (Gametype t)
string MapInfo_Type_ToText (Gametype t)
bool MapReadSizes (string map)
 STATIC_INIT (Gametypes_renumber)

Variables

const int GAMETYPE_FLAG_1V1 = BIT(6)
const int GAMETYPE_FLAG_HIDELIMITS = BIT(4)
const int GAMETYPE_FLAG_PREFERRED = BIT(2)
const int GAMETYPE_FLAG_PRIORITY = BIT(3)
const int GAMETYPE_FLAG_TEAMPLAY = BIT(0)
const int GAMETYPE_FLAG_USEPOINTS = BIT(1)
const int GAMETYPE_FLAG_WEAPONARENA = BIT(5)
vector gametype_flags
int map_maxplayers
int map_minplayers
float MapInfo_count
const int MAPINFO_FEATURE_MONSTERS = 8
const int MAPINFO_FEATURE_TURRETS = 4
const int MAPINFO_FEATURE_VEHICLES = 2
const int MAPINFO_FEATURE_WEAPONS = 1
float MapInfo_FindName_firstResult
string MapInfo_FindName_match
const int MAPINFO_FLAG_DONOTWANT = 8
const int MAPINFO_FLAG_FORBIDDEN = 2
const int MAPINFO_FLAG_FRUSTRATING = 4
const int MAPINFO_FLAG_HIDDEN = 1
Gametype MapInfo_LoadedGametype
string MapInfo_Map_author
string MapInfo_Map_bspname
string MapInfo_Map_clientstuff
string MapInfo_Map_description
int MapInfo_Map_flags
string MapInfo_Map_fog
vector MapInfo_Map_maxs
vector MapInfo_Map_mins
int MapInfo_Map_supportedFeatures
vector MapInfo_Map_supportedGametypes
string MapInfo_Map_title
string MapInfo_Map_titlestring
float MapInfo_progress
vector MAPINFO_TYPE_ALL

Macro Definition Documentation

◆ MAPINFO_SETTEMP_ACL_SYSTEM

#define MAPINFO_SETTEMP_ACL_SYSTEM   "-g_mapinfo_* -rcon_* -_* -g_ban* +*"

Definition at line 237 of file mapinfo.qh.

Referenced by _MapInfo_Parse_Settemp().

◆ MAPINFO_SETTEMP_ACL_USER

#define MAPINFO_SETTEMP_ACL_USER   cvar_string("g_mapinfo_settemp_acl")

Definition at line 236 of file mapinfo.qh.

Referenced by CampaignPreInit(), and MapInfo_Get_ByName_NoFallbacks().

◆ REGISTER_GAMETYPE

Function Documentation

◆ _GametypeFlags_FromGametype()

vector _GametypeFlags_FromGametype ( int a)

Definition at line 20 of file mapinfo.qc.

21{
22 if (REGISTRY_MAX(Gametypes) > 24)
23 if (a >= 24)
24 {
25 a -= 24;
26 if (REGISTRY_MAX(Gametypes) > 48)
27 if (a >= 24)
28 {
29 a -= 24;
30 return '0 0 1' * BIT(a);
31 }
32 return '0 1 0' * BIT(a);
33 }
34 return '1 0 0' * BIT(a);
35}
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
#define REGISTRY_MAX(id)
Definition registry.qh:17

References BIT, REGISTRY_MAX, and vector.

Referenced by STATIC_INIT().

◆ _MapInfo_FilterGametype()

float _MapInfo_FilterGametype ( vector gametypeFlags,
float features,
float pFlagsRequired,
float pFlagsForbidden,
float pAbortOnGenerate )

References vector.

◆ _MapInfo_FindArenaFile()

string _MapInfo_FindArenaFile ( string pFilename,
string extension )

Definition at line 1008 of file mapinfo.qc.

1009{
1010 // A valid arena file with the "default" name may have been created as a map-specific
1011 // override of an arena file with a different name (possibly multi-map) in the pk3
1012 // (occasionally in the wild such file exists in the pk3 but isn't valid for a map in the pk3).
1013 // Therefore we try the "default" name first.
1014 string afile = _MapInfo_CheckArenaFile(strcat("scripts/", pFilename, extension), pFilename);
1015 if (afile != ""
1016 || !checkextension("DP_QC_FS_SEARCH_PACKFILE"))
1017 return afile;
1018
1019 string base_pack = whichpack(strcat("maps/", pFilename, ".bsp"));
1020 if(base_pack == "") // this map isn't packaged!
1021 return "";
1022 int glob = search_packfile_begin(strcat("scripts/*", extension), true, true, base_pack);
1023 if(glob < 0) // there's no matching file in the pack
1024 return "";
1025 int n = search_getsize(glob);
1026 for(int j = 0; j < n; ++j)
1027 {
1028 afile = search_getfilename(glob, j);
1029 if(_MapInfo_CheckArenaFile(afile, pFilename) != "")
1030 {
1031 search_end(glob);
1032 return afile;
1033 }
1034 }
1035 search_end(glob);
1036
1037 return ""; // if we get here, a valid .arena file could not be found
1038}
string _MapInfo_CheckArenaFile(string pFilename, string pMapname)
Definition mapinfo.qc:978
string search_getfilename(float handle, float num)
float search_getsize(float handle)
float checkextension(string ext)
void search_end(float handle)
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))

References _MapInfo_CheckArenaFile(), checkextension(), search_end(), search_getfilename(), search_getsize(), and strcat().

Referenced by _MapInfo_Generate(), MapInfo_Get_ByName_NoFallbacks(), and spawnfunc().

◆ _MapInfo_GetDefaultEx()

string _MapInfo_GetDefaultEx ( Gametype t)

Definition at line 534 of file mapinfo.qc.

535{
536 return t ? t.model2 : "";
537}

Referenced by _MapInfo_Map_ApplyGametypeEx().

◆ _MapInfo_GetTeamPlayBool()

float _MapInfo_GetTeamPlayBool ( Gametype t)

Definition at line 539 of file mapinfo.qc.

540{
541 return t ? t.team : false;
542}
bool team
does this gametype support teamplay?
Definition mapinfo.qh:46

References Gametype::team.

Referenced by MapHasRightSize(), NET_HANDLE(), and XonoticGametypeList_drawListBoxItem().

◆ _MapInfo_Parse_Settemp()

void _MapInfo_Parse_Settemp ( string pFilename,
string acl,
float type,
string s,
float recurse )

Definition at line 667 of file mapinfo.qc.

668{
669 string t;
670 float o;
671 // tabs are invalid, treat them as "empty"
672 s = strreplace("\t", "", s);
673
674 t = car(s); s = cdr(s);
675
676 // limited support of "" and comments
677 // remove trailing and leading " of t
678 if(substring(t, 0, 1) == "\"")
679 {
680 if(substring(t, -1, 1) == "\"")
681 t = substring(t, 1, -2);
682 }
683
684 // remove leading " of s
685 if(substring(s, 0, 1) == "\"")
686 {
687 s = substring(s, 1, -1);
688 }
689 // remove trailing " of s, and all that follows (cvar description)
690 o = strstrofs(s, "\"", 0);
691 if(o >= 0)
692 s = substring(s, 0, o);
693
694 // remove // comments
695 o = strstrofs(s, "//", 0);
696 if(o >= 0)
697 s = substring(s, 0, o);
698
699 // remove trailing spaces
700 while(substring(s, -1, 1) == " ")
701 s = substring(s, 0, -2);
702
703 if(t == "#include")
704 {
705 if(recurse > 0)
706 {
707 float fh = fopen(s, FILE_READ);
708 if(fh < 0)
709 {
710 if(WARN_COND)
711 LOG_WARN("Map ", pFilename, " references not existing config file ", s);
712 }
713 else
714 {
715 while((s = fgets(fh)))
716 {
717 s = strreplace("\t", "", s); // treat tabs as "empty", perform here first to ensure coments are detected
718 // catch different sorts of comments
719 if(s == "") // empty lines
720 continue;
721 if(substring(s, 0, 1) == "#") // UNIX style
722 continue;
723 if(substring(s, 0, 2) == "//") // C++ style
724 continue;
725 if(substring(s, 0, 1) == "_") // q3map style
726 continue;
727
728 if(substring(s, 0, 4) == "set ")
729 s = substring(s, 4, -1);
730 if(substring(s, 0, 5) == "seta ")
731 s = substring(s, 5, -1);
732
733 _MapInfo_Parse_Settemp(pFilename, acl, type, s, recurse - 1);
734 }
735 fclose(fh);
736 }
737 }
738 else if(WARN_COND)
739 LOG_WARN("Map ", pFilename, " uses too many levels of inclusion");
740 }
741 else if(t == ""
742 || !cvar_value_issafe(t)
743 || !cvar_value_issafe(s)
745 {
746 if (WARN_COND)
747 LOG_WARN("Map ", pFilename, " contains a potentially harmful setting, ignored");
748 }
749 else if(matchacl(acl, t) <= 0)
750 {
751 if (WARN_COND)
752 LOG_WARN("Map ", pFilename, " contains a denied setting, ignored");
753 }
754 else
755 {
756 if(type == 0) // server set
757 {
758 LOG_TRACE("Applying temporary setting ", t, " := ", s);
759 #if 0
760 if(cvar("g_campaign"))
761 cvar_set(t, s); // this is a wrapper and is always temporary anyway; no need to backup old values then
762 else
763 #endif
764 cvar_settemp(t, s);
765 }
766 else
767 {
768 LOG_TRACE("Applying temporary client setting ", t, " := ", s);
770 MapInfo_Map_clientstuff, "cl_cmd settemp \"", t, "\" \"", s, "\"\n"
771 );
772 }
773 }
774}
float matchacl(string acl, string str)
Definition util.qc:1339
float cvar_settemp(string tmp_cvar, string tmp_value)
Definition util.qc:811
const float FILE_READ
ERASEABLE bool cvar_value_issafe(string s)
Definition cvar.qh:11
#define strstrofs
#define LOG_TRACE(...)
Definition log.qh:76
#define LOG_WARN(...)
Definition log.qh:61
void _MapInfo_Parse_Settemp(string pFilename, string acl, float type, string s, float recurse)
Definition mapinfo.qc:667
#define WARN_COND
Definition mapinfo.qc:15
#define MAPINFO_SETTEMP_ACL_SYSTEM
Definition mapinfo.qh:237
string MapInfo_Map_clientstuff
Definition mapinfo.qh:11
void cvar_set(string name, string value)
string fgets(float fhandle)
void fclose(float fhandle)
string substring(string s, float start, float length)
float cvar(string name)
float fopen(string filename, float mode)
ERASEABLE string car(string s)
returns first word
Definition string.qh:259
ERASEABLE string cdr(string s)
returns all but first word
Definition string.qh:268

References _MapInfo_Parse_Settemp(), car(), cdr(), cvar(), cvar_set(), cvar_settemp(), cvar_value_issafe(), fclose(), fgets(), FILE_READ, fopen(), LOG_TRACE, LOG_WARN, MapInfo_Map_clientstuff, MAPINFO_SETTEMP_ACL_SYSTEM, matchacl(), strcat(), strstrofs, substring(), and WARN_COND.

Referenced by _MapInfo_Parse_Settemp(), CampaignPreInit(), and MapInfo_Get_ByName_NoFallbacks().

◆ _MapInfo_ParseArena()

bool _MapInfo_ParseArena ( string arena_filename,
int fh,
string pFilename,
Gametype pGametypeToSet,
bool isdefi,
bool isgenerator )

Definition at line 826 of file mapinfo.qc.

827{
828 // NOTE: .arena files can hold more than 1 map's information!
829 // to handle this, we're going to store gathered information in local variables and save it if we encounter the correct map name
830 bool in_brackets = false; // testing a potential mapinfo section (within brackets)
831 bool dosave = false;
832 string stored_Map_description = "";
833 string stored_Map_title = "";
834 string stored_Map_author = "";
835 vector stored_supportedGametypes = '0 0 0';
836 int stored_supportedFeatures = 0;
837 int stored_flags = 0;
838 string t, s;
839
840 if (isgenerator)
841 LOG_INFO("Generating ", pFilename, ".mapinfo: analyzing ", arena_filename);
842
843 for (;;)
844 {
845 if (!((s = fgets(fh))))
846 break;
847
848 // catch different sorts of comments
849 if(s == "") // empty lines
850 continue;
851 if(substring(s, 0, 2) == "//") // C++ style
852 continue;
853 if(strstrofs(s, "{", 0) >= 0)
854 {
855 if(in_brackets)
856 return false; // edge case? already in a bracketed section!
857 in_brackets = true;
858 continue;
859 }
860 else if(!in_brackets)
861 {
862 // if we're not inside a bracket, don't process map info
863 continue;
864 }
865 if(strstrofs(s, "}", 0) >= 0)
866 {
867 if(!in_brackets)
868 return false; // no starting bracket! let the mapinfo generation system handle it
869 in_brackets = false;
870 if(dosave)
871 {
872 MapInfo_Map_description = stored_Map_description;
873 if(stored_Map_title != "")
874 MapInfo_Map_title = stored_Map_title;
875 if(stored_Map_author != "") // write the usual "<AUTHOR>" if we have nothing better
876 MapInfo_Map_author = stored_Map_author;
877 // might have .arena AND .defi for the same map so these bitfields are OR'd
878 if(isgenerator)
879 MapInfo_Map_supportedGametypes |= stored_supportedGametypes;
880 else
881 {
882 FOREACH(Gametypes, it.gametype_flags & stored_supportedGametypes,
883 {
884 _MapInfo_Map_ApplyGametype ("", pGametypeToSet, it, true);
885 });
886 }
887 MapInfo_Map_supportedFeatures |= stored_supportedFeatures;
888 MapInfo_Map_flags |= stored_flags;
889 return true; // no need to continue through the file, we have our map!
890 }
891 else
892 {
893 // discard any gathered locals, we're not using the correct map!
894 stored_Map_description = "";
895 stored_Map_title = "";
896 stored_Map_author = "";
897 stored_supportedGametypes = '0 0 0';
898 stored_supportedFeatures = 0;
899 stored_flags = 0;
900 continue;
901 }
902 }
903
904 s = strreplace("\t", " ", s);
905
906 float p = strstrofs(s, "//", 0);
907 if(p >= 0)
908 s = substring(s, 0, p);
909
910 // perform an initial trim to ensure the first argument is properly obtained
911 // remove leading spaces
912 while(substring(s, 0, 1) == " ")
913 s = substring(s, 1, -1);
914
915 t = car(s); s = cdr(s);
916 t = strtolower(t); // apparently some q3 maps use capitalized parameters
917
918 // remove trailing spaces
919 while(substring(t, -1, 1) == " ")
920 t = substring(t, 0, -2);
921
922 // remove trailing spaces
923 while(substring(s, -1, 1) == " ")
924 s = substring(s, 0, -2);
925 // remove leading spaces
926 while(substring(s, 0, 1) == " ")
927 s = substring(s, 1, -1);
928 // limited support of ""
929 // remove trailing and leading " of s
930 if(substring(s, 0, 1) == "\"")
931 {
932 if(substring(s, -1, 1) == "\"")
933 s = substring(s, 1, -2);
934 }
935 if(t == "longname")
936 stored_Map_title = s;
937 else if(t == "author")
938 stored_Map_author = s;
939 else if(t == "type")
940 {
941 // if there is a valid gametype in this .arena file, include it in the menu
942 stored_supportedFeatures |= MAPINFO_FEATURE_WEAPONS;
943 // type in quake 3 holds all the supported gametypes, so we must loop through all of them
944 // TODO: handle support here better to include more Xonotic teamplay modes
945 string types = s;
946 types = strreplace("team", "tdm ft", types);
947 types = strreplace("ffa", "dm lms ka", types);
948 types = strreplace("tourney", "duel", types); // QL used duel so the following check must support it
949 if(strstrofs(types, "duel", 0) < 0 && strstrofs(types, "tdm", 0) >= 0) // larger team map, support additional gametypes!
950 types = cons(types, "ca kh");
951 FOREACH_WORD(types, true,
952 {
953 Gametype f = MapInfo_Type_FromString(it, false, true);
954 if(f)
955 stored_supportedGametypes |= f.gametype_flags;
956 });
957 }
958 else if(t == "style" && isdefi)
959 {
960 // we have a defrag map on our hands, add CTS!
961 // TODO: styles
962 stored_supportedGametypes |= MAPINFO_TYPE_CTS.gametype_flags;
963 }
964 else if(t == "map")
965 {
966 if(strtolower(s) == strtolower(pFilename))
967 dosave = true; // yay, found our map!
968 }
969 else if(t == "quote")
970 stored_Map_description = s;
971 // TODO: fraglimit
972 }
973
974 // if the map wasn't found in the .arena, fall back to generated .mapinfo
975 return false;
976}
string strtolower(string s)
#define FOREACH_WORD(words, cond, body)
Definition iter.qh:33
#define FOREACH(list, cond, body)
Definition iter.qh:19
#define LOG_INFO(...)
Definition log.qh:65
Gametype MapInfo_Type_FromString(string gtype, bool dowarn, bool is_q3compat)
Definition mapinfo.qc:621
vector MapInfo_Map_supportedGametypes
Definition mapinfo.qh:13
int MapInfo_Map_supportedFeatures
Definition mapinfo.qh:14
string MapInfo_Map_title
Definition mapinfo.qh:7
string MapInfo_Map_author
Definition mapinfo.qh:10
const int MAPINFO_FEATURE_WEAPONS
Definition mapinfo.qh:156
int MapInfo_Map_flags
Definition mapinfo.qh:15
string MapInfo_Map_description
Definition mapinfo.qh:9
vector
Definition self.qh:92
ERASEABLE string cons(string a, string b)
Definition string.qh:276

References car(), cdr(), cons(), fgets(), FOREACH, FOREACH_WORD, LOG_INFO, MAPINFO_FEATURE_WEAPONS, MapInfo_Map_author, MapInfo_Map_description, MapInfo_Map_flags, MapInfo_Map_supportedFeatures, MapInfo_Map_supportedGametypes, MapInfo_Map_title, MapInfo_Type_FromString(), strstrofs, strtolower(), substring(), and vector.

Referenced by _MapInfo_Generate(), and MapInfo_Get_ByName_NoFallbacks().

◆ MapInfo_BSPName_ByID()

string MapInfo_BSPName_ByID ( float i)

◆ MapInfo_Cache_Create()

void MapInfo_Cache_Create ( )

Definition at line 53 of file mapinfo.qc.

54{
59}
#define buf_create
ERASEABLE int db_create()
Definition map.qh:25
int _MapInfo_Cache_DB_NameToIndex
Definition mapinfo.qc:40
void MapInfo_Cache_Destroy()
Definition mapinfo.qc:43
int _MapInfo_Cache_Buf_IndexToMapData
Definition mapinfo.qc:41
int _MapInfo_Cache_Active
Definition mapinfo.qc:39

References _MapInfo_Cache_Active, _MapInfo_Cache_Buf_IndexToMapData, _MapInfo_Cache_DB_NameToIndex, buf_create, db_create(), and MapInfo_Cache_Destroy().

Referenced by MapInfo_Cache_Invalidate(), and preMenuInit().

◆ MapInfo_Cache_Destroy()

void MapInfo_Cache_Destroy ( )

◆ MapInfo_Cache_Invalidate()

void MapInfo_Cache_Invalidate ( )

Definition at line 61 of file mapinfo.qc.

62{
64 return;
65
67}
void MapInfo_Cache_Create()
Definition mapinfo.qc:53

References _MapInfo_Cache_Active, and MapInfo_Cache_Create().

Referenced by MapInfo_Enumerate().

◆ MapInfo_CheckMap()

float MapInfo_CheckMap ( string s)

Definition at line 1510 of file mapinfo.qc.

1511{
1512 float r;
1513 r = _MapInfo_CheckMap(s, false);
1515 return r;
1516}
float _MapInfo_CheckMap(string s, bool gametype_only)
Definition mapinfo.qc:1497
void MapInfo_ClearTemps()
Definition mapinfo.qc:1639

References _MapInfo_CheckMap(), and MapInfo_ClearTemps().

Referenced by DoNextMapOverride(), GenericCommand_maplist(), getmaplist(), GotoMap(), Map_Check(), MapList_LoadMap(), MapVote_AddVotable(), MapVote_Suggest(), and ValidateMap().

◆ MapInfo_ClearTemps()

◆ MapInfo_CurrentFeatures()

int MapInfo_CurrentFeatures ( )

Definition at line 1480 of file mapinfo.qc.

1481{
1482 int req = 0;
1483 // TODO: find a better way to check if weapons are required on the map
1484 if(!(cvar("g_instagib") || cvar("g_overkill") || cvar("g_nix") || cvar("g_weaponarena") || !cvar("g_pickup_items") || !cvar("g_melee_only")
1485 || cvar("g_race") || cvar("g_cts") || cvar("g_nexball") || cvar("g_ca") || cvar("g_freezetag") || cvar("g_lms")))
1487 return req;
1488}

References cvar(), and MAPINFO_FEATURE_WEAPONS.

Referenced by _MapInfo_CheckMap(), GameTypeVote_SetGametype(), GenericCommand_maplist(), GotoFirstMap(), InstantAction_LoadMap(), make_mapinfo_Think(), MapInfo_ListAllAllowedMaps(), MapInfo_ListAllowedMaps(), MapVote_Start(), MapVote_Think(), RestoreGame(), spawnfunc(), spawnfunc(), and XonoticMapList_refilter().

◆ MapInfo_CurrentGametype()

◆ MapInfo_Enumerate()

void MapInfo_Enumerate ( )

◆ MapInfo_FilterGametype()

float MapInfo_FilterGametype ( Gametype gametypeFlags,
float features,
float pFlagsRequired,
float pFlagsForbidden,
float pAbortOnGenerate )

◆ MapInfo_FilterString()

void MapInfo_FilterString ( string sf)

Definition at line 213 of file mapinfo.qc.

214{
215 // this function further filters _MapInfo_filtered, which is prepared by MapInfo_FilterGametype by string
216 float i, j;
217 string title;
218
219 for(i = 0, j = -1; i < MapInfo_count; ++i)
220 {
221 if (MapInfo_Get_ByID(i))
222 {
223 // prepare for keyword filter
224 if (MapInfo_Map_title && strstrofs(MapInfo_Map_title, "<TITLE>", 0) == -1)
225 title = MapInfo_Map_title;
226 else
227 title = MapInfo_Map_bspname;
228 // keyword filter
229 if((strstrofs(strtolower(title), strtolower(sf), 0)) >= 0)
230 bufstr_set(_MapInfo_filtered, ++j, bufstr_get(_MapInfo_filtered, i));
231 }
232 }
233 MapInfo_count = j + 1;
235
236 // sometimes the glob isn't sorted nicely, so fix it here...
238}
bool MapInfo_Get_ByID(int i)
Definition mapinfo.qc:275
void _MapInfo_FilterList_swap(float i, float j, entity pass)
Definition mapinfo.qc:161
float _MapInfo_FilterList_cmp(float i, float j, entity pass)
Definition mapinfo.qc:169
float _MapInfo_filtered
Definition mapinfo.qc:154
float MapInfo_count
Definition mapinfo.qh:166
#define NULL
Definition post.qh:14
ERASEABLE void heapsort(int n, swapfunc_t swap, comparefunc_t cmp, entity pass)
Definition sort.qh:9

References _MapInfo_filtered, _MapInfo_FilterList_cmp(), _MapInfo_FilterList_swap(), heapsort(), MapInfo_ClearTemps(), MapInfo_count, MapInfo_Get_ByID(), MapInfo_Map_bspname, MapInfo_Map_title, NULL, strstrofs, and strtolower().

Referenced by XonoticMapList_refilter().

◆ MapInfo_FindName()

float MapInfo_FindName ( string s)

Definition at line 1426 of file mapinfo.qc.

1427{
1428 // if there is exactly one map of prefix s, return it
1429 // if not, return the null string
1430 // note that DP sorts glob results... so I can use a binary search
1431 float l, r, m, cmp;
1432 l = 0;
1433 r = MapInfo_count;
1434 // invariants: r is behind s, l-1 is equal or before
1435 while(l != r)
1436 {
1437 m = floor((l + r) / 2);
1440 if(cmp == 0)
1441 return m; // found and good
1442 if(cmp < 0)
1443 l = m + 1; // l-1 is before s
1444 else
1445 r = m; // behind s
1446 }
1449 // r == l, so: l is behind s, l-1 is before
1450 // SO: if there is any, l is the one with the right prefix
1451 // and l+1 may be one too
1452 if(l == MapInfo_count)
1453 {
1456 return -1; // no MapInfo_FindName_match, behind last item
1457 }
1459 {
1462 return -1; // wrong prefix
1463 }
1464 if(l == MapInfo_count - 1)
1465 return l; // last one, nothing can follow => unique
1467 {
1469 return -1; // ambigous MapInfo_FindName_match
1470 }
1471 return l;
1472}
#define strcasecmp
string MapInfo_FindName_match
Definition mapinfo.qh:195
float MapInfo_FindName_firstResult
Definition mapinfo.qh:196
float floor(float f)
ERASEABLE bool startsWithNocase(string haystack, string needle)
Definition string.qh:239

References _MapInfo_GlobItem(), floor(), MapInfo_count, MapInfo_FilterList_Lookup(), MapInfo_FindName_firstResult, MapInfo_FindName_match, startsWithNocase(), strcasecmp, and string_null.

Referenced by MapInfo_FixName(), XonoticMapList_keyDown(), and XonoticMapList_refilter().

◆ MapInfo_FixName()

string MapInfo_FixName ( string s)

Definition at line 1474 of file mapinfo.qc.

1475{
1478}
float MapInfo_FindName(string s)
Definition mapinfo.qc:1426

References MapInfo_FindName(), and MapInfo_FindName_match.

Referenced by GameTypeVote_MapInfo_FixName(), and ValidateMap().

◆ MapInfo_ForbiddenFlags()

int MapInfo_ForbiddenFlags ( )

Definition at line 1664 of file mapinfo.qc.

1665{
1666 int f = MAPINFO_FLAG_FORBIDDEN;
1667
1668#ifdef GAMEQC
1669 if (!cvar("g_maplist_allow_hidden"))
1670#endif
1672
1673 if (!cvar("g_maplist_allow_frustrating"))
1675
1676 return f;
1677}
const int MAPINFO_FLAG_FORBIDDEN
Definition mapinfo.qh:162
const int MAPINFO_FLAG_HIDDEN
Definition mapinfo.qh:161
const int MAPINFO_FLAG_FRUSTRATING
Definition mapinfo.qh:163

References cvar(), MAPINFO_FLAG_FORBIDDEN, MAPINFO_FLAG_FRUSTRATING, and MAPINFO_FLAG_HIDDEN.

Referenced by GameTypeVote_MapInfo_FixName(), GameTypeVote_SetGametype(), GenericCommand_maplist(), getlsmaps(), GotoFirstMap(), InstantAction_LoadMap(), make_mapinfo_Think(), MapList_Add_All(), Maplist_Init(), MapVote_Start(), MapVote_Think(), RestoreGame(), spawnfunc(), spawnfunc(), and XonoticMapList_refilter().

◆ MapInfo_Get_ByID()

bool MapInfo_Get_ByID ( int i)

Definition at line 275 of file mapinfo.qc.

276{
277 return MapInfo_Get_ByName(MapInfo_BSPName_ByID(i), 0, NULL) ? true : false;
278}
#define true
Definition csprogsdefs.qh:5
string MapInfo_BSPName_ByID(float i)
Definition mapinfo.qc:250
int MapInfo_Get_ByName(string pFilename, float pAllowGenerate, Gametype pGametypeToSet)
Definition mapinfo.qc:1390

References MapInfo_BSPName_ByID(), MapInfo_Get_ByName(), NULL, and true.

Referenced by getladder(), getlsmaps(), MapInfo_FilterString(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), MUTATOR_HOOKFUNCTION(), XonoticMapInfoDialog_loadMapInfo(), and XonoticMapList_drawListBoxItem().

◆ MapInfo_Get_ByName()

int MapInfo_Get_ByName ( string s,
float allowGenerate,
Gametype gametypeToSet )

Definition at line 1390 of file mapinfo.qc.

1391{
1392 int r = MapInfo_Get_ByName_NoFallbacks(pFilename, pAllowGenerate, pGametypeToSet);
1393
1394 FOREACH(Gametypes, it.m_isForcedSupported(it), _MapInfo_Map_ApplyGametypeEx("", pGametypeToSet, it));
1395
1396 if(pGametypeToSet)
1397 {
1398 if(!(MapInfo_Map_supportedGametypes & pGametypeToSet.gametype_flags))
1399 {
1400 error("Can't select the requested gametype. This should never happen as the caller should prevent it!\n");
1401 //_MapInfo_Map_ApplyGametypeEx("", pGametypeToSet, MAPINFO_TYPE_DEATHMATCH);
1402 //return;
1403 }
1404 }
1405
1406 return r;
1407}
void _MapInfo_Map_ApplyGametypeEx(string s, Gametype pWantedType, Gametype pThisType)
Definition mapinfo.qc:544
float MapInfo_Get_ByName_NoFallbacks(string pFilename, int pAllowGenerate, Gametype pGametypeToSet)
Definition mapinfo.qc:1041
#define error
Definition pre.qh:6

References _MapInfo_Map_ApplyGametypeEx(), error, FOREACH, MapInfo_Get_ByName_NoFallbacks(), and MapInfo_Map_supportedGametypes.

Referenced by _MapInfo_CheckMap(), _MapInfo_FilterGametype(), GameTypeVote_AvailabilityStatus(), get_mi_min_max(), MapInfo_Get_ByID(), MapInfo_LoadMapSettings(), and SendWelcomeMessage().

◆ MapInfo_ListAllAllowedMaps()

string MapInfo_ListAllAllowedMaps ( float pFlagsRequired,
float pFlagsForbidden )

Definition at line 1556 of file mapinfo.qc.

1557{
1558 string out;
1559
1560 // to make absolutely sure:
1562 _MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, pRequiredFlags, pForbiddenFlags, 0);
1563
1564 out = "";
1565 for(float i = 0; i < MapInfo_count; ++i)
1567
1568 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), pRequiredFlags, pForbiddenFlags, 0);
1569
1570 return substring(out, 1, strlen(out) - 1);
1571}
#define strlen
float MapInfo_FilterGametype(Gametype pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
Definition mapinfo.qc:177
float _MapInfo_FilterGametype(vector pGametype, int pFeatures, int pFlagsRequired, int pFlagsForbidden, bool pAbortOnGenerate)
Definition mapinfo.qc:181
Gametype MapInfo_CurrentGametype()
Definition mapinfo.qc:1490
int MapInfo_CurrentFeatures()
Definition mapinfo.qc:1480
void MapInfo_Enumerate()
Definition mapinfo.qc:134
vector MAPINFO_TYPE_ALL
Definition mapinfo.qh:27

References _MapInfo_FilterGametype(), _MapInfo_GlobItem(), MapInfo_count, MapInfo_CurrentFeatures(), MapInfo_CurrentGametype(), MapInfo_Enumerate(), MapInfo_FilterGametype(), MapInfo_FilterList_Lookup(), MAPINFO_TYPE_ALL, strcat(), strlen, and substring().

◆ MapInfo_ListAllowedMaps()

string MapInfo_ListAllowedMaps ( Gametype type,
float pFlagsRequired,
float pFlagsForbidden )

Definition at line 1542 of file mapinfo.qc.

1543{
1544 string out;
1545
1546 // to make absolutely sure:
1548 MapInfo_FilterGametype(type, MapInfo_CurrentFeatures(), pRequiredFlags, pForbiddenFlags, 0);
1549
1550 out = "";
1551 for(float i = 0; i < MapInfo_count; ++i)
1553 return substring(out, 1, strlen(out) - 1);
1554}

References _MapInfo_GlobItem(), MapInfo_count, MapInfo_CurrentFeatures(), MapInfo_Enumerate(), MapInfo_FilterGametype(), MapInfo_FilterList_Lookup(), strcat(), strlen, and substring().

Referenced by GameTypeVote_SetGametype(), and Maplist_Init().

◆ MapInfo_LoadMap()

void MapInfo_LoadMap ( string s,
float reinit )

Definition at line 1523 of file mapinfo.qc.

1524{
1526 // we shouldn't need this, as LoadMapSettings already fixes the gametype
1527 //if(!MapInfo_CheckMap(s))
1528 //{
1529 // print("EMERGENCY: can't play the selected map in the given gametype. Falling back to DM.\n");
1530 // MapInfo_SwitchGameType(MAPINFO_TYPE_DEATHMATCH.gametype_flags);
1531 //}
1532
1533 LOG_INFO("Switching to map ", s);
1534
1536 if(reinit)
1537 localcmd(strcat("\nmap ", s, "\n"));
1538 else
1539 localcmd(strcat("\nchangelevel ", s, "\n"));
1540}
int cvar_settemp_restore()
Definition util.qc:851
void localcmd(string command,...)

References cvar_settemp_restore(), localcmd(), LOG_INFO, MapInfo_Map_supportedGametypes, and strcat().

Referenced by CampaignSetup(), InstantAction_LoadMap(), Map_Goto(), and MapList_LoadMap().

◆ MapInfo_LoadMapSettings()

void MapInfo_LoadMapSettings ( string s)

Definition at line 1580 of file mapinfo.qc.

1581{
1584
1585 if(!_MapInfo_CheckMap(s, true)) // with underscore, it keeps temps
1586 {
1587 if(cvar("g_mapinfo_allow_unsupported_modes_and_let_stuff_break"))
1588 {
1589 LOG_SEVERE("can't play the selected map in the given gametype. Working with only the override settings.");
1591 return; // do not call Get_ByName!
1592 }
1593
1594 if(MapInfo_Map_supportedGametypes == '0 0 0')
1595 {
1597 FOREACH(Gametypes, it.m_priority == 2,
1598 {
1599 MapInfo_Map_supportedGametypes |= it.gametype_flags;
1600 RandomSelection_AddEnt(it, 1, 1);
1601 });
1604 LOG_SEVEREF("Mapinfo system is not functional at all. Falling back to a preferred mode (%s).", t.mdl);
1607 return; // do not call Get_ByName!
1608 }
1609
1610#if 0
1611 // find the lowest bit in the supported gametypes
1612 // unnecessary now that we select one at random
1613 int _t = 1;
1614 while(!(MapInfo_Map_supportedGametypes & 1))
1615 {
1616 _t <<= 1;
1618 }
1619#endif
1621 Gametype t_prev = t;
1622 FOREACH(Gametypes, MapInfo_Map_supportedGametypes & it.gametype_flags,
1623 {
1624 RandomSelection_AddEnt(it, 1, it.m_priority);
1625 });
1628
1629 // t is now a supported mode!
1630 LOG_WARNF("can't play the selected map in the given gametype (%s). Falling back to a supported mode (%s).", t_prev.mdl, t.mdl);
1632 }
1633 if(!_MapInfo_CheckMap(s, false)) { // with underscore, it keeps temps
1634 LOG_WARNF("the selected map lacks features required by current settings; playing anyway.");
1635 }
1636 MapInfo_Get_ByName(s, 1, t);
1637}
#define LOG_WARNF(...)
Definition log.qh:62
#define LOG_SEVEREF(...)
Definition log.qh:58
#define LOG_SEVERE(...)
Definition log.qh:57
void MapInfo_LoadMapSettings_SaveGameType(Gametype t)
Definition mapinfo.qc:1573
ERASEABLE void RandomSelection_Init()
Definition random.qc:4
entity RandomSelection_chosen_ent
Definition random.qh:5

References _MapInfo_CheckMap(), _MapInfo_Map_ApplyGametypeEx(), cvar(), floor(), FOREACH, LOG_SEVERE, LOG_SEVEREF, LOG_WARNF, MapInfo_CurrentGametype(), MapInfo_Get_ByName(), MapInfo_LoadMapSettings_SaveGameType(), MapInfo_Map_supportedGametypes, RandomSelection_chosen_ent, and RandomSelection_Init().

Referenced by InitGameplayMode().

◆ MapInfo_RequiredFlags()

int MapInfo_RequiredFlags ( )

◆ MapInfo_Shutdown()

◆ MapInfo_SwitchGameType()

void MapInfo_SwitchGameType ( Gametype t)

Definition at line 1518 of file mapinfo.qc.

1519{
1520 FOREACH(Gametypes, true, cvar_set(it.netname, (it == t) ? "1" : "0"));
1521}

References cvar_set(), and FOREACH.

Referenced by CampaignPreInit(), GameTypeVote_SetGametype(), InstantAction_LoadMap(), MapInfo_LoadMapSettings_SaveGameType(), target_changelevel_use(), and XonoticGametypeList_saveCvars().

◆ MapInfo_Type_Description()

string MapInfo_Type_Description ( Gametype t)

Definition at line 651 of file mapinfo.qc.

652{
653 return t ? t.m_description : "";
654}

Referenced by GameTypeVote_ReadOption(), and XonoticGametypeList_focusedItemChangeNotify().

◆ MapInfo_Type_FromString()

Gametype MapInfo_Type_FromString ( string t,
bool dowarn,
bool is_q3compat )

Definition at line 621 of file mapinfo.qc.

622{
623 string replacement = "";
624
625 switch (gtype)
626 {
627 case "nexball": replacement = "nb"; break;
628 case "freezetag": replacement = "ft"; break;
629 case "keepaway": replacement = "ka"; break;
630 case "invasion": replacement = "inv"; break;
631 case "assault": replacement = "as"; break;
632 case "race": replacement = "rc"; break;
633 // Q3/QL compat, see DoesQ3ARemoveThisEntity() in quake3.qc for complete lists
634 case "ffa": replacement = "dm"; break;
635 case "cctf": // from ThreeWave, maps with this should all have "ctf" too
636 case "oneflag": replacement = "ctf"; break;
637 case "tourney": replacement = "duel"; break;
638 case "arena": // which Q3 mod is this from? In Nexuiz it was 'duel with rounds'.
639 if(is_q3compat) { replacement = "ca"; } break;
640 }
641 if (replacement != "")
642 {
643 if (dowarn && WARN_COND)
644 LOG_WARNF("MapInfo_Type_FromString (probably %s): using deprecated name '%s'. Should use '%s'.", MapInfo_Map_bspname, gtype, replacement);
645 gtype = replacement;
646 }
647 FOREACH(Gametypes, it.mdl == gtype, return it);
648 return NULL;
649}

References FOREACH, LOG_WARNF, MapInfo_Map_bspname, NULL, and WARN_COND.

Referenced by _MapInfo_ParseArena(), Campaign_Invalid(), CampaignPreInit(), GameCommand_gametype(), GameTypeVote_AvailabilityStatus(), GameTypeVote_ReadOption(), GameTypeVote_Type_FromString(), MapInfo_CurrentGametype(), MapInfo_Get_ByName_NoFallbacks(), target_changelevel_use(), and XonoticServerInfoDialog_loadServerInfo().

◆ MapInfo_Type_ToString()

◆ MapInfo_Type_ToText()

◆ MapReadSizes()

bool MapReadSizes ( string map)

Definition at line 1409 of file mapinfo.qc.

1410{
1411 // TODO: implement xonotic#28 / xonvote 172 (sizes in mapinfo)
1412 string readsize_msg = strcat("MapReadSizes ", map);
1413 float fh = fopen(strcat("maps/", map, ".sizes"), FILE_READ);
1414 if(fh >= 0)
1415 {
1416 map_minplayers = stoi(fgets(fh));
1417 map_maxplayers = stoi(fgets(fh));
1418 fclose(fh);
1419 LOG_TRACEF(readsize_msg, ": ok, min %d max %d", map_minplayers, map_maxplayers);
1420 return true;
1421 }
1422 LOG_TRACE(readsize_msg, ": not found");
1423 return false;
1424}
#define stoi(s)
Definition int.qh:4
#define LOG_TRACEF(...)
Definition log.qh:77
int map_minplayers
Definition mapinfo.qh:190
int map_maxplayers
Definition mapinfo.qh:191

References fclose(), fgets(), FILE_READ, fopen(), LOG_TRACE, LOG_TRACEF, map_maxplayers, map_minplayers, stoi, and strcat().

Referenced by GameplayMode_DelayedInit(), and MapHasRightSize().

◆ STATIC_INIT()

STATIC_INIT ( Gametypes_renumber )

Definition at line 140 of file mapinfo.qh.

141{
142 FOREACH(Gametypes, true,
143 {
144 it.m_id = i;
145 vector set = it.gametype_flags = _GametypeFlags_FromGametype(it.m_id);
146 MAPINFO_TYPE_ALL |= set;
147 });
148}
vector _GametypeFlags_FromGametype(int a)
Definition mapinfo.qc:20

References _GametypeFlags_FromGametype(), FOREACH, MAPINFO_TYPE_ALL, STATIC_INIT, and vector.

Variable Documentation

◆ GAMETYPE_FLAG_1V1

const int GAMETYPE_FLAG_1V1 = BIT(6)

Definition at line 25 of file mapinfo.qh.

Referenced by Duel::Duel(), and Gametype::gametype_init().

◆ GAMETYPE_FLAG_HIDELIMITS

const int GAMETYPE_FLAG_HIDELIMITS = BIT(4)

Definition at line 23 of file mapinfo.qh.

Referenced by LastManStanding::LastManStanding(), and Gametype::gametype_init().

◆ GAMETYPE_FLAG_PREFERRED

const int GAMETYPE_FLAG_PREFERRED = BIT(2)

Definition at line 21 of file mapinfo.qh.

Referenced by Deathmatch::Deathmatch(), and Gametype::gametype_init().

◆ GAMETYPE_FLAG_PRIORITY

const int GAMETYPE_FLAG_PRIORITY = BIT(3)

◆ GAMETYPE_FLAG_TEAMPLAY

◆ GAMETYPE_FLAG_USEPOINTS

◆ GAMETYPE_FLAG_WEAPONARENA

const int GAMETYPE_FLAG_WEAPONARENA = BIT(5)

Definition at line 24 of file mapinfo.qh.

Referenced by NexBall::NexBall(), and Gametype::gametype_init().

◆ gametype_flags

◆ map_maxplayers

int map_maxplayers

◆ map_minplayers

int map_minplayers

◆ MapInfo_count

◆ MAPINFO_FEATURE_MONSTERS

const int MAPINFO_FEATURE_MONSTERS = 8

Definition at line 159 of file mapinfo.qh.

Referenced by _MapInfo_Generate(), and MapInfo_Get_ByName_NoFallbacks().

◆ MAPINFO_FEATURE_TURRETS

const int MAPINFO_FEATURE_TURRETS = 4

Definition at line 158 of file mapinfo.qh.

Referenced by _MapInfo_Generate(), and MapInfo_Get_ByName_NoFallbacks().

◆ MAPINFO_FEATURE_VEHICLES

const int MAPINFO_FEATURE_VEHICLES = 2

Definition at line 157 of file mapinfo.qh.

Referenced by _MapInfo_Generate(), and MapInfo_Get_ByName_NoFallbacks().

◆ MAPINFO_FEATURE_WEAPONS

const int MAPINFO_FEATURE_WEAPONS = 1

◆ MapInfo_FindName_firstResult

float MapInfo_FindName_firstResult

Definition at line 196 of file mapinfo.qh.

Referenced by MapInfo_FindName(), and XonoticMapList_keyDown().

◆ MapInfo_FindName_match

string MapInfo_FindName_match

Definition at line 195 of file mapinfo.qh.

Referenced by MapInfo_FindName(), and MapInfo_FixName().

◆ MAPINFO_FLAG_DONOTWANT

const int MAPINFO_FLAG_DONOTWANT = 8

Definition at line 164 of file mapinfo.qh.

Referenced by Map_Check(), and MapInfo_Get_ByName_NoFallbacks().

◆ MAPINFO_FLAG_FORBIDDEN

const int MAPINFO_FLAG_FORBIDDEN = 2

Definition at line 162 of file mapinfo.qh.

Referenced by MapInfo_ForbiddenFlags(), and MapInfo_Get_ByName_NoFallbacks().

◆ MAPINFO_FLAG_FRUSTRATING

const int MAPINFO_FLAG_FRUSTRATING = 4

◆ MAPINFO_FLAG_HIDDEN

const int MAPINFO_FLAG_HIDDEN = 1

Definition at line 161 of file mapinfo.qh.

Referenced by MapInfo_ForbiddenFlags(), and MapInfo_Get_ByName_NoFallbacks().

◆ MapInfo_LoadedGametype

◆ MapInfo_Map_author

◆ MapInfo_Map_bspname

◆ MapInfo_Map_clientstuff

◆ MapInfo_Map_description

◆ MapInfo_Map_flags

◆ MapInfo_Map_fog

string MapInfo_Map_fog

Definition at line 12 of file mapinfo.qh.

Referenced by _MapInfo_Map_Reset(), InitGameplayMode(), and MapInfo_Get_ByName_NoFallbacks().

◆ MapInfo_Map_maxs

vector MapInfo_Map_maxs

Definition at line 17 of file mapinfo.qh.

Referenced by _MapInfo_Map_Reset(), get_mi_min_max(), and MapInfo_Get_ByName_NoFallbacks().

◆ MapInfo_Map_mins

vector MapInfo_Map_mins

Definition at line 16 of file mapinfo.qh.

Referenced by _MapInfo_Map_Reset(), get_mi_min_max(), and MapInfo_Get_ByName_NoFallbacks().

◆ MapInfo_Map_supportedFeatures

◆ MapInfo_Map_supportedGametypes

◆ MapInfo_Map_title

◆ MapInfo_Map_titlestring

◆ MapInfo_progress

float MapInfo_progress

Definition at line 173 of file mapinfo.qh.

Referenced by _MapInfo_FilterGametype(), and preMenuInit().

◆ MAPINFO_TYPE_ALL