]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mapinfo.qc
func_door: fix erratic behaviour of spawned trigger field
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mapinfo.qc
index f102cce87ab41247ac33fbf531a7c261fda18642..82a7e758413de31ffd73eae094b93717c67fb678 100644 (file)
@@ -273,6 +273,7 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp
        float r;
        float diameter, spawnpoints;
        float spawnplaces;
+       bool is_q3df_map = false;
 
        vector mapMins, mapMaxs;
 
@@ -341,7 +342,7 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp
                                _MapInfo_Map_worldspawn_music = v;
                        else if(k == "noise")
                                _MapInfo_Map_worldspawn_music = v;
-                       else if(k == "message")
+                       else if(k == "message" && (!MapInfo_Map_title || MapInfo_Map_title == "<TITLE>"))
                        {
                                i = strstrofs(v, " by ", 0);
                                if(MapInfo_Map_author == "<AUTHOR>" && i >= 0)
@@ -394,6 +395,8 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp
                                        MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_MONSTERS;
                                else if(v == "target_music" || v == "trigger_music")
                                        _MapInfo_Map_worldspawn_music = string_null; // don't use regular BGM
+                               else if(v == "target_stopTimer")
+                                       is_q3df_map = true; // don't support standard gamemodes
                                else
                                        FOREACH(Gametypes, true, it.m_generate_mapinfo(it, v));
                        }
@@ -412,7 +415,7 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp
        {
                // we have a symmetrical map, don't add the modes without bases
        }
-       else
+       else if(!is_q3df_map)
        {
                FOREACH(Gametypes, it.m_isAlwaysSupported(it, spawnpoints, diameter), MapInfo_Map_supportedGametypes |= it.m_flags);
        }
@@ -900,8 +903,10 @@ bool _MapInfo_ParseArena(string arena_filename, int fh, string pFilename, Gamety
                        stored_supportedFeatures |= MAPINFO_FEATURE_WEAPONS;
                        // type in quake 3 holds all the supported gametypes, so we must loop through all of them
                        // TODO: handle support here better to include more Xonotic teamplay modes
-                       string types = strreplace("team", "tdm ft", s);
-                       if(strstrofs(s, "tournament", 0) < 0 && strstrofs(s, "tdm", 0) >= 0) // larger team map, support additional gamemodes!
+                       string types = s;
+                       types = strreplace("team", "tdm ft", types);
+                       types = strreplace("ffa", "dm lms ka", types);
+                       if(strstrofs(types, "tournament", 0) < 0 && strstrofs(types, "tdm", 0) >= 0) // larger team map, support additional gamemodes!
                                types = cons(types, "ca kh");
                        FOREACH_WORD(types, true,
                        {
@@ -930,9 +935,6 @@ bool _MapInfo_ParseArena(string arena_filename, int fh, string pFilename, Gamety
        return false;
 }
 
-#if defined(CSQC) || defined(MENUQC)
-string(string filename) whichpack = #503;
-#endif
 string _MapInfo_CheckArenaFile(string pFilename, string pMapname)
 {
        // returns the file name if valid, otherwise returns ""
@@ -1021,13 +1023,16 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, int pAllowGenerate, Gamet
        fh = fopen(fn, FILE_READ);
        if(fh < 0)
        {
-               if(autocvar_g_mapinfo_q3compat == 1) // use arena data instead of generating a mapinfo file
+               if(autocvar_g_mapinfo_q3compat) // use arena data instead of generating a mapinfo file
                {
                        bool isdefi = false;
-                       fn = _MapInfo_FindArenaFile(pFilename, ".arena");
-                       if(fn != "")
-                               fh = fopen(fn, FILE_READ);
-                       if(fh < 0)
+                       if(autocvar_g_mapinfo_q3compat == 1) // only parse .arena files in mode 1
+                       {
+                               fn = _MapInfo_FindArenaFile(pFilename, ".arena");
+                               if(fn != "")
+                                       fh = fopen(fn, FILE_READ);
+                       }
+                       if(fh < 0 || autocvar_g_mapinfo_q3compat == 2)
                        {
                                isdefi = true;
                                fn = _MapInfo_FindArenaFile(pFilename, ".defi");
@@ -1336,6 +1341,23 @@ int MapInfo_Get_ByName(string pFilename, float pAllowGenerate, Gametype pGametyp
        return r;
 }
 
+bool MapReadSizes(string map)
+{
+       // TODO: implement xonotic#28 / xonvote 172 (sizes in mapinfo)
+       string readsize_msg = strcat("MapReadSizes ", map);
+       float fh = fopen(strcat("maps/", map, ".sizes"), FILE_READ);
+       if(fh >= 0)
+       {
+               map_minplayers = stoi(fgets(fh));
+               map_maxplayers = stoi(fgets(fh));
+               fclose(fh);
+               LOG_TRACEF(readsize_msg, ": ok, min %d max %d", map_minplayers, map_maxplayers);
+               return true;
+       }
+       LOG_TRACE(readsize_msg, ": not found");
+       return false;
+}
+
 float MapInfo_FindName(string s)
 {
        // if there is exactly one map of prefix s, return it