From e0d1a396964f10f7d2c737e1dabe893201835121 Mon Sep 17 00:00:00 2001
From: cloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Date: Sun, 21 Jun 2020 20:39:05 +0000
Subject: [PATCH] Partially revert r12699 pending better solution

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12713 d7cf8633-e32d-0410-b094-e92efae38249
---
 cl_main.c | 1 -
 cmd.c     | 4 ++++
 host.c    | 6 ++++++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/cl_main.c b/cl_main.c
index b03292c9..e17cc44f 100644
--- a/cl_main.c
+++ b/cl_main.c
@@ -2776,7 +2776,6 @@ void CL_Init (void)
 		CL_MeshEntities_Init();
 
 		CL_Video_Init();
-		Host_StartVideo();
 
 		#ifdef CONFIG_MENU
 		Cbuf_InsertText(&cmd_client,"menu_start\n");
diff --git a/cmd.c b/cmd.c
index f7d84dc2..095d63b5 100644
--- a/cmd.c
+++ b/cmd.c
@@ -410,6 +410,10 @@ static void Cmd_StuffCmds_f (cmd_state_t *cmd)
 	int		i, j, l;
 	// 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.state == host_init)
+		return;
 
 	if (Cmd_Argc (cmd) != 1)
 	{
diff --git a/host.c b/host.c
index 1b935c7e..85096e39 100644
--- a/host.c
+++ b/host.c
@@ -1286,6 +1286,8 @@ static void Host_Init (void)
 
 	Host_AddConfigText(cmd);
 
+	Host_StartVideo();
+
 	// if quake.rc is missing, use default
 	if (!FS_FileExists("quake.rc"))
 	{
@@ -1295,6 +1297,10 @@ static void Host_Init (void)
 
 	host.state = host_active;
 
+	// 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.5