server.cfg Map List Shuffler

Tips on how to tweak Nexuiz for the best performance

Moderators: Nexuiz Moderators, Moderators

server.cfg Map List Shuffler

Postby Sxen » Sun Oct 29, 2006 9:23 am

Hi,

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
DCC's Delight Public Server: http://delight.vapor.com/
Sxen
Member
 
Posts: 48
Joined: Mon Aug 28, 2006 8:12 am

Return to Nexuiz - Performance Tips

Who is online

Users browsing this forum: No registered users and 1 guest

cron