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 1003 of file mapinfo.qc.

1004{
1005 // A valid arena file with the "default" name may have been created as a map-specific
1006 // override of an arena file with a different name (possibly multi-map) in the pk3
1007 // (occasionally in the wild such file exists in the pk3 but isn't valid for a map in the pk3).
1008 // Therefore we try the "default" name first.
1009 string afile = _MapInfo_CheckArenaFile(strcat("scripts/", pFilename, extension), pFilename);
1010 if (afile != ""
1011 || !checkextension("DP_QC_FS_SEARCH_PACKFILE"))
1012 return afile;
1013
1014 string base_pack = whichpack(strcat("maps/", pFilename, ".bsp"));
1015 if(base_pack == "") // this map isn't packaged!
1016 return "";
1017 int glob = search_packfile_begin(strcat("scripts/*", extension), true, true, base_pack);
1018 if(glob < 0) // there's no matching file in the pack
1019 return "";
1020 int n = search_getsize(glob);
1021 for(int j = 0; j < n; ++j)
1022 {
1023 afile = search_getfilename(glob, j);
1024 if(_MapInfo_CheckArenaFile(afile, pFilename) != "")
1025 {
1026 search_end(glob);
1027 return afile;
1028 }
1029 }
1030 search_end(glob);
1031
1032 return ""; // if we get here, a valid .arena file could not be found
1033}
string _MapInfo_CheckArenaFile(string pFilename, string pMapname)
Definition mapinfo.qc:973
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 cvar_settemp(t, s);
760 }
761 else
762 {
763 LOG_TRACE("Applying temporary client setting ", t, " := ", s);
765 MapInfo_Map_clientstuff, "cl_cmd settemp \"", t, "\" \"", s, "\"\n"
766 );
767 }
768 }
769}
float matchacl(string acl, string str)
Definition util.qc:1445
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
string fgets(float fhandle)
void fclose(float fhandle)
string substring(string s, float start, float length)
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_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 821 of file mapinfo.qc.

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

1506{
1507 float r;
1508 r = _MapInfo_CheckMap(s, false);
1510 return r;
1511}
float _MapInfo_CheckMap(string s, bool gametype_only)
Definition mapinfo.qc:1492
void MapInfo_ClearTemps()
Definition mapinfo.qc:1634

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 1475 of file mapinfo.qc.

1476{
1477 int req = 0;
1478 // TODO: find a better way to check if weapons are required on the map
1479 if(!(cvar("g_instagib") || cvar("g_overkill") || cvar("g_nix") || cvar("g_weaponarena") || !cvar("g_pickup_items") || !cvar("g_melee_only")
1480 || cvar("g_race") || cvar("g_cts") || cvar("g_nexball") || cvar("g_ca") || cvar("g_freezetag") || cvar("g_lms")))
1482 return req;
1483}
float cvar(string name)

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 1421 of file mapinfo.qc.

1422{
1423 // if there is exactly one map of prefix s, return it
1424 // if not, return the null string
1425 // note that DP sorts glob results... so I can use a binary search
1426 float l, r, m, cmp;
1427 l = 0;
1428 r = MapInfo_count;
1429 // invariants: r is behind s, l-1 is equal or before
1430 while(l != r)
1431 {
1432 m = floor((l + r) / 2);
1435 if(cmp == 0)
1436 return m; // found and good
1437 if(cmp < 0)
1438 l = m + 1; // l-1 is before s
1439 else
1440 r = m; // behind s
1441 }
1444 // r == l, so: l is behind s, l-1 is before
1445 // SO: if there is any, l is the one with the right prefix
1446 // and l+1 may be one too
1447 if(l == MapInfo_count)
1448 {
1451 return -1; // no MapInfo_FindName_match, behind last item
1452 }
1454 {
1457 return -1; // wrong prefix
1458 }
1459 if(l == MapInfo_count - 1)
1460 return l; // last one, nothing can follow => unique
1462 {
1464 return -1; // ambigous MapInfo_FindName_match
1465 }
1466 return l;
1467}
#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 1469 of file mapinfo.qc.

1470{
1473}
float MapInfo_FindName(string s)
Definition mapinfo.qc:1421

References MapInfo_FindName(), and MapInfo_FindName_match.

Referenced by GameTypeVote_MapInfo_FixName(), and ValidateMap().

◆ MapInfo_ForbiddenFlags()

int MapInfo_ForbiddenFlags ( )

Definition at line 1659 of file mapinfo.qc.

1660{
1661 int f = MAPINFO_FLAG_FORBIDDEN;
1662
1663#ifdef GAMEQC
1664 if (!cvar("g_maplist_allow_hidden"))
1665#endif
1667
1668 if (!cvar("g_maplist_allow_frustrating"))
1670
1671 return f;
1672}
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:1385

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 1385 of file mapinfo.qc.

