r2005 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Dec 8 02:19:59 EST 2006


Author: div0
Date: 2006-12-08 02:19:58 -0500 (Fri, 08 Dec 2006)
New Revision: 2005

Modified:
   trunk/data/qcsrc/server/g_world.qc
Log:
slightly more intelligent maplist editing (doesn't re-shuffle any more)


Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc	2006-12-07 20:51:21 UTC (rev 2004)
+++ trunk/data/qcsrc/server/g_world.qc	2006-12-08 07:19:58 UTC (rev 2005)
@@ -1267,18 +1267,18 @@
 			result = strcat(result, "'", argv(i), "'");
 	}
 	if(found)
-	{
 		cvar_set("g_maplist", result);
-		localcmd("set _g_maplist_have_shuffled 0\n");
-	}
 	ServerConsoleEcho(strcat("Removed ", ftos(found), " items."), FALSE);
 }
 
 void AddToMaplist(string m)
 {
+	string result;
 	float found;
 	float litems;
 	float i;
+	float ipos;
+	float inserted;
 
 	if(!TryFile(strcat("maps/", m, ".mapcfg")))
 	{
@@ -1287,14 +1287,29 @@
 	}
 
 	litems = tokenize(cvar_string("g_maplist"));
+	if(cvar("g_maplist_shuffle"))
+		ipos = ceil(random() * (litems + 1)) - 1;
+	else
+		ipos = litems;
 	found = 0;
+	inserted = 0;
 	for(i = 0; i < litems; ++i)
+	{
+		m = strcat(m);
+		if(i == ipos)
+		{
+			result = strcat(result, "'", m, "'");
+			inserted = 1;
+		}
+		result = strcat(result, "'", argv(i), "'");
 		if(argv(i) == m)
 			found += 1;
+	}
+	if(!inserted)
+		result = strcat(result, "'", m, "'");
 	if(!found)
 	{
-		cvar_set("g_maplist", strcat(cvar_string("g_maplist"), "'", m, "'"));
-		localcmd("set _g_maplist_have_shuffled 0\n");
+		cvar_set("g_maplist", result);
 		ServerConsoleEcho("Map added.", FALSE);
 	}
 	else




More information about the nexuiz-commits mailing list