]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
now runs scripts at startup differently - runs scripts twice, once only executing...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 1 Jan 2004 02:35:56 +0000 (02:35 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 1 Jan 2004 02:35:56 +0000 (02:35 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3772 d7cf8633-e32d-0410-b094-e92efae38249

client.h
cmd.c
cvar.c
host.c
host_cmd.c
sv_main.c
todo

index 578cd68443b99772f5172e0fa75b4981d864706a..69fd11952aa0fca52e1293186ea0467c92c0d353 100644 (file)
--- a/client.h
+++ b/client.h
@@ -659,7 +659,5 @@ extern mempool_t *cl_refdef_mempool;
 
 #include "cgamevm.h"
 
-void Host_PerformSpawnServerAndLoadGame(void);
-
 #endif
 
diff --git a/cmd.c b/cmd.c
index 24c4c6351f2928f7fa5dfec70c1b7c5eccf69aa9..47a4692848f7363e2c4c3c89c6a697013a5d2c14 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -809,30 +809,36 @@ void Cmd_ExecuteString (const char *text, cmd_source_t src)
                return;         // no tokens
        }
 
-// check functions
-       for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
+// check functions (only after host_initialized)
+       if (host_initialized || !strcasecmp(cmd_argv[0], "exec"))
        {
-               if (!strcasecmp (cmd_argv[0],cmd->name))
+               for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
                {
-                       cmd->function ();
-                       cmd_tokenizebufferpos = oldpos;
-                       return;
+                       if (!strcasecmp (cmd_argv[0],cmd->name))
+                       {
+                               cmd->function ();
+                               cmd_tokenizebufferpos = oldpos;
+                               return;
+                       }
                }
        }
 
-// check alias
-       for (a=cmd_alias ; a ; a=a->next)
+// check alias (only after host_initialized)
+       if (host_initialized)
        {
-               if (!strcasecmp (cmd_argv[0], a->name))
+               for (a=cmd_alias ; a ; a=a->next)
                {
-                       Cbuf_InsertText (a->value);
-                       cmd_tokenizebufferpos = oldpos;
-                       return;
+                       if (!strcasecmp (cmd_argv[0], a->name))
+                       {
+                               Cbuf_InsertText (a->value);
+                               cmd_tokenizebufferpos = oldpos;
+                               return;
+                       }
                }
        }
 
-// check cvars
-       if (!Cvar_Command ())
+// check cvars (always)
+       if (!Cvar_Command () && host_initialized)
                Con_Printf ("Unknown command \"%s\"\n", Cmd_Argv(0));
 
        cmd_tokenizebufferpos = oldpos;
diff --git a/cvar.c b/cvar.c
index fb7cb18d097d77466c42c1636b160c2412eeff77..db209739fd3c4995e4051fdc8ea7eedc7f797cf2 100644 (file)
--- a/cvar.c
+++ b/cvar.c
@@ -315,7 +315,9 @@ qboolean    Cvar_Command (void)
 // perform a variable print or set
        if (Cmd_Argc() == 1)
        {
-               Con_Printf ("\"%s\" is \"%s\"\n", v->name, v->string);
+               // only print if host_initialized (otherwise it could print twice if this is in a script)
+               if (host_initialized)
+                       Con_Printf ("\"%s\" is \"%s\"\n", v->name, v->string);
                return true;
        }
 
diff --git a/host.c b/host.c
index 69e980f1217a76fc0ae0aa36596bebff53c1a7d4..89e5dab93e4f1ba2296262eb3a8d4b68850623e0 100644 (file)
--- a/host.c
+++ b/host.c
@@ -136,8 +136,6 @@ void PRVM_ProcessError(void);
 static char hosterrorstring1[4096];
 static char hosterrorstring2[4096];
 static qboolean hosterror = false;
-extern char sv_spawnmap[MAX_QPATH];
-extern char sv_loadgame[MAX_OSPATH];
 void Host_Error (const char *error, ...)
 {
        va_list argptr;
@@ -159,10 +157,6 @@ void Host_Error (const char *error, ...)
 
        strcpy(hosterrorstring2, hosterrorstring1);
 
-       // make sure we don't get in a loading loop
-       sv_loadgame[0] = 0;
-       sv_spawnmap[0] = 0;
-
        CL_Parse_DumpPacket();
 
        PR_Crash();
@@ -716,9 +710,6 @@ void _Host_Frame (float time)
        // process console commands
        Cbuf_Execute();
 
-       // LordHavoc: map and load are delayed until video is initialized
-       Host_PerformSpawnServerAndLoadGame();
-
        // if running the server locally, make intentions now
        if (cls.state == ca_connected && sv.active)
                CL_SendCmd(&cmd);
@@ -883,10 +874,8 @@ void Host_Init (void)
                CL_Init();
        }
 
-       Cbuf_InsertText ("exec quake.rc\n");
-       Cbuf_Execute();
-       Cbuf_Execute();
-       Cbuf_Execute();
+       // only cvars are executed when host_initialized == false
+       Cbuf_InsertText("exec quake.rc\n");
        Cbuf_Execute();
 
        host_initialized = true;
@@ -899,6 +888,11 @@ void Host_Init (void)
                SCR_BeginLoadingPlaque();
                MR_Init();
        }
