+string _MapInfo_GetDefaultEx(float t)
+{
+ switch(t)
+ {
+ case MAPINFO_TYPE_DEATHMATCH: return "timelimit=20 pointlimit=30 leadlimit=0";
+ case MAPINFO_TYPE_TEAM_DEATHMATCH: return "timelimit=20 pointlimit=50 teams=2 leadlimit=0";
+ case MAPINFO_TYPE_DOMINATION: return "timelimit=20 pointlimit=200 teams=2 leadlimit=0";
+ case MAPINFO_TYPE_CTF: return "timelimit=20 pointlimit=300 caplimit=10 leadlimit=0";
+ case MAPINFO_TYPE_RUNEMATCH: return "timelimit=20 pointlimit=200 leadlimit=0";
+ case MAPINFO_TYPE_LMS: return "timelimit=20 lives=9 leadlimit=0";
+ case MAPINFO_TYPE_ARENA: return "timelimit=20 pointlimit=10 leadlimit=0";
+ case MAPINFO_TYPE_CA: return "timelimit=20 pointlimit=10 leadlimit=0";
+ case MAPINFO_TYPE_KEYHUNT: return "timelimit=20 pointlimit=1000 teams=3 leadlimit=0";
+ case MAPINFO_TYPE_ASSAULT: return "timelimit=20";
+ case MAPINFO_TYPE_RACE: return "timelimit=20 qualifying_timelimit=5 laplimit=7 teamlaplimit=15 leadlimit=0";
+ case MAPINFO_TYPE_ONSLAUGHT: return "timelimit=20";
+ case MAPINFO_TYPE_NEXBALL: return "timelimit=20 pointlimit=5 leadlimit=0";
+ case MAPINFO_TYPE_CTS: return "timelimit=20 skill=-1";
+ case MAPINFO_TYPE_KEEPAWAY: return "timelimit=20 pointlimit=30";
+ default: return "";
+ }
+}
+
+void _MapInfo_Map_ApplyGametypeEx(string s, float pWantedType, float pThisType)
+{
+ string sa, k, v;
+ float p;
+ string fraglimit_normal;
+ string fraglimit_caps;
+ string fraglimit_teams;
+
+ MapInfo_Map_supportedGametypes |= pThisType;
+ if(!(pThisType & pWantedType))
+ return;
+
+ // reset all the cvars to their defaults
+
+ cvar_set("timelimit", cvar_defstring("timelimit"));
+ 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_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"));
+
+ fraglimit_normal = string_null;
+ fraglimit_caps = string_null;
+ fraglimit_teams = string_null;
+
+ s = strcat(_MapInfo_GetDefaultEx(pWantedType), " ", s);
+ while(s != "")
+ {
+ sa = car(s);
+ s = cdr(s);
+
+ if(sa == "")
+ continue;
+
+ p = strstrofs(sa, "=", 0);
+ if(p < 0)
+ {
+ k = "timelimit";
+ v = s;
+ }
+ else
+ {
+ k = substring(sa, 0, p);
+ v = substring(sa, p+1, -1);
+ }
+
+ if(k == "timelimit")
+ {
+ cvar_set("timelimit", v);
+ }
+ else if(k == "leadlimit")
+ {
+ cvar_set("leadlimit", v);
+ }
+ else if(k == "pointlimit" || k == "fraglimit" || k == "lives" || k == "laplimit")
+ {
+ fraglimit_normal = v;
+ }
+ else if(k == "caplimit")
+ {
+ fraglimit_caps = v;
+ }
+ else if(k == "teampointlimit" || k == "teamlaplimit")
+ {
+ fraglimit_teams = v;
+ }
+ else if(k == "teams")
+ {
+ cvar_set("g_tdm_teams", v);
+ cvar_set("g_keyhunt_teams", v);
+ cvar_set("g_domination_default_teams", v);
+ }
+ else if(k == "qualifying_timelimit")
+ {
+ cvar_set("g_race_qualifying_timelimit", v);
+ }
+ else if(k == "skill")
+ {
+ // ignore
+ }
+ else
+ {
+ print("Invalid gametype key in mapinfo: ", k, "\n");
+ }
+ }
+
+ if(pWantedType == MAPINFO_TYPE_CTF && cvar("g_ctf_win_mode") < 2)
+ {
+ if(fraglimit_caps)
+ cvar_set("fraglimit", fraglimit_caps);
+ }
+ else if(pWantedType == MAPINFO_TYPE_RACE && cvar("g_race_teams") >= 2)
+ {
+ if(fraglimit_teams)
+ cvar_set("fraglimit", fraglimit_teams);
+ }
+ else
+ {
+ if(fraglimit_normal)
+ cvar_set("fraglimit", fraglimit_normal);
+ }
+}
+