r2957 - in trunk/data/qcsrc: common menu-div0test server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Nov 15 12:53:39 EST 2007


Author: div0
Date: 2007-11-15 12:53:38 -0500 (Thu, 15 Nov 2007)
New Revision: 2957

Modified:
   trunk/data/qcsrc/common/mapinfo.qc
   trunk/data/qcsrc/common/mapinfo.qh
   trunk/data/qcsrc/menu-div0test/menu.qc
   trunk/data/qcsrc/server/gamecommand.qc
Log:
add "features" (so a mutator combination can require them)


Modified: trunk/data/qcsrc/common/mapinfo.qc
===================================================================
--- trunk/data/qcsrc/common/mapinfo.qc	2007-11-15 15:55:22 UTC (rev 2956)
+++ trunk/data/qcsrc/common/mapinfo.qc	2007-11-15 17:53:38 UTC (rev 2957)
@@ -57,7 +57,7 @@
 
 // filter the info by game type mask (updates MapInfo_count)
 string _MapInfo_filtered;
-string MapInfo_FilterGametype_Recursive(float pGametype, float pBegin, float pEnd)
+string MapInfo_FilterGametype_Recursive(float pGametype, float pFeatures, float pBegin, float pEnd)
 {
 	float m;
 	string l, r;
@@ -67,25 +67,25 @@
 
 	m = floor((pBegin + pEnd) / 2);
 
-	l = MapInfo_FilterGametype_Recursive(pGametype, pBegin, m);
+	l = MapInfo_FilterGametype_Recursive(pGametype, pFeatures, pBegin, m);
 	if not(l)
 		return string_null; // BAIL OUT
 	if(MapInfo_Get_ByName(_MapInfo_GlobItem(m), 1) == 2) // if we generated one... BAIL OUT and let the caller continue in the next frame.
 		return string_null; // BAIL OUT
-	r = MapInfo_FilterGametype_Recursive(pGametype, m + 1, pEnd);
+	r = MapInfo_FilterGametype_Recursive(pGametype, pFeatures, m + 1, pEnd);
 	if not(r)
 		return string_null; // BAIL OUT
 
-	if(MapInfo_Map_supportedGametypes & pGametype)
+	if(((MapInfo_Map_supportedGametypes & pGametype) != 0) && ((MapInfo_Map_supportedFeatures & pFeatures) == pFeatures))
 		return HugeSetOfIntegers_insert(l, m, r);
 	else
 		return HugeSetOfIntegers_concat(l, r);
 }
-float MapInfo_FilterGametype(float pGametype)
+float MapInfo_FilterGametype(float pGametype, float pFeatures)
 {
 	if(_MapInfo_filtered)
 		strunzone(_MapInfo_filtered);
-	_MapInfo_filtered = MapInfo_FilterGametype_Recursive(pGametype, 0, _MapInfo_globcount);
+	_MapInfo_filtered = MapInfo_FilterGametype_Recursive(pGametype, pFeatures, 0, _MapInfo_globcount);
 	if(!_MapInfo_filtered)
 	{
 		dprint("Autogenerated a .mapinfo, doing the rest later.\n");
@@ -137,9 +137,6 @@
 
 	inWorldspawn = 2;
 
-	MapInfo_Map_supportedGametypes = 0;
-	MapInfo_Map_diameter = 0;
-	MapInfo_Map_spawnpoints = 0;
 	for(;;)
 	{
 		if not((s = fgets(fh)))
@@ -194,6 +191,8 @@
 					++MapInfo_Map_spawnpoints;
 				else if(startsWith(v, "info_player_start\""))
 					++MapInfo_Map_spawnpoints;
+				else if(startsWith(v, "weapon_") && !startsWith(v, "weapon_nex\"") && !startsWith(v, "weapon_railgun\""))
+					MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_WEAPONS;
 			}
 		}
 	}
@@ -241,6 +240,7 @@
 	MapInfo_Map_title = "Untitled1";
 	MapInfo_Map_description = "Bleh.";
 	MapInfo_Map_supportedGametypes = 0;
+	MapInfo_Map_supportedFeatures = 0;
 	MapInfo_Map_diameter = 0;
 	MapInfo_Map_spawnpoints = 0;
 