+
+       // stuff it again so the first host frame will execute it again, this time
+       // in its entirety
+       Cbuf_InsertText("exec quake.rc\n");
+       Cbuf_Execute();
 }
 
 
index 528af90a599c6503c00eec09d7532ebde48feac9..429af4b494bf17979b9b27c0a120101f6e047364 100644 (file)
@@ -21,9 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "quakedef.h"
 
 int current_skill;
-char sv_spawnmap[MAX_QPATH];
-char sv_loadgame[MAX_OSPATH];
-
 cvar_t sv_cheats = {0, "sv_cheats", "0"};
 qboolean allowcheats = false;
 
@@ -272,6 +269,8 @@ command from the console.  Active clients are kicked off.
 */
 void Host_Map_f (void)
 {
+       char level[MAX_QPATH];
+
        if (cmd_source != src_command)
                return;
 
@@ -283,11 +282,12 @@ void Host_Map_f (void)
        key_dest = key_game;                    // remove console or menu
        SCR_BeginLoadingPlaque ();
 
-
        svs.serverflags = 0;                    // haven't completed an episode yet
-       strcpy (sv_spawnmap, Cmd_Argv(1));
-       if (host_initialized)
-               Host_PerformSpawnServerAndLoadGame();
+       allowcheats = sv_cheats.integer != 0;
+       strcpy(level, Cmd_Argv(1));
+       SV_SpawnServer(level);
+       if (sv.active && cls.state == ca_disconnected)
+               CL_EstablishConnection("local");
 }
 
 /*
@@ -299,6 +299,8 @@ Goes to a new map, taking all clients along
 */
 void Host_Changelevel_f (void)
 {
+       char level[MAX_QPATH];
+       
        if (Cmd_Argc() != 2)
        {
                Con_Printf ("changelevel <levelname> : continue game on a new level\n");
@@ -310,9 +312,11 @@ void Host_Changelevel_f (void)
                return;
        }
        SV_SaveSpawnparms ();
-       strcpy (sv_spawnmap, Cmd_Argv(1));
-       if (host_initialized)
-               Host_PerformSpawnServerAndLoadGame();
+       allowcheats = sv_cheats.integer != 0;
+       strcpy(level, Cmd_Argv(1));
+       SV_SpawnServer(level);
+       if (sv.active && cls.state == ca_disconnected)
+               CL_EstablishConnection("local");
 }
 
 /*
@@ -324,14 +328,18 @@ Restarts the current server for a dead player
 */
 void Host_Restart_f (void)
 {
+       char mapname[MAX_QPATH];
+       
        if (cls.demoplayback || !sv.active)
                return;
 
        if (cmd_source != src_command)
                return;
-       strcpy (sv_spawnmap, sv.name);
-       if (host_initialized)
-               Host_PerformSpawnServerAndLoadGame();
+       allowcheats = sv_cheats.integer != 0;
+       strcpy(mapname, sv.name);
+       SV_SpawnServer(mapname);
+       if (sv.active && cls.state == ca_disconnected)
+               CL_EstablishConnection("local");
 }
 
 /*
@@ -502,25 +510,9 @@ Host_Loadgame_f
 ===============
 */
 void Host_Loadgame_f (void)
