From 48bdd4238e44df9596cb556f905550d50ebb65e2 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 26 Dec 2024 02:13:13 +0300 Subject: [PATCH] engine: always include reason to server shutdown --- engine/client/cl_demo.c | 2 +- engine/client/cl_main.c | 3 ++- engine/common/common.h | 1 - engine/common/host.c | 7 +------ engine/server/sv_cmds.c | 2 +- engine/server/sv_init.c | 3 ++- 6 files changed, 7 insertions(+), 11 deletions(-) diff --git a/engine/client/cl_demo.c b/engine/client/cl_demo.c index bbb7973c..82d26bb1 100644 --- a/engine/client/cl_demo.c +++ b/engine/client/cl_demo.c @@ -724,7 +724,7 @@ static void CL_DemoStartPlayback( int mode ) { // NOTE: at this point demo is still valid CL_Disconnect(); - Host_ShutdownServer(); + SV_Shutdown( "Server was killed due to demo playback start\n" ); Con_FastClose(); UI_SetActiveMenu( false ); diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 8847b77e..d59ec323 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -1401,7 +1401,8 @@ static void CL_Connect_f( void ) Q_strncpy( server, Cmd_Argv( 1 ), sizeof( server )); // if running a local server, kill it and reissue - if( SV_Active( )) Host_ShutdownServer(); + if( SV_Active( )) + SV_Shutdown( "Server was killed due to connection to remote server\n" ); NET_Config( true, !cl_nat.value ); // allow remote Con_Printf( "server %s\n", server ); diff --git a/engine/common/common.h b/engine/common/common.h index 28298bc9..cae534ec 100644 --- a/engine/common/common.h +++ b/engine/common/common.h @@ -555,7 +555,6 @@ void Host_WriteServerConfig( const char *name ); void Host_WriteOpenGLConfig( void ); void Host_WriteVideoConfig( void ); void Host_WriteConfig( void ); -void Host_ShutdownServer( void ); void Host_Error( const char *error, ... ) FORMAT_CHECK( 1 ); void Host_ValidateEngineFeatures( uint32_t mask, uint32_t features ); void Host_Frame( double time ); diff --git a/engine/common/host.c b/engine/common/host.c index 563c0658..d708dfd0 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -237,11 +237,6 @@ static void Sys_PrintBugcompUsage( const char *exename ) Sys_Quit(); } -void Host_ShutdownServer( void ) -{ - SV_Shutdown( "Server was killed\n" ); -} - /* ================ Host_PrintEngineFeatures @@ -841,7 +836,7 @@ void GAME_EXPORT Host_Error( const char *error, ... ) COM_InitHostState(); Cbuf_Clear(); - Host_ShutdownServer(); + SV_Shutdown( "Server was killed due to an error\n" ); CL_Drop(); // drop clients // recreate world if needs diff --git a/engine/server/sv_cmds.c b/engine/server/sv_cmds.c index 4297cf29..2a7c34f1 100644 --- a/engine/server/sv_cmds.c +++ b/engine/server/sv_cmds.c @@ -846,7 +846,7 @@ Kick everyone off, possibly in preparation for a new game */ static void SV_KillServer_f( void ) { - Host_ShutdownServer(); + SV_Shutdown( "Server was killed due to shutdownserver command\n" ); } /* diff --git a/engine/server/sv_init.c b/engine/server/sv_init.c index 31444a1a..c11a4537 100644 --- a/engine/server/sv_init.c +++ b/engine/server/sv_init.c @@ -805,7 +805,8 @@ static void SV_SetupClients( void ) if( !changed_maxclients ) return; // nothing to change // if clients count was changed we need to run full shutdown procedure - if( svs.maxclients ) Host_ShutdownServer(); + if( svs.maxclients ) + SV_Shutdown( "Server was killed due to maxclients change\n" ); // copy the actual value from cvar svs.maxclients = (int)sv_maxclients.value;