From 02fc573e31f5af3de819a9dbaa1e41f604a69afa Mon Sep 17 00:00:00 2001 From: smallmodel <15067410+smallmodel@users.noreply.github.com> Date: Tue, 21 Jan 2025 22:56:05 +0100 Subject: [PATCH] Apply client and server config tweaks when loading the original config --- code/client/cl_main.cpp | 18 ++++++++++++++++++ code/client/client.h | 1 + code/qcommon/common.c | 7 ++++++- code/qcommon/qcommon.h | 1 + code/server/server.h | 2 ++ code/server/sv_init.c | 14 ++++++++++++++ 6 files changed, 42 insertions(+), 1 deletion(-) diff --git a/code/client/cl_main.cpp b/code/client/cl_main.cpp index 3bcf0628..2f8ffd8c 100644 --- a/code/client/cl_main.cpp +++ b/code/client/cl_main.cpp @@ -3685,6 +3685,12 @@ void CL_Init( void ) { end = Sys_Milliseconds(); + if (com_gotOriginalConfig) { + // Added in OPM + // Apply config tweaks after loading the original config + CL_ApplyOriginalConfigTweaks(); + } + Com_Printf( "----- Client Initialization Complete ----- %i ms\n", start - end ); } @@ -4861,3 +4867,15 @@ void TIKI_CG_Command_ProcessFile(char* filename, qboolean quiet, dtiki_t* curTik Com_Printf("NO CGE \n"); } + +void CL_ApplyOriginalConfigTweaks() +{ + cvar_t* snaps = Cvar_Get("snaps", "", 0); + + // Those variables are not editable via UI so reset them + // snaps/maxpackets can also have wrong values due to them being changed + // via stufftext + + Cvar_Set("snaps", snaps->resetString); + Cvar_Set("cl_maxpackets", cl_maxpackets->resetString); +} diff --git a/code/client/client.h b/code/client/client.h index 7c15b003..c693fbe8 100644 --- a/code/client/client.h +++ b/code/client/client.h @@ -561,6 +561,7 @@ qboolean CL_CheckPaused(void); int CL_GetRefSequence(void); qboolean CL_IsRendererLoaded(void); +void CL_ApplyOriginalConfigTweaks(); // // cl_input diff --git a/code/qcommon/common.c b/code/qcommon/common.c index fe7a33ed..f340d246 100644 --- a/code/qcommon/common.c +++ b/code/qcommon/common.c @@ -144,6 +144,7 @@ qboolean com_errorEntered = qfalse; qboolean com_fullyInitialized = qfalse; qboolean com_gameRestarting = qfalse; qboolean com_gameClientRestarting = qfalse; +qboolean com_gotOriginalConfig = qfalse; char com_errorMessage[MAXPRINTMSG]; @@ -1695,6 +1696,7 @@ void Com_Init( char *commandLine ) { const char *s; char configname[ 128 ]; int qport; + qboolean configExists; Com_Printf( "--- Common Initialization ---\n" ); @@ -1794,9 +1796,12 @@ void Com_Init( char *commandLine ) { Cvar_Set( "config", configname ); Com_Printf( "Config: %s\n", configname ); - if ( !Com_ConfigExists( configname )) { + configExists = Com_ConfigExists(configname); + + if ( !configExists ) { Com_Printf( "The config file '%s' doesn't exist, using unnamedsoldier.cfg as a template\n", configname ); Cbuf_AddText( va( "exec configs/unnamedsoldier.cfg\n", configname ) ); + com_gotOriginalConfig = qtrue; } else { Cbuf_AddText( va( "exec configs/%s\n", configname ) ); } diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index dd06a54a..d1fd7a1e 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -1074,6 +1074,7 @@ extern int com_frameMsec; extern qboolean com_errorEntered; extern qboolean com_fullyInitialized; +extern qboolean com_gotOriginalConfig; extern fileHandle_t com_journalFile; extern fileHandle_t com_journalDataFile; diff --git a/code/server/server.h b/code/server/server.h index 9ef4134c..1322ba59 100644 --- a/code/server/server.h +++ b/code/server/server.h @@ -489,6 +489,8 @@ void SV_SpawnServer( const char *server, qboolean loadgame, qboolean restart, qb int SV_PVSSoundIndex(const char* name, qboolean streamed); void SV_HandleNonPVSSound(); +void SV_ApplyOriginalConfigTweaks(); + // // sv_client.c diff --git a/code/server/sv_init.c b/code/server/sv_init.c index 3c96d2d4..3686f3b7 100644 --- a/code/server/sv_init.c +++ b/code/server/sv_init.c @@ -1109,6 +1109,12 @@ void SV_Init (void) // Load saved bans Cbuf_AddText("rehashbans\n"); + + if (com_gotOriginalConfig) { + // Added in OPM + // Apply config tweaks after loading the original config + SV_ApplyOriginalConfigTweaks(); + } } @@ -1325,3 +1331,11 @@ void SV_HandleNonPVSSound() SV_CleanupNonPVSSound(); } +/* +=============== +SV_ApplyOriginalConfigTweaks +=============== +*/ +void SV_ApplyOriginalConfigTweaks() +{ +}