X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmapinfo.qc;h=469c86a2b68f18822121160a4cea454e0540099e;hb=68eeed9d509bed4b50e81f5995065322e23634fa;hp=35a827f90035438c33b7a6ce60b25d19e5629008;hpb=ee1bc52fd8269edac22ce73ddecc88583fa1d623;p=xonotic%2Fxonotic-data.pk3dir.git
diff --git a/qcsrc/common/mapinfo.qc b/qcsrc/common/mapinfo.qc
index 35a827f90..469c86a2b 100644
--- a/qcsrc/common/mapinfo.qc
+++ b/qcsrc/common/mapinfo.qc
@@ -49,6 +49,7 @@ void MapInfo_Cache_Store()
// now store all the stuff
bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, i, MapInfo_Map_bspname);
bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, MapInfo_Map_title);
+ bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, MapInfo_Map_titlestring);
bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, MapInfo_Map_description);
bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, MapInfo_Map_author);
bufstr_set(_MapInfo_Cache_Buf_IndexToMapData, ++i, ftos(MapInfo_Map_supportedGametypes));
@@ -71,6 +72,7 @@ float MapInfo_Cache_Retrieve(string map)
// now retrieve all the stuff
MapInfo_Map_bspname = bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, i);
MapInfo_Map_title = bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i);
+ MapInfo_Map_titlestring = bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i);
MapInfo_Map_description = bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i);
MapInfo_Map_author = bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i);
MapInfo_Map_supportedGametypes = stof(bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i));
@@ -379,6 +381,7 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp
void _MapInfo_Map_Reset()
{
MapInfo_Map_title = "
";
+ MapInfo_Map_titlestring = "";
MapInfo_Map_description = "";
MapInfo_Map_author = "";
MapInfo_Map_supportedGametypes = 0;
@@ -409,7 +412,10 @@ string _MapInfo_GetDefault(float t)
case MAPINFO_TYPE_NEXBALL: return "5 20 0";
case MAPINFO_TYPE_CTS: return "20 0 0";
case MAPINFO_TYPE_FREEZETAG: return "10 20 0";
- case MAPINFO_TYPE_KEEPAWAY: return "30 20 0";
+ // NOTE: DO NOT ADD ANY MORE GAME TYPES HERE
+ // THIS IS JUST LEGACY SUPPORT FOR NEXUIZ MAPS
+ // ONLY ADD NEW STUFF TO _MapInfo_GetDefaultEx
+ // THIS FUNCTION WILL EVENTUALLY BE REMOVED
default: return "";
}
}
@@ -466,6 +472,7 @@ void _MapInfo_Map_ApplyGametype(string s, float pWantedType, float pThisType, fl
s = cdr(s);
}
+ /* keepaway wuz here
if(pWantedType == MAPINFO_TYPE_KEEPAWAY)
{
sa = car(s);
@@ -473,7 +480,8 @@ void _MapInfo_Map_ApplyGametype(string s, float pWantedType, float pThisType, fl
cvar_set("fraglimit", sa);
s = cdr(s);
}
-
+ */
+
// rc = timelimit timelimit_qualification laps laps_teamplay
if(pWantedType == MAPINFO_TYPE_RACE)
{
@@ -792,12 +800,37 @@ void _MapInfo_Parse_Settemp(string pFilename, string acl, float type, string s,
}
}
+float MapInfo_isRedundant(string fn, string t)
+{
+ // normalize file name
+ fn = strreplace("_", "-", fn);
+
+ // normalize visible title
+ t = strreplace(": ", "-", t);
+ t = strreplace(":", "-", t);
+ t = strreplace(" ", "-", t);
+ t = strreplace("_", "-", t);
+ t = strreplace("'", "-", t);
+
+ if(!strcasecmp(fn, t))
+ return TRUE;
+
+ // we allow the visible title to have punctuation the file name does
+ // not, but not vice versa
+ t = strreplace("-", "", t);
+
+ if(!strcasecmp(fn, t))
+ return TRUE;
+
+ return FALSE;
+}
+
// load info about a map by name into the MapInfo_Map_* globals
float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametypeToSet)
{
string fn;
string s, t;
- float fh, fh2;
+ float fh;
float r, f, n, i, p;
string acl;
@@ -870,12 +903,8 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype
if(MapInfo_Map_supportedGametypes & i)
fputs(fh, sprintf("gametype %s // defaults: %s\n", MapInfo_Type_ToString(i), _MapInfo_GetDefaultEx(i)));
- fh2 = fopen(strcat("scripts/", pFilename, ".arena"), FILE_READ);
- if(fh2 >= 0)
- {
- fclose(fh2);
+ if(fexists(strcat("scripts/", pFilename, ".arena")))
fputs(fh, "settemp_for_type all sv_q3acompat_machineshotgunswap 1\n");
- }
fputs(fh, "// optional: fog density red green blue alpha mindist maxdist\n");
fputs(fh, "// optional: settemp_for_type (all|gametypename) cvarname value\n");
@@ -945,6 +974,7 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype
{
t = car(s); s = cdr(s);
f = MapInfo_Type_FromString(t);
+ print("Map ", pFilename, " contains the legacy 'type' keyword which is deprecated and will be removed in the future. Please migrate the mapinfo file to 'gametype'.\n");
if(f)
_MapInfo_Map_ApplyGametype (s, pGametypeToSet, f, TRUE);
else
@@ -1054,6 +1084,13 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype
}
}
+ if(MapInfo_Map_title == "")
+ MapInfo_Map_titlestring = MapInfo_Map_bspname;
+ else if(MapInfo_isRedundant(MapInfo_Map_bspname, MapInfo_Map_title))
+ MapInfo_Map_titlestring = MapInfo_Map_title;
+ else
+ MapInfo_Map_titlestring = sprintf(_("%s: %s"), MapInfo_Map_bspname, MapInfo_Map_title);
+
MapInfo_Cache_Store();
if(MapInfo_Map_supportedGametypes != 0)
return r;
@@ -1251,6 +1288,24 @@ string MapInfo_ListAllowedMaps(float pRequiredFlags, float pForbiddenFlags)
return substring(out, 1, strlen(out) - 1);
}
+string MapInfo_ListAllAllowedMaps(float pRequiredFlags, float pForbiddenFlags)
+{
+ string out;
+ float i;
+
+ // to make absolutely sure:
+ MapInfo_Enumerate();
+ MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0, pRequiredFlags, pForbiddenFlags, 0);
+
+ out = "";
+ for(i = 0; i < MapInfo_count; ++i)
+ out = strcat(out, " ", _MapInfo_GlobItem(MapInfo_FilterList_Lookup(i)));
+
+ MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), pRequiredFlags, pForbiddenFlags, 0);
+
+ return substring(out, 1, strlen(out) - 1);
+}
+
void MapInfo_LoadMapSettings(string s) // to be called from worldspawn
{
float t, t0;
@@ -1293,6 +1348,7 @@ void MapInfo_ClearTemps()
{
MapInfo_Map_bspname = string_null;
MapInfo_Map_title = string_null;
+ MapInfo_Map_titlestring = string_null;
MapInfo_Map_description = string_null;
MapInfo_Map_author = string_null;
MapInfo_Map_clientstuff = string_null;