]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
mapinfo: large changes to help with future self-registering of game types
authorRudolf Polzer <divverent@xonotic.org>
Thu, 29 Dec 2011 09:46:08 +0000 (10:46 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Thu, 29 Dec 2011 09:46:08 +0000 (10:46 +0100)
qcsrc/common/mapinfo.qc
qcsrc/common/mapinfo.qh
qcsrc/server/autocvars.qh
qcsrc/server/defs.qh
qcsrc/server/teamplay.qc

index 699a132fde2e97d62df9e3e8a9e97a479468ade7..148bc1af80d7b4b6205c81af2305bd03666e07d2 100644 (file)
@@ -1192,38 +1192,61 @@ float MapInfo_CurrentFeatures()
 
 float MapInfo_CurrentGametype()
 {
-       if(cvar("g_domination"))
-               return MAPINFO_TYPE_DOMINATION;
-       else if(cvar("g_ctf"))
-               return MAPINFO_TYPE_CTF;
-       else if(cvar("g_runematch"))
-               return MAPINFO_TYPE_RUNEMATCH;
-       else if(cvar("g_tdm"))
-               return MAPINFO_TYPE_TEAM_DEATHMATCH;
-       else if(cvar("g_assault"))
-               return MAPINFO_TYPE_ASSAULT;
-       else if(cvar("g_lms"))
-               return MAPINFO_TYPE_LMS;
-       else if(cvar("g_arena"))
-               return MAPINFO_TYPE_ARENA;
-       else if(cvar("g_ca"))
-               return MAPINFO_TYPE_CA; 
-       else if(cvar("g_keyhunt"))
-               return MAPINFO_TYPE_KEYHUNT;
-       else if(cvar("g_onslaught"))
-               return MAPINFO_TYPE_ONSLAUGHT;
-       else if(cvar("g_race"))
-               return MAPINFO_TYPE_RACE;
-       else if(cvar("g_nexball"))
-               return MAPINFO_TYPE_NEXBALL;
-       else if(cvar("g_cts"))
-               return MAPINFO_TYPE_CTS;
-       else if(cvar("g_freezetag"))
-               return MAPINFO_TYPE_FREEZETAG;
-       else if(cvar("g_keepaway"))
-               return MAPINFO_TYPE_KEEPAWAY;
-       else
-               return MAPINFO_TYPE_DEATHMATCH;
+       float prev, i;
+       prev = cvar("gamecfg");
+       for(i = 0; i < 2; ++i)
+       {
+               if(cvar("g_dm"))
+                       if(prev != MAPINFO_TYPE_DEATHMATCH)
+                               return MAPINFO_TYPE_DEATHMATCH;
+               if(cvar("g_domination"))
+                       if(prev != MAPINFO_TYPE_DOMINATION)
+                               return MAPINFO_TYPE_DOMINATION;
+               if(cvar("g_ctf"))
+                       if(prev != MAPINFO_TYPE_CTF)
+                               return MAPINFO_TYPE_CTF;
+               if(cvar("g_runematch"))
+                       if(prev != MAPINFO_TYPE_RUNEMATCH)
+                               return MAPINFO_TYPE_RUNEMATCH;
+               if(cvar("g_tdm"))
+                       if(prev != MAPINFO_TYPE_TEAM_DEATHMATCH)
+                               return MAPINFO_TYPE_TEAM_DEATHMATCH;
+               if(cvar("g_assault"))
+                       if(prev != MAPINFO_TYPE_ASSAULT)
+                               return MAPINFO_TYPE_ASSAULT;
+               if(cvar("g_lms"))
+                       if(prev != MAPINFO_TYPE_LMS)
+                               return MAPINFO_TYPE_LMS;
+               if(cvar("g_arena"))
+                       if(prev != MAPINFO_TYPE_ARENA)
+                               return MAPINFO_TYPE_ARENA;
+               if(cvar("g_ca"))
+                       if(prev != MAPINFO_TYPE_CA)
+                               return MAPINFO_TYPE_CA; 
+               if(cvar("g_keyhunt"))
+                       if(prev != MAPINFO_TYPE_KEYHUNT)
+                               return MAPINFO_TYPE_KEYHUNT;
+               if(cvar("g_onslaught"))
+                       if(prev != MAPINFO_TYPE_ONSLAUGHT)
+                               return MAPINFO_TYPE_ONSLAUGHT;
+               if(cvar("g_race"))
+                       if(prev != MAPINFO_TYPE_RACE)
+                               return MAPINFO_TYPE_RACE;
+               if(cvar("g_nexball"))
+                       if(prev != MAPINFO_TYPE_NEXBALL)
+                               return MAPINFO_TYPE_NEXBALL;
+               if(cvar("g_cts"))
+                       if(prev != MAPINFO_TYPE_CTS)
+                               return MAPINFO_TYPE_CTS;
+               if(cvar("g_freezetag"))
+                       if(prev != MAPINFO_TYPE_FREEZETAG)
+                               return MAPINFO_TYPE_FREEZETAG;
+               if(cvar("g_keepaway"))
+                       if(prev != MAPINFO_TYPE_KEEPAWAY)
+                               return MAPINFO_TYPE_KEEPAWAY;
+               prev = -1;
+       }
+       return MAPINFO_TYPE_DEATHMATCH;
 }
 
 float _MapInfo_CheckMap(string s) // returns 0 if the map can't be played with the current settings, 1 otherwise
@@ -1271,7 +1294,6 @@ string MapInfo_GetGameTypeCvar(float t)
 
 void MapInfo_SwitchGameType(float t)
 {
-       cvar_set("gamecfg",      "0");
        cvar_set("g_dm",         (t == MAPINFO_TYPE_DEATHMATCH)      ? "1" : "0");
        cvar_set("g_tdm",        (t == MAPINFO_TYPE_TEAM_DEATHMATCH) ? "1" : "0");
        cvar_set("g_domination", (t == MAPINFO_TYPE_DOMINATION)      ? "1" : "0");
@@ -1340,16 +1362,35 @@ string MapInfo_ListAllAllowedMaps(float pRequiredFlags, float pForbiddenFlags)
        return substring(out, 1, strlen(out) - 1);
 }
 
+void MapInfo_LoadMapSettings_SaveGameType(float t)
+{
+       MapInfo_SwitchGameType(t);
+       cvar_set("gamecfg", ftos(t));
+       MapInfo_LoadedGametype = t;
+}
+
 void MapInfo_LoadMapSettings(string s) // to be called from worldspawn
 {
        float t, t0;
+
+       t = MapInfo_CurrentGametype();
+       MapInfo_LoadMapSettings_SaveGameType(t);
+
        if(!_MapInfo_CheckMap(s)) // with underscore, it keeps temps
        {
+               if(cvar("g_mapinfo_allow_unsupported_modes_and_let_stuff_break"))
+               {
+                       print("EMERGENCY: can't play the selected map in the given game mode. Working with only the override settings.\n");
+                       _MapInfo_Map_ApplyGametypeEx("", t, t);
+                       return; // do not call Get_ByName!
+               }
+
                if(MapInfo_Map_supportedGametypes == 0)
                {
                        print("Mapinfo system is not functional at all. Assuming deathmatch.\n");
                        MapInfo_Map_supportedGametypes = MAPINFO_TYPE_DEATHMATCH;
-                       _MapInfo_Map_ApplyGametypeEx("", t0, t0);
+                       MapInfo_LoadMapSettings_SaveGameType(MAPINFO_TYPE_DEATHMATCH);
+                       _MapInfo_Map_ApplyGametypeEx("", MAPINFO_TYPE_DEATHMATCH, MAPINFO_TYPE_DEATHMATCH);
                        return; // do not call Get_ByName!
                }
 
@@ -1359,23 +1400,12 @@ void MapInfo_LoadMapSettings(string s) // to be called from worldspawn
                        t *= 2;
                        MapInfo_Map_supportedGametypes = floor(MapInfo_Map_supportedGametypes / 2);
                }
+
                // t is now a supported mode!
-               t0 = MapInfo_CurrentGametype();
-               if(cvar("g_mapinfo_allow_unsupported_modes_and_let_stuff_break"))
-               {
-                       print("EMERGENCY: can't play the selected map in the given game mode. Working with only the override settings.\n");
-                       cvar_settemp_restore();
-                       _MapInfo_Map_ApplyGametypeEx("", t0, t0);
-                       return; // do not call Get_ByName!
-               }
-               else
-               {
-                       print("EMERGENCY: can't play the selected map in the given game mode. Falling back to a supported mode.\n");
-                       MapInfo_SwitchGameType(t);
-               }
+               print("EMERGENCY: can't play the selected map in the given game mode. Falling back to a supported mode.\n");
+               MapInfo_LoadMapSettings_SaveGameType(t);
        }
-       cvar_settemp_restore();
-       MapInfo_Get_ByName(s, 1, MapInfo_CurrentGametype());
+       MapInfo_Get_ByName(s, 1, t);
 }
 
 void MapInfo_ClearTemps()
