r2960 - in trunk/data/qcsrc: common server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Thu Nov 15 14:07:06 EST 2007
Author: div0
Date: 2007-11-15 14:07:03 -0500 (Thu, 15 Nov 2007)
New Revision: 2960
Modified:
trunk/data/qcsrc/common/mapinfo.qc
trunk/data/qcsrc/common/mapinfo.qh
trunk/data/qcsrc/server/teamplay.qc
Log:
added some primitives to the mapinfo system to be aware of game mode requirements
Modified: trunk/data/qcsrc/common/mapinfo.qc
===================================================================
--- trunk/data/qcsrc/common/mapinfo.qc 2007-11-15 18:51:31 UTC (rev 2959)
+++ trunk/data/qcsrc/common/mapinfo.qc 2007-11-15 19:07:03 UTC (rev 2960)
@@ -355,3 +355,65 @@
return string_null; // ambigous match
return match;
}
+
+float MapInfo_CurrentFeatures()
+{
+ float req;
+ req = 0;
+ if(!(cvar("g_instagib") || cvar("g_minstagib") || cvar("g_nixnex") || cvar("g_rocketarena")))
+ req |= MAPINFO_FEATURE_WEAPONS;
+ return req;
+}
+
+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_keyhunt"))
+ return MAPINFO_TYPE_KEYHUNT;
+ else if(cvar("g_onslaught"))
+ return MAPINFO_TYPE_ONSLAUGHT;
+ else
+ return MAPINFO_TYPE_DEATHMATCH;
+}
+
+float MapInfo_CheckMap(string s) // returns 0 if the map can't be played with the current settings, 1 otherwise
+{
+ if(!MapInfo_Get_ByName(s, 1))
+ return 0;
+ if((MapInfo_Map_supportedGametypes & MapInfo_CurrentGametype()) == 0)
+ return 0;
+ if((MapInfo_Map_supportedFeatures & MapInfo_CurrentFeatures()) != MapInfo_CurrentFeatures())
+ return 0;
+ return 1;
+}
+
+void MapInfo_LoadMap(string s)
+{
+ if(!MapInfo_CheckMap(s))
+ {
+ print("EMERGENCY: can't play the selected map in the given game mode. Falling back to deathmatch.\n");
+ cvar_set("g_domination", "0");
+ cvar_set("g_ctf", "0");
+ cvar_set("g_runematch", "0");
+ cvar_set("g_tdm", "0");
+ cvar_set("g_assault", "0");
+ cvar_set("g_lms", "0");
+ cvar_set("g_arena", "0");
+ cvar_set("g_keyhunt", "0");
+ cvar_set("g_onslaught", "0");
+ }
+ localcmd(strcat("\nchangelevel ", s, "\n"));
+}
Modified: trunk/data/qcsrc/common/mapinfo.qh
===================================================================
--- trunk/data/qcsrc/common/mapinfo.qh 2007-11-15 18:51:31 UTC (rev 2959)
+++ trunk/data/qcsrc/common/mapinfo.qh 2007-11-15 19:07:03 UTC (rev 2960)
@@ -28,6 +28,8 @@
// filter the info by game type mask (updates MapInfo_count)
float MapInfo_FilterGametype(float gametype, float features); // 1 on success, 0 on temporary failure (call it again next frame then)
+float MapInfo_CurrentFeatures(); // retrieves currently required features from cvars
+float MapInfo_CurrentGametype(); // retrieves current gametype from cvars
// load info about the i-th map into the MapInfo_Map_* globals
float MapInfo_Get_ByID(float i); // 1 on success, 0 on failure
@@ -37,3 +39,7 @@
// look for a map by a prefix, returns the actual map name on success, string_null on failure or ambigous match
string MapInfo_FixName(string s);
+
+// play a map
+float MapInfo_CheckMap(string s); // returns 0 if the map can't be played with the current settings
+void MapInfo_LoadMap(string s);
Modified: trunk/data/qcsrc/server/teamplay.qc
===================================================================
--- trunk/data/qcsrc/server/teamplay.qc 2007-11-15 18:51:31 UTC (rev 2959)
+++ trunk/data/qcsrc/server/teamplay.qc 2007-11-15 19:07:03 UTC (rev 2960)
@@ -162,10 +162,11 @@
gamemode_name = "Capture the Flag";
teams_matter = 1;
}
- else if((game == GAME_RUNEMATCH || cvar("g_runematch")) && !g_minstagib)
+ else if(game == GAME_RUNEMATCH || cvar("g_runematch"))
{
game = GAME_RUNEMATCH;
cvar_set("g_runematch", "1");
+ cvar_set("g_minstagib", "0");
if(cvar("deathmatch_force_teamplay"))
ActivateTeamplay();
More information about the nexuiz-commits
mailing list