]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mapinfo.qc
Merge remote-tracking branch 'origin/mrbougo/quickfix-mapinfo_gen_typo', fixes #1756
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mapinfo.qc
index 05c93865dbcceed7c2606d9cb567b727e3fe8ad7..aa906d68418999f3c01518d5ba2546bd2e66c6c5 100644 (file)
@@ -38,7 +38,7 @@ void MapInfo_Cache_Store()
                return;
 
        s = db_get(_MapInfo_Cache_DB_NameToIndex, MapInfo_Map_bspname);
-       if(!s) // empty string is NOT valid here!
+       if(s == "")
        {
                i = buf_getsize(_MapInfo_Cache_Buf_IndexToMapData);
                db_put(_MapInfo_Cache_DB_NameToIndex, MapInfo_Map_bspname, ftos(i));
@@ -65,7 +65,7 @@ float MapInfo_Cache_Retrieve(string map)
                return 0;
 
        s = db_get(_MapInfo_Cache_DB_NameToIndex, map);
-       if(!s)
+       if(s == "")
                return 0;
        i = stof(s);
 
@@ -89,6 +89,8 @@ float _MapInfo_globhandle;
 string _MapInfo_GlobItem(float i)
 {
        string s;
+       if(!_MapInfo_globopen)
+               return string_null;
        s = search_getfilename(_MapInfo_globhandle, i);
        return substring(s, 5, strlen(s) - 9); // without maps/ and .bsp
 }
@@ -96,11 +98,19 @@ string _MapInfo_GlobItem(float i)
 void MapInfo_Enumerate()
 {
        if(_MapInfo_globopen)
+       {
                search_end(_MapInfo_globhandle);
+               _MapInfo_globopen = 0;
+       }
        MapInfo_Cache_Invalidate();
        _MapInfo_globhandle = search_begin("maps/*.bsp", TRUE, TRUE);
-       _MapInfo_globcount = search_getsize(_MapInfo_globhandle);
-       _MapInfo_globopen = 1;
+       if(_MapInfo_globhandle >= 0)
+       {
+               _MapInfo_globcount = search_getsize(_MapInfo_globhandle);
+               _MapInfo_globopen = 1;
+       }
+       else
+               _MapInfo_globcount = 0;
 }
 
 // filter the info by game type mask (updates MapInfo_count)
@@ -303,8 +313,6 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp
                                        MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CTF;
                                else if(v == "team_CTF_blueflag")
                                        MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CTF;
-                               else if(v == "runematch_spawn_point")
-                                       MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_RUNEMATCH;
                                else if(v == "target_assault_roundend")
                                        MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_ASSAULT;
                                else if(v == "onslaught_generator")
@@ -354,7 +362,6 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp
        else
        {
                MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_DEATHMATCH;      // DM always works
-               MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_RUNEMATCH;       // Rune always works
                MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_LMS;             // LMS always works
                MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_KEEPAWAY;                // Keepaway always works
 
@@ -372,7 +379,7 @@ float _MapInfo_Generate(string pFilename) // 0: failure, 1: ok ent, 2: ok bsp
        if(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_RACE)
        if(!spawnplaces)
        {
-               MapInfo_Map_supportedGametypes &~= MAPINFO_TYPE_RACE;
+               MapInfo_Map_supportedGametypes &= ~MAPINFO_TYPE_RACE;
                MapInfo_Map_supportedGametypes |= MAPINFO_TYPE_CTS;
        }
 
@@ -408,7 +415,6 @@ string _MapInfo_GetDefault(float t)
                case MAPINFO_TYPE_TEAM_DEATHMATCH: return "50 20 2 0";
                case MAPINFO_TYPE_DOMINATION:      return "200 20 0";
                case MAPINFO_TYPE_CTF:             return "300 20 10 0";
-               case MAPINFO_TYPE_RUNEMATCH:       return "200 20 0";
                case MAPINFO_TYPE_LMS:             return "9 20 0";
                case MAPINFO_TYPE_ARENA:           return "10 20 0";
                case MAPINFO_TYPE_CA:              return "10 20 0";
@@ -470,6 +476,22 @@ void _MapInfo_Map_ApplyGametype(string s, float pWantedType, float pThisType, fl
                s = cdr(s);
        }
 
+       if(pWantedType == MAPINFO_TYPE_CA)
+       {
+               sa = car(s);
+               if(sa != "")
+                       cvar_set("g_ca_teams", sa);
+               s = cdr(s);
+       }
+
+       if(pWantedType == MAPINFO_TYPE_FREEZETAG)
+       {
+               sa = car(s);
+               if(sa != "")
+                       cvar_set("g_freezetag_teams", sa);
+               s = cdr(s);
+       }
+
        if(pWantedType == MAPINFO_TYPE_CTF)
        {
                sa = car(s);
@@ -560,6 +582,8 @@ void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType)
        cvar_set("leadlimit", cvar_defstring("leadlimit"));
        cvar_set("fraglimit", cvar_defstring("fraglimit"));
        cvar_set("g_tdm_teams", cvar_defstring("g_tdm_teams"));
+       cvar_set("g_ca_teams", cvar_defstring("g_ca_teams"));
+       cvar_set("g_freezetag_teams", cvar_defstring("g_freezetag_teams"));
        cvar_set("g_keyhunt_teams", cvar_defstring("g_keyhunt_teams"));
        cvar_set("g_domination_default_teams", cvar_defstring("g_domination_default_teams"));
        cvar_set("g_race_qualifying_timelimit", cvar_defstring("g_race_qualifying_timelimit"));
@@ -607,6 +631,8 @@ void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType)
                else if(k == "teams")
                {
                        cvar_set("g_tdm_teams", v);
+                       cvar_set("g_ca_teams", v);
+                       cvar_set("g_freezetag_teams", v);
                        cvar_set("g_keyhunt_teams", v);
                        cvar_set("g_domination_default_teams", v);
                }
@@ -682,6 +708,7 @@ string MapInfo_Type_ToText(float t)
        for(e = MapInfo_Type_first; e; e = e.enemy)
                if(t == e.items)
                        return e.message;
+       /* xgettext:no-c-format */
        return _("@!#%'n Tuba Throwing");
 }
 