index 0d03912079fee2fa0a1ca2dd73b7640e2b664200..0093b196520a45f8c1c1254f95f2ef14b99f1daa 100644 (file)
@@ -82,6 +82,7 @@ void MapInfo_SwitchGameType(float t);
 
 // to be called from worldspawn to set up cvars
 void MapInfo_LoadMapSettings(string s);
+float MapInfo_LoadedGametype; // game type that was active during map load
 
 void MapInfo_Cache_Destroy(); // disable caching
 void MapInfo_Cache_Create(); // enable caching
@@ -93,3 +94,20 @@ void MapInfo_Shutdown(); // call this in the shutdown handler
 
 #define MAPINFO_SETTEMP_ACL_USER cvar_string("g_mapinfo_settemp_acl")
 #define MAPINFO_SETTEMP_ACL_SYSTEM "-g_mapinfo_* -rcon_* -_* -g_ban* +*"
+
+#define g_dm (MapInfo_LoadedGametype == MAPINFO_TYPE_DEATHMATCH)
+#define g_tdm (MapInfo_LoadedGametype == MAPINFO_TYPE_TEAM_DEATHMATCH)
+#define g_domination (MapInfo_LoadedGametype == MAPINFO_TYPE_DOMINATION)
+#define g_ctf (MapInfo_LoadedGametype == MAPINFO_TYPE_CTF)
+#define g_runematch (MapInfo_LoadedGametype == MAPINFO_TYPE_RUNEMATCH)
+#define g_lms (MapInfo_LoadedGametype == MAPINFO_TYPE_LMS)
+#define g_arena (MapInfo_LoadedGametype == MAPINFO_TYPE_ARENA)
+#define g_ca (MapInfo_LoadedGametype == MAPINFO_TYPE_CA)
+#define g_keyhunt (MapInfo_LoadedGametype == MAPINFO_TYPE_KEYHUNT)
+#define g_assault (MapInfo_LoadedGametype == MAPINFO_TYPE_ASSAULT)
+#define g_onslaught (MapInfo_LoadedGametype == MAPINFO_TYPE_ONSLAUGHT)
+#define g_race (MapInfo_LoadedGametype == MAPINFO_TYPE_RACE)
+#define g_nexball (MapInfo_LoadedGametype == MAPINFO_TYPE_NEXBALL)
+#define g_cts (MapInfo_LoadedGametype == MAPINFO_TYPE_CTS)
+#define g_freezetag (MapInfo_LoadedGametype == MAPINFO_TYPE_FREEZETAG)
+#define g_keepaway (MapInfo_LoadedGametype == MAPINFO_TYPE_KEEPAWAY)
index c6c29817aed4a806509796e7fa28d07e4cf6d043..9cd1fa9e8b4f0334cd343a37a4eb2d5014de5670 100644 (file)
@@ -1035,7 +1035,6 @@ float autocvar_g_weapon_charge_colormod_red_half;
 float autocvar_g_weapon_throwable;
 #define autocvar_g_weaponarena cvar_string("g_weaponarena")
 string autocvar_g_xonoticversion;
