]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mapinfo.qc
rewrite settemp system to handle "quit" right
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mapinfo.qc
index 4ec54b0f06ace8cd5773fa846296ccda602b23ca..699a132fde2e97d62df9e3e8a9e97a479468ade7 100644 (file)
@@ -78,6 +78,7 @@ float MapInfo_Cache_Retrieve(string map)
        MapInfo_Map_supportedGametypes = stof(bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i));
        MapInfo_Map_supportedFeatures = stof(bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i));
        MapInfo_Map_flags = stof(bufstr_get(_MapInfo_Cache_Buf_IndexToMapData, ++i));
+
        return 1;
 }
 
@@ -830,7 +831,7 @@ float MapInfo_isRedundant(string fn, string t)
 }
 
 // load info about a map by name into the MapInfo_Map_* globals
-float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametypeToSet)
+float MapInfo_Get_ByName_NoFallbacks(string pFilename, float pAllowGenerate, float pGametypeToSet)
 {
        string fn;
        string s, t;
@@ -1088,16 +1089,6 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype
        }
        fclose(fh);
 
-       if(pGametypeToSet)
-       {
-               if(!(MapInfo_Map_supportedGametypes & pGametypeToSet))
-               {
-                       error("Can't select the requested game type. This should never happen as the caller should prevent it!\n");
-                       //_MapInfo_Map_ApplyGametypeEx("", pGametypeToSet, MAPINFO_TYPE_DEATHMATCH);
-                       //return;
-               }
-       }
-
        if(MapInfo_Map_title == "<TITLE>")
                MapInfo_Map_titlestring = MapInfo_Map_bspname;
        else if(MapInfo_isRedundant(MapInfo_Map_bspname, MapInfo_Map_title))
@@ -1111,6 +1102,30 @@ float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametype
        dprint("Map ", pFilename, " supports no game types, ignored\n");
        return 0;
 }
+float MapInfo_Get_ByName(string pFilename, float pAllowGenerate, float pGametypeToSet)
+{
+       float r = MapInfo_Get_ByName_NoFallbacks(pFilename, pAllowGenerate, pGametypeToSet);
+
+       if(cvar("g_tdm_on_dm_maps"))
+       {
+               // if this is set, all DM maps support TDM too
+               if not(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_TEAM_DEATHMATCH)
+                       if(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_DEATHMATCH)
+                               _MapInfo_Map_ApplyGametypeEx ("", pGametypeToSet, MAPINFO_TYPE_TEAM_DEATHMATCH);
+       }
+
+       if(pGametypeToSet)
+       {
+               if(!(MapInfo_Map_supportedGametypes & pGametypeToSet))
+               {
+                       error("Can't select the requested game type. This should never happen as the caller should prevent it!\n");
+                       //_MapInfo_Map_ApplyGametypeEx("", pGametypeToSet, MAPINFO_TYPE_DEATHMATCH);
+                       //return;
+               }
+       }
+
+       return r;
+}
 
 float MapInfo_FindName(string s)
 {
@@ -1275,7 +1290,7 @@ void MapInfo_SwitchGameType(float t)
        cvar_set("g_keepaway",   (t == MAPINFO_TYPE_KEEPAWAY)        ? "1" : "0");
 }
 
-void MapInfo_LoadMap(string s)
+void MapInfo_LoadMap(string s, float reinit)
 {
        MapInfo_Map_supportedGametypes = 0;
        // we shouldn't need this, as LoadMapSettings already fixes the gametype
@@ -1284,7 +1299,12 @@ void MapInfo_LoadMap(string s)
        //      print("EMERGENCY: can't play the selected map in the given game mode. Falling back to DM.\n");
        //      MapInfo_SwitchGameType(MAPINFO_TYPE_DEATHMATCH);
        //}
-       localcmd(strcat("\nsettemp_restore\nchangelevel ", s, "\n"));
+       
+       cvar_settemp_restore();
+       if(reinit)
+               localcmd(strcat("\nmap ", s, "\n"));
+       else
+               localcmd(strcat("\nchangelevel ", s, "\n"));
 }
 
 string MapInfo_ListAllowedMaps(float pRequiredFlags, float pForbiddenFlags)