not sure whether this is appropriate for Performance Tips, but since there is no dedicated Server Operator board...

Since the map randomizer in the Nexuiz game code seems to work slightly strangely, nil and I hacked together a small awk/bsh script which randomizes the maplist in the server.cfg (also updating the currently running server using rcon):
- Code: Select all
shufflemaplist.sh
#!/bin/bash
MAPFILE="/home/nexserv/Nexuiz/data/$1.cfg"
MAPFILETMP="$MAPFILE.tmp"
cat >/tmp/mapshuffle.awk <<"EOF"
/set \"g_maplist\"/ {
split($3,maps,"''|'|\"")
for(i in maps)
{
if(maps[i])
ma[cnt++]=maps[i]
}
srand()
mapcmd="set \"g_maplist\" \"";
for(c=0;c<cnt;c++)
{
while(1)
{
x=int(rand()*cnt)
if(ma[x])
{
mapcmd=mapcmd "'" ma[x] "'"
ma[x]=""
break
}
}
}
mapcmd=mapcmd "\""
print mapcmd
if(port)
system("rcon >/dev/null 2>&1 127.0.0.1:" port " `cat ~/.rconpass` " mapcmd)
next
}
{
print $0
}
EOF
mv $MAPFILE $MAPFILETMP
awk -f /tmp/mapshuffle.awk -vport=$2 <$MAPFILETMP >$MAPFILE
The embedded AWK code in the shell script scans the code input file for a line of the form
- Code: Select all
set "g_maplist" "'mapname''mapname''mapname''"
splits it into individual mapnames and reassembles it in random order. It then outputs the new line and also sends the command to the running server instance using the rcon command.
We then call this once a night using cron
- Code: Select all
shufflemaplist.sh server 26000
shufflemaplist.sh server-minsta 26002
shufflemaplist.sh server-tdm 26003
shufflemaplist.sh server-newbie 26004
Sxen