From 0fe5448cd48d31770768f209b302187dcdb1502c Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Thu, 4 Jun 2020 12:11:20 +0000 Subject: [PATCH] Fix the +map crash once and for all. Defer stuffcmds until it's safe to run. Check if the literal quake.rc file exists rather than using stuffcmds as an indicator of its existence, and use a new qboolean host_init to defer stuffcmds. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12632 d7cf8633-e32d-0410-b094-e92efae38249 --- cmd.c | 6 ++++++ host.c | 19 +++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/cmd.c b/cmd.c index 4f13c0a9..d1820e2c 100644 --- a/cmd.c +++ b/cmd.c @@ -397,6 +397,8 @@ void Cbuf_Frame(cmd_state_t *cmd) ============================================================================== */ +extern qboolean host_init; + /* =============== Cmd_StuffCmds_f @@ -413,6 +415,10 @@ static void Cmd_StuffCmds_f (cmd_state_t *cmd) // this is for all commandline options combined (and is bounds checked) char build[MAX_INPUTLINE]; + // come back later so we don't crash + if(host_init) + return; + if (Cmd_Argc (cmd) != 1) { Con_Print("stuffcmds : execute command line parameters\n"); diff --git a/host.c b/host.c index b4acbed6..9a3d6ace 100644 --- a/host.c +++ b/host.c @@ -47,6 +47,9 @@ Memory is cleared / released when a server or client begins, not when they end. // how many frames have occurred // (checked by Host_Error and Host_SaveConfig_f) int host_framecount = 0; + +// Cloudwalk: set when Host_Init is executed +qboolean host_init = false; // LadyHavoc: set when quit is executed qboolean host_shuttingdown = false; @@ -328,6 +331,7 @@ static void Host_AddConfigText(cmd_state_t *cmd) Cbuf_InsertText(cmd, "alias startmap_sp \"map start\"\nalias startmap_dm \"map start\"\nexec teu.rc\n"); else Cbuf_InsertText(cmd, "alias startmap_sp \"map start\"\nalias startmap_dm \"map start\"\nexec " STARTCONFIGFILENAME "\n"); + Cbuf_Execute(cmd); } /* @@ -1177,6 +1181,8 @@ static void Host_Init (void) qboolean dedicated_server = COM_CheckParm("-dedicated") || !cl_available; cmd_state_t *cmd = &cmd_client; + host_init = true; + if (COM_CheckParm("-profilegameonly")) Sys_AllowProfiling(false); @@ -1304,17 +1310,22 @@ static void Host_Init (void) } Host_AddConfigText(cmd); - Cbuf_Execute(cmd); Host_StartVideo(); - // if stuffcmds wasn't run, then quake.rc is probably missing, use default - if (!host_stuffcmdsrun) + // if quake.rc is missing, use default + if (!FS_FileExists("quake.rc")) { - Cbuf_AddText(cmd, "exec default.cfg\nexec " CONFIGFILENAME "\nexec autoexec.cfg\nstuffcmds\n"); + Cbuf_AddText(cmd, "exec default.cfg\nexec " CONFIGFILENAME "\nexec autoexec.cfg\n"); Cbuf_Execute(cmd); } + host_init = false; + + // run stuffcmds now, deferred previously because it can crash if a server starts that early + Cbuf_AddText(cmd,"stuffcmds\n"); + Cbuf_Execute(cmd); + Log_Start(); // put up the loading image so the user doesn't stare at a black screen... -- 2.39.2