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
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");
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!
}
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()
// 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
#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)
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)
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))
{
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;