From 92774dc9c3e8e6efe6caa9fc226b0a507df8b487 Mon Sep 17 00:00:00 2001 From: div0 Date: Sun, 3 Dec 2006 13:07:55 +0000 Subject: [PATCH] remove stupid requirement to manually call g_maplist_shufflenow git-svn-id: svn://svn.icculus.org/nexuiz/trunk@1977 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- Docs/server/server.cfg | 1 - data/default.cfg | 2 +- data/qcsrc/server/g_world.qc | 20 ++++++++++++-------- misc/nexuiz-map-compiler | 4 +++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Docs/server/server.cfg b/Docs/server/server.cfg index ffdd92574..0b6a1e18e 100644 --- a/Docs/server/server.cfg +++ b/Docs/server/server.cfg @@ -43,7 +43,6 @@ set "bot_suffix" "" // append to all botnames set "sv_mapchange_delay" "5" // how long the pause between maps will be set "g_maplist_shuffle" "0" // if "1", the first map of g_maplist will always get chosen as next map and inserted at a random place in the list -g_maplist_shufflenow // you probably want to call this command when you use the above option // remove the // from the beginning of one g_maplist line to play those maps only // arena mode (1on1 tourney) diff --git a/data/default.cfg b/data/default.cfg index 228e7b285..821db7b15 100644 --- a/data/default.cfg +++ b/data/default.cfg @@ -217,7 +217,7 @@ seta g_maplist $g_maplist_defaultlist seta g_maplist_index 0 // this is used internally for saving position in maplist cycle 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" // call this in server.cfg when using g_maplist_shuffle +alias g_maplist_shufflenow "set _g_maplist_shufflenow 1" // timeout for kill credit when your damage knocks someone into a death trap set g_maxpushtime 8.0 diff --git a/data/qcsrc/server/g_world.qc b/data/qcsrc/server/g_world.qc index 4ade33357..30fc1476f 100644 --- a/data/qcsrc/server/g_world.qc +++ b/data/qcsrc/server/g_world.qc @@ -1249,29 +1249,29 @@ void ShuffleMaplist() { string result; float start; - float items; + float litems; float selected; float i; result = cvar_string("g_maplist"); - items = tokenize(result); + litems = tokenize(result); - for(start = 0; start < items - 1; ++start) + for(start = 0; start < litems - 1; ++start) { result = ""; // select a random item - selected = ceil(random() * (items - start) + start) - 1; + selected = ceil(random() * (litems - start) + start) - 1; // shift this item to the place start for(i = 0; i < start; ++i) result = strcat(result, "'", argv(i), "'"); result = strcat(result, "'", argv(selected), "'"); - for(i = start; i < items; ++i) + for(i = start; i < litems; ++i) if(i != selected) result = strcat(result, "'", argv(i), "'"); - items = tokenize(result); + litems = tokenize(result); dprint(result, "\n"); } @@ -1314,11 +1314,15 @@ void() CheckRules_World = PrintScoreboard(); } - if(cvar("_g_maplist_shufflenow")) + // automatically shuffle when setting g_maplist_shuffle + if(cvar("_g_maplist_shufflenow") || (cvar("g_maplist_shuffle") && !cvar("_g_maplist_have_shuffled"))) { - cvar_set("_g_maplist_shufflenow", "0"); ShuffleMaplist(); + localcmd("set _g_maplist_shufflenow 0\nset _g_maplist_have_shuffled 1\necho Shuffled map list.\n"); } + if(cvar("_g_maplist_have_shuffled")) + if(!cvar("g_maplist_shuffle")) + localcmd("set _g_maplist_have_shuffled 0\n"); timelimit = cvar("timelimit") * 60; fraglimit = cvar("fraglimit"); diff --git a/misc/nexuiz-map-compiler b/misc/nexuiz-map-compiler index 104e15501..14a238e84 100755 --- a/misc/nexuiz-map-compiler +++ b/misc/nexuiz-map-compiler @@ -100,7 +100,9 @@ while(@ARGV) sub q3map2(@) { my @args = @_; - return !system $Q3MAP2, '-game', 'quake3', '-fs_basepath', $NEXUIZDIR, '-fs_game', 'data', '-v', @_; + my @args = ($Q3MAP2, '-game', 'quake3', '-fs_basepath', $NEXUIZDIR, '-fs_game', 'data', '-v', @_); + print "\$ @args\n"; + return !system @args; } (my $mapdir = getcwd()) =~ s!/[^/]*(?:$)!!; -- 2.39.2