r1989 - in branches/nexuiz-2.0/data: . qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Mon Dec 4 17:22:39 EST 2006


Author: div0
Date: 2006-12-04 17:22:39 -0500 (Mon, 04 Dec 2006)
New Revision: 1989

Modified:
   branches/nexuiz-2.0/data/default.cfg
   branches/nexuiz-2.0/data/qcsrc/server/g_world.qc
Log:
g_maplist_ editing commands


Modified: branches/nexuiz-2.0/data/default.cfg
===================================================================
--- branches/nexuiz-2.0/data/default.cfg	2006-12-04 12:55:51 UTC (rev 1988)
+++ branches/nexuiz-2.0/data/default.cfg	2006-12-04 22:22:39 UTC (rev 1989)
@@ -201,6 +201,8 @@
 seta g_maplist_selectrandom 0 // if 1, a random map will be chosen as next map; DEPRECATED in favor of g_maplist_shuffle
 seta g_maplist_shuffle 0 // new randomization method: like selectrandom, but avoid playing the same maps in short succession. This works by taking out the first element and inserting it into g_maplist with a bias to the end of the list.
 alias g_maplist_shufflenow "set _g_maplist_shufflenow 1"
+alias g_maplist_add "set _g_maplist_add $1"
+alias g_maplist_remove "set _g_maplist_remove $1"
 // timeout for kill credit when your damage knocks someone into a death trap
 set g_maxpushtime 8.0
 

Modified: branches/nexuiz-2.0/data/qcsrc/server/g_world.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/g_world.qc	2006-12-04 12:55:51 UTC (rev 1988)
+++ branches/nexuiz-2.0/data/qcsrc/server/g_world.qc	2006-12-04 22:22:39 UTC (rev 1989)
@@ -1208,6 +1208,60 @@
 	ServerConsoleEcho(".", FALSE);
 }
 
+void RemoveFromMaplist(string m)
+{
+	string result;
+	float litems;
+	float i;
+	float found;
+
+	litems = tokenize(cvar_string("g_maplist"));
+	found = 0;
+	result = "";
+	for(i = 0; i < litems; ++i)
+	{
+		m = strcat(m);
+		result = strcat(result);
+		if(argv(i) == m)
+			found += 1;
+		else
+			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)
+{
+	float found;
+	float litems;
+	float i;
+
+	if(!TryFile(strcat("maps/", m, ".mapcfg")))
+	{
+		ServerConsoleEcho("Map not found.", FALSE);
+		return;
+	}
+
+	litems = tokenize(cvar_string("g_maplist"));
+	found = 0;
+	for(i = 0; i < litems; ++i)
+		if(argv(i) == m)
+			found += 1;
+	if(!found)
+	{
+		cvar_set("g_maplist", strcat(cvar_string("g_maplist"), "'", m, "'"));
+		localcmd("set _g_maplist_have_shuffled 0\n");
+		ServerConsoleEcho("Map added.", FALSE);
+	}
+	else
+		ServerConsoleEcho("Map already in list.", FALSE);
+}
+
 void ShuffleMaplist()
 {
 	string result;
@@ -1278,6 +1332,16 @@
 	}
 
 	// automatically shuffle when setting g_maplist_shuffle
+	if(cvar_string("_g_maplist_add") != "")
+	{
+		AddToMaplist(cvar_string("_g_maplist_add"));
+		cvar_set("_g_maplist_add", "");
+	}
+	if(cvar_string("_g_maplist_remove") != "")
+	{
+		RemoveFromMaplist(cvar_string("_g_maplist_remove"));
+		cvar_set("_g_maplist_remove", "");
+	}
 	if(cvar("_g_maplist_shufflenow") || (cvar("g_maplist_shuffle") && !cvar("_g_maplist_have_shuffled")))
 	{
 		ShuffleMaplist();




More information about the nexuiz-commits mailing list