@@ -258,6 +258,7 @@
 		fputs(fh, strcat("description ", MapInfo_Map_description, "\n"));
 		fputs(fh, strcat("_diameter ", ftos(MapInfo_Map_diameter), "\n"));
 		fputs(fh, strcat("_spawnpoints ", ftos(MapInfo_Map_spawnpoints), "\n"));
+		if(MapInfo_Map_supportedFeatures & MAPINFO_FEATURE_WEAPONS)       fputs(fh, "has weapons\n");
 		if(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_DEATHMATCH)      fputs(fh, "type dm 30 20\n");
 		if(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_TEAM_DEATHMATCH) fputs(fh, "type tdm 50 20 2\n"); // TODO count tdm_team entities
 		if(MapInfo_Map_supportedGametypes & MAPINFO_TYPE_DOMINATION)      fputs(fh, "type dom 200 20 2\n"); // TODO count tdm_team entities
@@ -286,6 +287,13 @@
 			MapInfo_Map_diameter = stof(argv(1));
 		else if(t == "_spawnpoints")
 			MapInfo_Map_spawnpoints = stof(argv(1));
+		else if(t == "has")
+		{
+			t = argv(1);
+			if     (t == "weapons") MapInfo_Map_supportedFeatures |= MAPINFO_FEATURE_WEAPONS;
+			else
+				dprint("Map ", pFilename, " supports unknown feature ", t, ", ignored\n");
+		}
 		else if(t == "type")
 		{
 			t = argv(1);

Modified: trunk/data/qcsrc/common/mapinfo.qh
===================================================================
--- trunk/data/qcsrc/common/mapinfo.qh	2007-11-15 15:55:22 UTC (rev 2956)
+++ trunk/data/qcsrc/common/mapinfo.qh	2007-11-15 17:53:38 UTC (rev 2957)
@@ -10,12 +10,15 @@
 float MAPINFO_TYPE_ONSLAUGHT		= 512;
 float MAPINFO_TYPE_ALL              = 65535; // this has to include all above bits
 
+float MAPINFO_FEATURE_WEAPONS       = 1; // not defined for minstagib-only maps
+
 float MapInfo_count;
 
 // info about a map that MapInfo loads
 string MapInfo_Map_title;
 string MapInfo_Map_description;
 float MapInfo_Map_supportedGametypes;
+float MapInfo_Map_supportedFeatures;
 float MapInfo_Map_diameter;
 float MapInfo_Map_spawnpoints;
 
@@ -24,7 +27,7 @@
 void MapInfo_Enumerate();
 
 // filter the info by game type mask (updates MapInfo_count)
-float MapInfo_FilterGametype(float gametype); // 1 on success, 0 on temporary failure (call it again next frame then)
+float MapInfo_FilterGametype(float gametype, float features); // 1 on success, 0 on temporary failure (call it again next frame then)
 
 // load info about the i-th map into the MapInfo_Map_* globals
 float MapInfo_Get_ByID(float i); // 1 on success, 0 on failure

Modified: trunk/data/qcsrc/menu-div0test/menu.qc
===================================================================
--- trunk/data/qcsrc/menu-div0test/menu.qc	2007-11-15 15:55:22 UTC (rev 2956)
+++ trunk/data/qcsrc/menu-div0test/menu.qc	2007-11-15 17:53:38 UTC (rev 2957)
@@ -26,7 +26,7 @@
 
 	menuLoadedMaplist = 0;
 	MapInfo_Enumerate();
-	if(!MapInfo_FilterGametype(MAPINFO_TYPE_ALL))
+	if(!MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0))
 		return;
 	menuLoadedMaplist = 1;
 

Modified: trunk/data/qcsrc/server/gamecommand.qc
===================================================================
--- trunk/data/qcsrc/server/gamecommand.qc	2007-11-15 15:55:22 UTC (rev 2956)
+++ trunk/data/qcsrc/server/gamecommand.qc	2007-11-15 17:53:38 UTC (rev 2957)
@@ -3,7 +3,7 @@
 void make_mapinfo_Think()
 {
 	MapInfo_Enumerate(); // just in case
-	if(MapInfo_FilterGametype(MAPINFO_TYPE_ALL))
+	if(MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0))
 	{
 		print("Done rebuiling mapinfos.\n");
 		remove(self);




More information about the nexuiz-commits mailing list