@@ -886,7 +913,7 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, float pAllowGenerate, flo
                        else
                                fputs(fh, "// uncomment this if you added turrets: has turrets\n");
                        if(MapInfo_Map_supportedFeatures & MAPINFO_FEATURE_VEHICLES)
-                               fputs(fh, "has weapons\n");
+                               fputs(fh, "has vehicles\n");
                        else
                                fputs(fh, "// uncomment this if you added vehicles: has vehicles\n");
                        if(MapInfo_Map_flags & MAPINFO_FLAG_FRUSTRATING)
@@ -965,6 +992,10 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, float pAllowGenerate, flo
                {
                        MapInfo_Map_flags |= MAPINFO_FLAG_FRUSTRATING;
                }
+               else if(t == "noautomaplist")
+               {
+                       MapInfo_Map_flags |= MAPINFO_FLAG_NOAUTOMAPLIST;
+               }
                else if(t == "type")
                {
                        t = car(s); s = cdr(s);
@@ -1047,20 +1078,21 @@ float MapInfo_Get_ByName_NoFallbacks(string pFilename, float pAllowGenerate, flo
                }
                else if(t == "fog")
                {
-                       if not(cvar_value_issafe(t))
+                       if not(cvar_value_issafe(s))
                                print("Map ", pFilename, " contains a potentially harmful fog setting, ignored\n");
                        else
                                MapInfo_Map_fog = s;
                }
                else if(t == "cdtrack")
                {
-                       if(pGametypeToSet)
+                       t = car(s); s = cdr(s);
+                       if(pGametypeToSet) // FIXME is this check right here?
                        {
                                if not(cvar_value_issafe(t))
                                        print("Map ", pFilename, " contains a potentially harmful cdtrack, ignored\n");
                                else
                                        MapInfo_Map_clientstuff = strcat(
-                                               MapInfo_Map_clientstuff, "cd loop \"", s, "\"\n"
+                                               MapInfo_Map_clientstuff, "cd loop \"", t, "\"\n"
                                        );
                        }
                }