-{
-       if (cmd_source != src_command)
-               return;
-
-       if (Cmd_Argc() != 2)
-       {
-               Con_Printf ("load <savename> : load a game\n");
-               return;
-       }
-
-       strcpy (sv_loadgame, Cmd_Argv(1));
-       FS_DefaultExtension (sv_loadgame, ".sav", sizeof (sv_loadgame));
-
-       Con_Printf ("Loading game from %s...\n", sv_loadgame);
-}
-
-void Host_PerformLoadGame(char *name)
 {
        qfile_t *f;
+       char filename[MAX_QPATH];
        char mapname[MAX_QPATH];
        float time, tfloat;
        char buf[32768];
@@ -532,9 +524,23 @@ void Host_PerformLoadGame(char *name)
        int version;
        float spawn_parms[NUM_SPAWN_PARMS];
 
+       if (cmd_source != src_command)
+               return;
+
+       if (Cmd_Argc() != 2)
+       {
+               Con_Printf ("load <savename> : load a game\n");
+               return;
+       }
+
+       strcpy (filename, Cmd_Argv(1));
+       FS_DefaultExtension (filename, ".sav", sizeof (filename));
+
+       Con_Printf ("Loading game from %s...\n", filename);
+
        cls.demonum = -1;               // stop demo loop in case this fails
 
-       f = FS_Open (name, "r", false);
+       f = FS_Open (filename, "r", false);
        if (!f)
        {
                Con_Printf ("ERROR: couldn't open.\n");
@@ -1572,7 +1578,7 @@ void Host_Startdemos_f (void)
 
        if (cls.state == ca_dedicated || COM_CheckParm("-listen"))
        {
-               if (!sv.active && !sv_spawnmap[0])
+               if (!sv.active)
                {
                        if (gamemode == GAME_TRANSFUSION)
                                Cbuf_AddText ("map bb1\n");
@@ -1638,25 +1644,6 @@ void Host_Stopdemo_f (void)
        CL_Disconnect ();
 }
 
-// LordHavoc: because we don't want to load things before the video starts,
-// we have to delay map and game loads until AFTER video is initialized
-void Host_PerformSpawnServerAndLoadGame(void)
-{
-       if (vid_hidden && cls.state != ca_dedicated)
-               return;
-       if (sv_loadgame[0])
-               Host_PerformLoadGame(sv_loadgame);
-       else if (sv_spawnmap[0])
-       {
-               allowcheats = sv_cheats.integer != 0;
-               SV_SpawnServer(sv_spawnmap);
-       }
-       sv_loadgame[0] = 0;
-       sv_spawnmap[0] = 0;
-       if (sv.active && cls.state == ca_disconnected)
-               Cbuf_AddText ("connect local");
-}
-
 static void MaxPlayers_f(void)
 {
        int n;
index 832b3b245042eef4c78d6ff53dd8e3b5ad280231..afc29be8f473b0faf8d2e350685c95258b9cb8ef 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -1771,7 +1771,11 @@ void SV_SpawnServer (const char *server)
        if (sv.active)
                SV_SendReconnect();
        else
+       {
+               // make sure cvars have been checked before opening the ports
+               NetConn_ServerFrame();
                NetConn_OpenServerPorts(true);
+       }
 
 //
 // make cvars consistant
diff --git a/todo b/todo
index 06748d5f9ad40f7650fb11125736ec7c11f5748a..9d879363b567067f02dd7e79eece761c72bec9b1 100644 (file)
--- a/todo
+++ b/todo
 -n darkplaces: server is starting before the "port" cvar is set by commandline and scripts? (yummyluv)
 -n darkplaces: typing ip in join game menu should show 'trying' and 'no response' after a while, or 'no network' if networking is not initialized (yummyluv)
 -n dpmod: make grapple off-hand (joe hill)
+0 darkplaces: add GL_EXT_stencil_two_side support to shadow rendering (fuh)
 0 darkplaces: mini scoreboard (the deathmatch overlay) shows player names multiple times in some cases?
 4 darkplaces: add qw protocol support (making darkplaces work as a qwcl client) (tell Fuh)
 0 darkplaces: add some cl_explosions_ cvars to control settings - start alpha, end alpha, start size, end size, life time (Supajoe, Mercury)
 0 darkplaces: "edict -1" and other invalid numbers cause an error, should just complain (Supajoe)
 2 darkplaces: add another TE_TELEPORT effect that spawns particles at a model's vertices (Urre)
 0 darkplaces: change sky handling to draw sky even if fog is on (Deej, C0burn)
-3 darkplaces: redesign startup script handling to simply stop execution until video inits, when it encounters certain commands (instead of delaying those commands)
+3 darkplaces: redesign startup script handling to scan scripts for cvars (ignoring commands) and then init video and then run the scripts for real
 d darkplaces: physics bug: rotating bmodels stop when the player blocks them instead of pushing the player
 d darkplaces: physics bug: fiends can leap through the player (thanks to Tomaz for massive assistance in tracking down this longstanding bug)
 -n darkplaces: physics bug: bmodels (doors, etc) hurt player if player pushes against it, and sometimes gets stuck for a frame when falling onto it (Andrew A. Gilevsky)
@@ -57,11 +58,11 @@ d darkplaces: add cvar_string builtin (Paul Timofeyev)
 d darkplaces: add DP_LITSUPPORT extension and document it
 0 darkplaces: add DP_SV_ROTATINGBMODEL extension to explain that MOVETYPE_PUSH/SOLID_BSP support rotation in darkplaces and a demonstration of how to use it without qc modifications (Uffe, Supajoe)
 0 darkplaces: add Draw2D function to model struct to make it easy to draw models without an entity (Tomaz)
-0 darkplaces: add _reflect textures which filter use of skybox as a cubemap reflection (FrikaC)
+4 darkplaces: add _reflect textures which filter use of skybox as a cubemap reflection (FrikaC)
 0 darkplaces: add a .collision_cancollide QC function call to decide if an entity should collide with another, or pass through it (Uffe)
 0 darkplaces: add a clipmask thingy to allow QC to mask off collisions as it wishes (Uffe)
 -n darkplaces: add a config saving command (Speeds)
-0 darkplaces: add a loading screen (gfx/loadback.tga or the loading plaque if that's not found) before loading commences so that people have something to look at when the engine starts... (SeienAbunae)
+2 darkplaces: add a loading screen (gfx/loadback.tga or the loading plaque if that's not found) before loading commences so that people have something to look at when the engine starts... (SeienAbunae)
 -n darkplaces: add a scr_screenshot_jpeg_quality cvar (Electro)
 0 darkplaces: add ability to load gfx/particlefont.tga (Vermeulen, frightfan, Error)
 0 darkplaces: add automatic binding to whatever address the machine's hostname resolves to (in addition to 0.0.0.0); see original quake code for examples (yummyluv)