1386{
1387 int r = MapInfo_Get_ByName_NoFallbacks(pFilename, pAllowGenerate, pGametypeToSet);
1388
1389 FOREACH(Gametypes, it.m_isForcedSupported(it), _MapInfo_Map_ApplyGametypeEx("", pGametypeToSet, it));
1390
1391 if(pGametypeToSet)
1392 {
1393 if(!(MapInfo_Map_supportedGametypes & pGametypeToSet.gametype_flags))
1394 {
1395 error("Can't select the requested gametype. This should never happen as the caller should prevent it!\n");
1396 //_MapInfo_Map_ApplyGametypeEx("", pGametypeToSet, MAPINFO_TYPE_DEATHMATCH);
1397 //return;
1398 }
1399 }
1400
1401 return r;
1402}
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:1036
#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 1551 of file mapinfo.qc.

1552{
1553 string out;
1554
1555 // to make absolutely sure:
1557 _MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, pRequiredFlags, pForbiddenFlags, 0);
1558
1559 out = "";
1560 for(float i = 0; i < MapInfo_count; ++i)
1562
1563 MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), pRequiredFlags, pForbiddenFlags, 0);
1564
1565 return substring(out, 1, strlen(out) - 1);
1566}
#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:1485
int MapInfo_CurrentFeatures()
Definition mapinfo.qc:1475
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 1537 of file mapinfo.qc.

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

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 1518 of file mapinfo.qc.

1519{
1521 // we shouldn't need this, as LoadMapSettings already fixes the gametype
1522 //if(!MapInfo_CheckMap(s))
1523 //{
1524 // print("EMERGENCY: can't play the selected map in the given gametype. Falling back to DM.\n");
1525 // MapInfo_SwitchGameType(MAPINFO_TYPE_DEATHMATCH.gametype_flags);
1526 //}
1527
1528 LOG_INFO("Switching to map ", s);
1529
1531 if(reinit)
1532 localcmd(strcat("\nmap ", s, "\n"));
1533 else
1534 localcmd(strcat("\nchangelevel ", s, "\n"));
1535}
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 1575 of file mapinfo.qc.

1576{
1579
1580 if(!_MapInfo_CheckMap(s, true)) // with underscore, it keeps temps
1581 {
1582 if(cvar("g_mapinfo_allow_unsupported_modes_and_let_stuff_break"))
1583 {
1584 LOG_SEVERE("can't play the selected map in the given gametype. Working with only the override settings.");
1586 return; // do not call Get_ByName!
1587 }
1588
1589 if(MapInfo_Map_supportedGametypes == '0 0 0')
1590 {
1592 FOREACH(Gametypes, it.m_priority == 2,
1593 {
1594 MapInfo_Map_supportedGametypes |= it.gametype_flags;
1595 RandomSelection_AddEnt(it, 1, 1);
1596 });
1599 LOG_SEVEREF("Mapinfo system is not functional at all. Falling back to a preferred mode (%s).", t.mdl);
1602 return; // do not call Get_ByName!
1603 }
1604
1605#if 0
1606 // find the lowest bit in the supported gametypes
1607 // unnecessary now that we select one at random
1608 int _t = 1;
1609 while(!(MapInfo_Map_supportedGametypes & 1))
1610 {
1611 _t <<= 1;
1613 }
1614#endif
1616 Gametype t_prev = t;
1617 FOREACH(Gametypes, MapInfo_Map_supportedGametypes & it.gametype_flags,
1618 {
1619 RandomSelection_AddEnt(it, 1, it.m_priority);
1620 });
1623
1624 // t is now a supported mode!
1625 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);
1627 }
1628 if(!_MapInfo_CheckMap(s, false)) { // with underscore, it keeps temps
1629 LOG_WARNF("the selected map lacks features required by current settings; playing anyway.");
1630 }
1631 MapInfo_Get_ByName(s, 1, t);
1632}
#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:1568
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 1513 of file mapinfo.qc.

1514{
1515 FOREACH(Gametypes, true, cvar_set(it.netname, (it == t) ? "1" : "0"));
1516}
void cvar_set(string name, string value)

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 1404 of file mapinfo.qc.

1405{
1406 // TODO: implement xonotic#28 / xonvote 172 (sizes in mapinfo)
1407 string readsize_msg = strcat("MapReadSizes ", map);
1408 float fh = fopen(strcat("maps/", map, ".sizes"), FILE_READ);
1409 if(fh >= 0)
1410 {
1411 map_minplayers = stoi(fgets(fh));
1412 map_maxplayers = stoi(fgets(fh));
1413 fclose(fh);
1414 LOG_TRACEF(readsize_msg, ": ok, min %d max %d", map_minplayers, map_maxplayers);
1415 return true;
1416 }
1417 LOG_TRACE(readsize_msg, ": not found");
1418 return false;
1419}
#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