From cb7094bb2dc1a2c7b2bee9e0b8683f789e58d0fb Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 2 Oct 2025 18:40:13 +0500 Subject: [PATCH] engine: move setjmp for exit-in-main to the beginning of Host_Main function --- engine/common/common.h | 2 +- engine/common/host.c | 18 +++++------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/engine/common/common.h b/engine/common/common.h index 6650f70f..7d7450c6 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -577,7 +577,7 @@ void Host_Error( const char *error, ... ) FORMAT_CHECK( 1 ); void Host_ValidateEngineFeatures( uint32_t mask, uint32_t features ); void Host_Frame( double time ); void Host_Credits( void ); -void Host_ExitInMain( void ); +void Host_ExitInMain( void ) NORETURN; // // host_state.c diff --git a/engine/common/host.c b/engine/common/host.c index 2ead6ca0..33b96a4f 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -37,8 +37,8 @@ GNU General Public License for more details. #include "render_api.h" // decallist_t #include "tests.h" -static pfnChangeGame pChangeGame = NULL; -host_parm_t host; // host parms +host_parm_t host; // host parms +static pfnChangeGame pChangeGame = NULL; static jmp_buf return_from_main_buf; /* @@ -1177,14 +1177,6 @@ static void Sys_Quit_f( void ) Sys_Quit( "command" ); } -static void Host_MainLoop( void *userdata ) -{ - double *poldtime = (double *)userdata; - double newtime = Sys_DoubleTime(); - COM_Frame( newtime - *poldtime ); - *poldtime = newtime; -} - /* ================= Host_Main @@ -1195,6 +1187,9 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa static double oldtime; string demoname, exename; + if( setjmp( return_from_main_buf )) + return error_on_exit; + host.starttime = Sys_DoubleTime(); pChangeGame = func; // may be NULL @@ -1338,9 +1333,6 @@ int EXPORT Host_Main( int argc, char **argv, const char *progname, int bChangeGa // check after all configs were executed HPAK_CheckIntegrity( hpk_custom_file.string ); - if( setjmp( return_from_main_buf )) - return error_on_exit; - // main window message loop while( host.status != HOST_CRASHED ) {