-float autocvar_gamecfg;
 float autocvar_gameversion;
 float autocvar_gameversion_min;
 float autocvar_gameversion_max;
index 0c06958af30d6de3baf411d5ba5308495894227f..bea9fddb3616f6f0868c11f607f26f4d30d6860c 100644 (file)
@@ -18,7 +18,6 @@ noref float require_spawnfunc_prefix; // if this float exists, only functions wi
 
 float ctf_score_value(string parameter);
 
-float g_dm, g_domination, g_ctf, g_tdm, g_keyhunt, g_onslaught, g_assault, g_arena, g_ca, g_lms, g_runematch, g_race, g_nexball, g_cts, g_freezetag, g_keepaway;
 float g_cloaked, g_footsteps, g_jump_grunt, g_grappling_hook, g_midair, g_minstagib, g_pinata, g_norecoil, g_minstagib_invis_alpha, g_bloodloss;
 float g_warmup_limit;
 float g_warmup_allguns;
index 66e909eec3ce9e5d26ee161a7729a9dd70462768..59428ef6038f19794800df119ffe344ee2bfcc13 100644 (file)
@@ -85,68 +85,6 @@ void LogTeamchange(float player_id, float team_number, float type)
        GameLogEcho(strcat(":team:", ftos(player_id), ":", ftos(team_number), ":", ftos(type)));
 }
 
