From ca7cbf263da2b3d19571c5522bdb625a82ac8af1 Mon Sep 17 00:00:00 2001 From: div0 Date: Fri, 8 Dec 2006 07:19:58 +0000 Subject: [PATCH] slightly more intelligent maplist editing (doesn't re-shuffle any more) git-svn-id: svn://svn.icculus.org/nexuiz/trunk@2005 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/g_world.qc | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/data/qcsrc/server/g_world.qc b/data/qcsrc/server/g_world.qc index c99ed7250..5ad2bc1d8 100644 --- a/data/qcsrc/server/g_world.qc +++ b/data/qcsrc/server/g_world.qc @@ -1267,18 +1267,18 @@ void RemoveFromMaplist(string m) 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 @@ void AddToMaplist(string m) } 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 -- 2.39.2