r2962 - in trunk/data/qcsrc: common server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Nov 15 16:44:10 EST 2007


Author: div0
Date: 2007-11-15 16:44:10 -0500 (Thu, 15 Nov 2007)
New Revision: 2962

Modified:
   trunk/data/qcsrc/common/mapinfo.qc
   trunk/data/qcsrc/server/clientcommands.qc
   trunk/data/qcsrc/server/g_world.qc
   trunk/data/qcsrc/server/gamecommand.qc
Log:
automatically call MapInfo_Enumerate when needed...
"completion" for vcall and suggestmap


Modified: trunk/data/qcsrc/common/mapinfo.qc
===================================================================
--- trunk/data/qcsrc/common/mapinfo.qc	2007-11-15 21:17:59 UTC (rev 2961)
+++ trunk/data/qcsrc/common/mapinfo.qc	2007-11-15 21:44:10 UTC (rev 2962)
@@ -100,6 +100,8 @@
 }
 float MapInfo_FilterGametype(float pGametype, float pFeatures)
 {
+	MapInfo_Enumerate();
+
 	if(_MapInfo_filtered)
 		strunzone(_MapInfo_filtered);
 	_MapInfo_filtered = MapInfo_FilterGametype_Recursive(pGametype, pFeatures, 0, _MapInfo_globcount);
@@ -384,6 +386,8 @@
 	// note that DP sorts glob results... so I can use a binary search
 	string match;
 	float l, r, m, cmp;
+	MapInfo_Enumerate();
+	MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures());
 	l = 0;
 	r = MapInfo_count;
 	// invariants: r is behind s, l-1 is equal or before

Modified: trunk/data/qcsrc/server/clientcommands.qc
===================================================================
--- trunk/data/qcsrc/server/clientcommands.qc	2007-11-15 21:17:59 UTC (rev 2961)
+++ trunk/data/qcsrc/server/clientcommands.qc	2007-11-15 21:44:10 UTC (rev 2962)
@@ -1,5 +1,5 @@
 void ReadyCount();
-float ValidateMap(string vote);
+string ValidateMap(string vote);
 void(entity e) DropFlag;
 string MapVote_Suggest(string m);
 
@@ -206,11 +206,16 @@
 					} else if(time < self.vote_next) {
 						sprint(self, strcat("^1You have to wait ^2", ftos(self.vote_next - time), "^1 seconds before you can again call a vote.\n"));
 					} else if(VoteAllowed(strcat1(argv(2)))) { // strcat seems to be necessary
-						if(!ValidateMap(vote))
-							return;
 						// remap chmap to gotomap (forces intermission)
 						if(substring(vote, 0, 6) == "chmap ")
 							vote = strcat("gotomap ", substring(vote, 6, strlen(vote) - 6));
+						if(substring(vote, 0, 8) == "gotomap ")
+						{
+							if(!(vote = ValidateMap(substring(vote, 8, strlen(vote) - 8))))
+								return;
+							vote = strcat("gotomap ", vote);
+						}
+
 						// make kick and kickban votes a bit nicer (and reject them if formatted badly)
 						if(substring(vote, 0, 5) == "kick " || substring(vote, 0, 8) == "kickban ")
 						{
@@ -482,40 +487,43 @@
 	}
 }
 
-float ValidateMap(string vote)
+string ValidateMap(string m)
 {
-	string ext;
-	
-	tokenize(vote);
-	if(argv(0) == "map" || argv(0) == "changelevel")
-		ext = ".bsp";
-	else if(argv(0) == "chmap")
-		ext = ".mapcfg";
-	else if(argv(0) == "gotomap")
-		ext = ".mapcfg";
-	else
-		return TRUE;
-
+#ifdef MAPINFO
+	m = MapInfo_FixName(m);
+	if(!m)
+	{
+		sprint(self, "This map is not available on this server.\n");
+		return string_null;
+	}
+#endif
 	if(!cvar("sv_vote_change_gametype"))
-		if(!IsSameGametype(argv(1)))
+		if(!IsSameGametype(m))
 		{
 			sprint(self, "This server does not allow changing the game type by map votes.\n");
-			return FALSE;
+			return string_null;
 		}
 	if(!cvar("sv_vote_override_mostrecent"))
-		if(Map_IsRecent(argv(1)))
+		if(Map_IsRecent(m))
 		{
 			sprint(self, "This server does not allow for recent maps to be played again. Please be patient for some rounds.\n");
-			return FALSE;
+			return string_null;
 		}
-
-	if(!TryFile(strcat("maps/", argv(1), ext)))
+#ifdef MAPINFO
+	if(!MapInfo_CheckMap(m))
 	{
-		sprint(self, strcat("^1Invalid mapname, \"^3", argv(1), "^1\" does not exist on this server.\n"));
-		return FALSE;
+		sprint(self, strcat("^1Invalid mapname, \"^3", m, "^1\" does not support the current game mode.\n"));
+		return string_null;
 	}
+#else
+	if(!TryFile(strcat("maps/", m, ".mapcfg")))
+	{
+		sprint(self, strcat("^1Invalid mapname, \"^3", m, "^1\" does not exist on this server.\n"));
+		return string_null;
+	}
+#endif
 
-	return TRUE;
+	return m;
 }
 
 

Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc	2007-11-15 21:17:59 UTC (rev 2961)
+++ trunk/data/qcsrc/server/g_world.qc	2007-11-15 21:44:10 UTC (rev 2962)
@@ -1788,6 +1788,11 @@
 		return "Suggestions are not accepted on this server.";
 	if(mapvote_initialized)
 		return "Can't suggest - voting is already in progress!";
+#ifdef MAPINFO
+	m = MapInfo_FixName(m);
+	if(!m)
+		return "The map you suggested is not available on this server.";
+#endif
 	if(!cvar("g_maplist_votable_suggestions_change_gametype"))
 		if(!IsSameGametype(m))
 			return "This server does not allow changing the game type by map suggestions.";
@@ -1797,10 +1802,11 @@
 
 #ifdef MAPINFO
 	if(!MapInfo_CheckMap(m))
+		return "The map you suggested does not support the current game mode.";
 #else
 	if(!TryFile(strcat("maps/", m, ".mapcfg")))
+		return "The map you suggested is not available on this server.";
 #endif
-		return "The map you suggested is not available on this server.";
 	for(i = 0; i < mapvote_suggestion_ptr; ++i)
 		if(mapvote_suggestions[i] == m)
 			return "This map was already suggested.";

Modified: trunk/data/qcsrc/server/gamecommand.qc
===================================================================
--- trunk/data/qcsrc/server/gamecommand.qc	2007-11-15 21:17:59 UTC (rev 2961)
+++ trunk/data/qcsrc/server/gamecommand.qc	2007-11-15 21:44:10 UTC (rev 2962)
@@ -2,7 +2,6 @@
 
 void make_mapinfo_Think()
 {
-	MapInfo_Enumerate(); // just in case
 	if(MapInfo_FilterGametype(MAPINFO_TYPE_ALL, 0))
 	{
 		print("Done rebuiling mapinfos.\n");




More information about the nexuiz-commits mailing list