engine: client: always load client.dll last to crash on nullptr in mods that fetch cvar pointers early, add comment for anyone who would modify this file

This commit is contained in:
Alibek Omarov
2026-05-05 01:15:16 +05:00
parent fdb59e990e
commit e6a44b70e0
4 changed files with 16 additions and 12 deletions

View File

@@ -3723,15 +3723,16 @@ void CL_Init( void )
COM_GetCommonLibraryPath( LIBRARY_CLIENT, libpath, sizeof( libpath ));
if( !CL_LoadProgs( libpath ))
Host_Error( "can't initialize %s: %s\n", libpath, COM_GetLibraryError( ));
S_Init(); // init sound
Voice_Init( VOICE_DEFAULT_CODEC, 3, true ); // init voice (do not open the device)
ID_Init();
SteamBroker_Init();
// client must be always initialized last so it can fetch all cvars
if( !CL_LoadProgs( libpath ))
Host_Error( "can't initialize %s: %s\n", libpath, COM_GetLibraryError( ));
cls.build_num = 0;
cls.initialized = true;
cl.maxclients = 1; // allow to drawing player in menu

View File

@@ -4132,6 +4132,7 @@ qboolean CL_LoadProgs( const char *name )
clgame.dllFuncs.pfnInit();
CL_InitStudioAPI();
S_InitSoundAPI();
return true;
}

View File

@@ -99,6 +99,7 @@ void SX_RoomFX( portable_samplepair_t *paint, int num_samples );
void SX_ClearState( void );
qboolean S_Init( void );
qboolean S_InitSoundAPI( void );
void S_Shutdown( void );
void S_SoundList_f( void );
void S_SoundInfo_f( void );

View File

@@ -1948,7 +1948,7 @@ static const sound_api_t gSoundAPI = {
S_InitSoundAPI
================
*/
static qboolean S_InitSoundAPI( void )
qboolean S_InitSoundAPI( void )
{
// make sure what sound functions is cleared
memset( &clgame.soundFuncs, 0, sizeof( clgame.soundFuncs ));
@@ -1967,6 +1967,9 @@ static qboolean S_InitSoundAPI( void )
memset( &clgame.soundFuncs, 0, sizeof( clgame.soundFuncs ));
}
if( clgame.soundFuncs.pfnS_Init )
clgame.soundFuncs.pfnS_Init( &snd );
return false;
}
@@ -2030,17 +2033,15 @@ qboolean S_Init( void )
S_InitSounds ();
VOX_Init ();
S_InitSoundAPI();
if( clgame.soundFuncs.pfnS_Init )
clgame.soundFuncs.pfnS_Init( &snd );
return true;
}
// =======================================================================
// Shutdown sound engine
// =======================================================================
/*
============
S_Shutdown
============
*/
void S_Shutdown( void )
{
if( !snd.initialized ) return;