From 0435530735836f65cb6c9c2ddb271e35813a17df Mon Sep 17 00:00:00 2001
From: Rudolf Polzer <divVerent@gmail.com>
Date: Sun, 6 Apr 2025 16:52:23 -0400
Subject: [PATCH] When Host_Error is called during QC init, Sys_Error a bit
 later.

This way, we still get packed dump, client error cleanup and - most
importantly - a QC backtrace message of where the crash came from.

Very useful for debugging.
---
 host.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/host.c b/host.c
index f004bb19..031841c0 100644
--- a/host.c
+++ b/host.c
@@ -103,11 +103,7 @@ void Host_Error (const char *error, ...)
 
 	Con_Printf(CON_ERROR "Host_Error: %s\n", hosterrorstring1);
 
-	// LadyHavoc: if crashing very early, or currently shutting down, do
-	// Sys_Error instead
-	if (host.framecount < 1 || host.state != host_active)
-		Sys_Error ("Host_Error during %s: %s", host_state_str[host.state], hosterrorstring1);
-
+	// "double fault": redirect to Sys_Error.
 	if (hosterror)
 		Sys_Error ("Host_Error: recursively entered (original error was: %s    new error is: %s)", hosterrorstring2, hosterrorstring1);
 	hosterror = true;
@@ -123,6 +119,11 @@ void Host_Error (const char *error, ...)
 	if(host.hook.SV_Shutdown)
 		host.hook.SV_Shutdown();
 
+	// LadyHavoc: if crashing very early, or currently shutting down, do
+	// Sys_Error instead and exit the engine fully
+	if (host.framecount < 1 || host.state != host_active)
+		Sys_Error ("Host_Error during %s: %s", host_state_str[host.state], hosterrorstring1);
+
 	if (cls.state == ca_dedicated)
 		Sys_Error("Host_Error: %s", hosterrorstring1);        // dedicated servers exit
 
-- 
2.39.5