-void WriteGameCvars()
-{
-       cvar_set("g_dm", ftos(g_dm));
-       cvar_set("g_tdm", ftos(g_tdm));
-       cvar_set("g_domination", ftos(g_domination));
-       cvar_set("g_ctf", ftos(g_ctf));
-       cvar_set("g_runematch", ftos(g_runematch));
-       cvar_set("g_lms", ftos(g_lms));
-       cvar_set("g_arena", ftos(g_arena));
-       cvar_set("g_ca", ftos(g_ca));
-       cvar_set("g_keyhunt", ftos(g_keyhunt));
-       cvar_set("g_assault", ftos(g_assault));
-       cvar_set("g_onslaught", ftos(g_onslaught));
-       cvar_set("g_race", ftos(g_race));
-       cvar_set("g_nexball", ftos(g_nexball));
-       cvar_set("g_cts", ftos(g_cts));
-       cvar_set("g_freezetag", ftos(g_freezetag));
-       cvar_set("g_keepaway", ftos(g_keepaway));
-}
-
-void ReadGameCvars()
-{
-       float found;
-       float prev;
-       float i;
-
-       found = 0;
-       prev = autocvar_gamecfg;
-       for(i = 0; i < 2; ++i)
-       {
-//#NO AUTOCVARS START
-               found += (g_dm = (!found && (prev != GAME_DEATHMATCH) && cvar("g_dm")));
-               found += (g_tdm = (!found && (prev != GAME_TEAM_DEATHMATCH) && cvar("g_tdm")));
-               found += (g_domination = (!found && (prev != GAME_DOMINATION) && cvar("g_domination")));
-               found += (g_ctf = (!found && (prev != GAME_CTF) && cvar("g_ctf")));
-               found += (g_runematch = (!found && (prev != GAME_RUNEMATCH) && cvar("g_runematch")));
-               found += (g_lms = (!found && (prev != GAME_LMS) && cvar("g_lms")));
-               found += (g_arena = (!found && (prev != GAME_ARENA) && cvar("g_arena")));
-               found += (g_ca = (!found && (prev != GAME_CA) && cvar("g_ca")));
-               found += (g_keyhunt = (!found && (prev != GAME_KEYHUNT) && cvar("g_keyhunt")));
-               found += (g_assault = (!found && (prev != GAME_ASSAULT) && cvar("g_assault")));
-               found += (g_onslaught = (!found && (prev != GAME_ONSLAUGHT) && cvar("g_onslaught")));
-               found += (g_race = (!found && (prev != GAME_RACE) && cvar("g_race")));
-               found += (g_nexball = (!found && (prev != GAME_NEXBALL) && cvar("g_nexball")));
-               found += (g_cts = (!found && (prev != GAME_CTS) && cvar("g_cts")));
-               found += (g_freezetag = (!found && (prev != GAME_FREEZETAG) && cvar("g_freezetag")));
-               found += (g_keepaway = (!found && (prev != GAME_KEEPAWAY) && cvar("g_keepaway")));
-//#NO AUTOCVARS END
-
-               if(found)
-                       break;
-
-               prev = -1; // second attempt takes place WITHOUT prev set
-       }
-
-       if(!found)
-               g_dm = 1;
-
-       teamplay = 0;
-       serverflags &~= SERVERFLAG_TEAMPLAY;
-}
-
 void default_delayedinit()
 {
        if(!scores_initialized)
@@ -167,16 +105,14 @@ void InitGameplayMode()
 
        VoteReset();
 
-       // make sure only ONE type is selected
-       ReadGameCvars();
-       WriteGameCvars();
-
        // find out good world mins/maxs bounds, either the static bounds found by looking for solid, or the mapinfo specified bounds
        get_mi_min_max(1);
        world.mins = mi_min;
        world.maxs = mi_max;
 
        MapInfo_LoadMapSettings(mapname);
+       teamplay = 0;
+       serverflags &~= SERVERFLAG_TEAMPLAY;
 
        if not(cvar_value_issafe(world.fog))
        {
@@ -192,9 +128,6 @@ void InitGameplayMode()
 
        MapInfo_ClearTemps();
 
-       // in case mapinfo switched the type
-       ReadGameCvars();
-
        // set both here, gamemode can override it later
        timelimit_override = autocvar_timelimit_override;
        fraglimit_override = autocvar_fraglimit_override;