From 18fec25aab414d16592acda89084369a2cfb5e37 Mon Sep 17 00:00:00 2001 From: div0 Date: Fri, 6 Mar 2009 09:40:41 +0000 Subject: [PATCH] Radical change (please test): allow sv_cmd commands in server.cfg; automatically execute server.cfg on dedicated servers This is done by making a tiny bsp file _init/_init.bsp that causes server initialization to take place. Result: aggressor is no longer forcefully loaded as first map, so servers should start up a little faster now. git-svn-id: svn://svn.icculus.org/nexuiz/trunk@6053 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/defaultNexuiz.cfg | 2 +- data/maps/_init/_init.bsp | Bin 0 -> 3136 bytes data/maps/_init/_init.map | 12 +++++++ data/qcsrc/server/g_world.qc | 58 ++++++++++++++++++++++---------- data/server.cfg | 8 +++++ server/server_havoc_linux.sh | 2 +- server/server_havoc_mac.sh | 2 +- server/server_havoc_windows.bat | 2 +- server/server_linux.sh | 2 +- server/server_mac.sh | 2 +- server/server_windows.bat | 2 +- 11 files changed, 68 insertions(+), 24 deletions(-) create mode 100644 data/maps/_init/_init.bsp create mode 100644 data/maps/_init/_init.map create mode 100644 data/server.cfg diff --git a/data/defaultNexuiz.cfg b/data/defaultNexuiz.cfg index 87b9779a0..2f0e95d08 100644 --- a/data/defaultNexuiz.cfg +++ b/data/defaultNexuiz.cfg @@ -736,7 +736,7 @@ sv_sound_watersplash "" seta cl_hitsound 1 // startmap_dm is used when running with the -listen or -dedicated commandline options -alias startmap_dm "set _sv_init 1; map aggressor" +alias startmap_dm "set _sv_init 0; map _init/_init; exec server.cfg; set _sv_init 1" // aliases: alias +attack2 +button3 diff --git a/data/maps/_init/_init.bsp b/data/maps/_init/_init.bsp new file mode 100644 index 0000000000000000000000000000000000000000..fc9e04c8412b9410c4b394ad5e05607b64bbe93b GIT binary patch literal 3136 zcmb_eO-~b16n)@Fw3^7mh3;Ou(giS-pg>|6j2cNKVoXe2)k!;vjdY4_Atc76KZT|L zz$N?)miz!0F8#)P=DqXgb|{ERZ~ErGckj99e#~^*wTCY^W{fePt{L-I^r5V$vh0L0 z2cq9xaJC~k4`lT(8nY|*FQVmRzRKl}=ta@jML!Z9iN1A7IAlL1Mx3D`i&u@=nsoV` z#a)pf5_{a5efIp-W4r#^zL;NM-Kg2x%)-pv{cO6olhvXn+sW*cZp*GGU2E^zxoCNA zaXDJBwJ2Ju+%<=v`{{0fyPNiA8=ZE$lg&1g?ag;C#ksH2uE=0T1q|f8ug+?llS@%6+O9;D{xE&_0fS)^vXT?fCc@3p0>g78V%f)&_AiG6ouWIEaT0 zSdEukA4JC@2Iq<_jTg#XLXgJ+%Xs>5md7;+>md&MhAi;YCXZ+k_RRX>xG78HSsSs; z!TN8P@K@ygM>;@09m5>Z5X?pUu_p$x@T0fyViygp6fzs1j|0$RsDi<-}z=9wjq|z}rdl`}3kK$bT_u^vjb_F(Y3-7M*9-V>R&cb$gzPWvw}{uQ&P!HfQoPV{fB)gUw^76tDBSndN+PVQy{1!LfKQ)f+4tOWs`jdiP=%SH{xH7|cxHW6hh#s=UB5F7WK1QLpOF)#0$< z2t2-C{j8U<%*B}v;$X=)gHQwbC%hByAG|;K4)*5%RH4qHIOai)@#F#h$z05X_w@Mk zoXo{M_^UUbJjJt*Y!v3162o}%fca!D=D~l3@#PuL^`TO&zn^a>TebR5+U>PES=CmD z{}WdWNTc1{Y-OoHrrT*h5l>??>GiUt4O_k5%3A$;Gi|mSNk47YdudlltCf%L7aPy? RB+`pO<2MvSJ8am){uh<7y!-$F literal 0 HcmV?d00001 diff --git a/data/maps/_init/_init.map b/data/maps/_init/_init.map new file mode 100644 index 000000000..2dcb4cb4c --- /dev/null +++ b/data/maps/_init/_init.map @@ -0,0 +1,12 @@ +{ +"classname" "__init_dedicated_server" +// brush 0 +{ +( 0 0 0 ) ( 0 1 0 ) ( 0 0 1 ) common/caulk 0 0 0 0.5 0.5 0 0 0 +( 0 0 0 ) ( 1 0 0 ) ( 0 1 0 ) common/caulk 0 0 0 0.5 0.5 0 0 0 +( 0 0 0 ) ( 0 0 1 ) ( 1 0 0 ) common/caulk 0 0 0 0.5 0.5 0 0 0 +( 1 1 1 ) ( 1 1 0 ) ( 1 0 1 ) common/caulk 0 0 0 0.5 0.5 0 0 0 +( 1 1 1 ) ( 1 0 1 ) ( 0 1 1 ) common/caulk 0 0 0 0.5 0.5 0 0 0 +( 1 1 1 ) ( 0 1 1 ) ( 1 1 0 ) common/caulk 0 0 0 0.5 0.5 0 0 0 +} +} diff --git a/data/qcsrc/server/g_world.qc b/data/qcsrc/server/g_world.qc index 3364c398e..ae53d229e 100644 --- a/data/qcsrc/server/g_world.qc +++ b/data/qcsrc/server/g_world.qc @@ -131,27 +131,38 @@ void timeoutHandler_Think() { } } -float GotoFirstMap() +void GotoFirstMap() { if(cvar("_sv_init")) { - cvar_set("_sv_init", "0"); + // cvar_set("_sv_init", "0"); + // we do NOT set this to 0 any more, so someone "accidentally" changing + // to this "init" map on a dedicated server will cause no permanent + // harm if(cvar("g_maplist_shuffle")) ShuffleMaplist(); tokenizebyseparator(cvar_string("g_maplist"), " "); - { - cvar_set("nextmap", argv(0)); - MapInfo_Enumerate(); - MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 0, (g_maplist_allow_hidden ? MAPINFO_FLAG_HIDDEN : 0), 0); + cvar_set("nextmap", argv(0)); - if(!DoNextMapOverride()) - GotoNextMap(); + MapInfo_Enumerate(); + MapInfo_FilterGametype(MapInfo_CurrentGametype(), MapInfo_CurrentFeatures(), 0, (g_maplist_allow_hidden ? MAPINFO_FLAG_HIDDEN : 0), 0); - return 1; - } + if(!DoNextMapOverride()) + GotoNextMap(); + + return; + } + + if(time < 5) + { + self.nextthink = time; + } + else + { + self.nextthink = time + 1; + print("Waiting for _sv_init being set to 1 by initialization scripts...\n"); } - return 0; } void cvar_changes_init() @@ -326,6 +337,25 @@ void RandomSeed_Spawn() self = oldself; } +void spawnfunc___init_dedicated_server(void) +{ + // handler for _init/_init map (only for dedicated server initialization) + + dprint_load(); // load dprint status from cvar + world_initialized = -1; // don't complain + remove = remove_unsafely; + + entity e; + e = spawn(); + e.think = GotoFirstMap; + e.nextthink = time; // this is usually 1 at this point + + e = spawn(); + e.classname = "info_player_deathmatch"; // safeguard against player joining + + self.classname = "worldspawn"; // safeguard against various stuff ;) +} + void Map_MarkAsRecent(string m); float world_already_spawned; void RegisterWeapons(); @@ -367,12 +397,6 @@ void spawnfunc_worldspawn (void) // needs to be done so early as they would still spawn RegisterWeapons(); - if(GotoFirstMap()) - { - world_initialized = -1; // don't complain - return; - } - if(sv_cheats) ServerProgsDB = db_create(); else diff --git a/data/server.cfg b/data/server.cfg new file mode 100644 index 000000000..5cac17004 --- /dev/null +++ b/data/server.cfg @@ -0,0 +1,8 @@ +echo +echo You have not written any server.cfg file yet. +echo The server will therefore run at default settings. +echo +echo For information on how to set up a dedicated server, +echo look at the files in the server/ subdirectory of your +echo Nexuiz install. +echo diff --git a/server/server_havoc_linux.sh b/server/server_havoc_linux.sh index 6dd6d27ab..9ce82ac9a 100755 --- a/server/server_havoc_linux.sh +++ b/server/server_havoc_linux.sh @@ -6,4 +6,4 @@ case "$(uname -m)" in esac cd "`dirname "${0}"`" -exec ./${executable} -game havoc +exec server.cfg "${@}" +exec ./${executable} -game havoc "${@}" diff --git a/server/server_havoc_mac.sh b/server/server_havoc_mac.sh index 7d6ed98ec..9c1819fe0 100755 --- a/server/server_havoc_mac.sh +++ b/server/server_havoc_mac.sh @@ -3,4 +3,4 @@ executable="nexuiz-osx-dedicated" cd "`dirname "${0}"`" -exec ./${executable} -game havoc +exec server.cfg "${@}" +exec ./${executable} -game havoc "${@}" diff --git a/server/server_havoc_windows.bat b/server/server_havoc_windows.bat index 784842261..3b51ae1a2 100644 --- a/server/server_havoc_windows.bat +++ b/server/server_havoc_windows.bat @@ -5,4 +5,4 @@ set executable=nexuiz -dedicated %~d0 cd "%~p0" -.\%executable% -game havoc +exec server.cfg %* +.\%executable% -game havoc %* diff --git a/server/server_linux.sh b/server/server_linux.sh index 58b6a198b..e2dee7abe 100755 --- a/server/server_linux.sh +++ b/server/server_linux.sh @@ -6,4 +6,4 @@ case "$(uname -m)" in esac cd "`dirname "${0}"`" -exec ./${executable} +exec server.cfg "${@}" +exec ./${executable} "${@}" diff --git a/server/server_mac.sh b/server/server_mac.sh index 512401289..c64949335 100755 --- a/server/server_mac.sh +++ b/server/server_mac.sh @@ -3,4 +3,4 @@ executable="nexuiz-osx-dedicated" cd "`dirname "${0}"`" -exec ./${executable} +exec server.cfg "${@}" +exec ./${executable} "${@}" diff --git a/server/server_windows.bat b/server/server_windows.bat index 8850825ea..f5a1c6876 100644 --- a/server/server_windows.bat +++ b/server/server_windows.bat @@ -5,4 +5,4 @@ set executable=nexuiz -dedicated %~d0 cd "%~p0" -.\%executable% +exec server.cfg %* +.\%executable% %* -- 2.39.2