r1988 - in trunk/data: . qcsrc/server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Mon Dec 4 07:55:51 EST 2006
Author: div0
Date: 2006-12-04 07:55:51 -0500 (Mon, 04 Dec 2006)
New Revision: 1988
Modified:
trunk/data/default.cfg
trunk/data/qcsrc/server/g_world.qc
Log:
maplist edit commands
Modified: trunk/data/default.cfg
===================================================================
--- trunk/data/default.cfg 2006-12-03 23:30:42 UTC (rev 1987)
+++ trunk/data/default.cfg 2006-12-04 12:55:51 UTC (rev 1988)
@@ -218,6 +218,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: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc 2006-12-03 23:30:42 UTC (rev 1987)
+++ trunk/data/qcsrc/server/g_world.qc 2006-12-04 12:55:51 UTC (rev 1988)
@@ -1244,6 +1244,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;
@@ -1314,6 +1368,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