engine: add a function that validates requested features bits

This commit is contained in:
Alibek Omarov 2024-01-04 05:09:36 +03:00
parent 49f972a7c9
commit ce73838f1b
4 changed files with 36 additions and 10 deletions

View File

@ -903,11 +903,7 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), sizeof( clgame.maptitle )); Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), sizeof( clgame.maptitle ));
background = MSG_ReadOneBit( msg ); background = MSG_ReadOneBit( msg );
Q_strncpy( gamefolder, MSG_ReadString( msg ), sizeof( gamefolder )); Q_strncpy( gamefolder, MSG_ReadString( msg ), sizeof( gamefolder ));
host.features = (uint)MSG_ReadLong( msg ); Host_ValidateEngineFeatures( MSG_ReadDword( msg ));
host.features &= legacy ? ENGINE_LEGACY_FEATURES_MASK : ENGINE_FEATURES_MASK;
if( !Host_IsLocalGame( ))
Host_PrintEngineFeatures( host.features );
if( !legacy ) if( !legacy )
{ {

View File

@ -554,7 +554,7 @@ qboolean Host_IsLocalGame( void );
qboolean Host_IsLocalClient( void ); qboolean Host_IsLocalClient( void );
void Host_ShutdownServer( void ); void Host_ShutdownServer( void );
void Host_Error( const char *error, ... ) _format( 1 ); void Host_Error( const char *error, ... ) _format( 1 );
void Host_PrintEngineFeatures( int features ); void Host_ValidateEngineFeatures( uint32_t features );
void Host_Frame( float time ); void Host_Frame( float time );
void Host_InitDecals( void ); void Host_InitDecals( void );
void Host_Credits( void ); void Host_Credits( void );

View File

@ -190,7 +190,7 @@ void Host_ShutdownServer( void )
Host_PrintEngineFeatures Host_PrintEngineFeatures
================ ================
*/ */
void Host_PrintEngineFeatures( int features ) static void Host_PrintEngineFeatures( int features )
{ {
const char *features_str[] = const char *features_str[] =
{ {
@ -213,6 +213,36 @@ void Host_PrintEngineFeatures( int features )
} }
} }
/*
==============
Host_ValidateEngineFeatures
validate features bits and set host.features
==============
*/
void Host_ValidateEngineFeatures( uint32_t features )
{
uint32_t mask = ENGINE_FEATURES_MASK;
#if !HOST_DEDICATED
if( !Host_IsDedicated( ) && cls.legacymode )
mask = ENGINE_LEGACY_FEATURES_MASK;
#endif
// don't allow unsupported bits
features &= mask;
// print requested first
Host_PrintEngineFeatures( features );
// now warn about incompatible bits
if( FBitSet( features, ENGINE_STEP_POSHISTORY_LERP|ENGINE_COMPUTE_STUDIO_LERP ))
Con_Printf( S_WARN "%s: incompatible ENGINE_STEP_POSHISTORY_LERP and ENGINE_COMPUTE_STUDIO_LERP are enabled!\n", __func__ );
// finally set global variable
host.features = features;
}
/* /*
============== ==============
Host_IsQuakeCompatible Host_IsQuakeCompatible

View File

@ -2139,18 +2139,18 @@ qboolean SV_InitPhysicsAPI( void )
if( svgame.physFuncs.SV_CheckFeatures != NULL ) if( svgame.physFuncs.SV_CheckFeatures != NULL )
{ {
// grab common engine features (it will be shared across the network) // grab common engine features (it will be shared across the network)
host.features = svgame.physFuncs.SV_CheckFeatures() & ENGINE_FEATURES_MASK; Host_ValidateEngineFeatures( svgame.physFuncs.SV_CheckFeatures( ));
Host_PrintEngineFeatures( host.features );
} }
return true; return true;
} }
// make sure what physic functions is cleared // make sure what physic functions is cleared
memset( &svgame.physFuncs, 0, sizeof( svgame.physFuncs )); memset( &svgame.physFuncs, 0, sizeof( svgame.physFuncs ));
Host_ValidateEngineFeatures( 0 );
return false; // just tell user about problems return false; // just tell user about problems
} }
// physic interface is missed // physic interface is missed
Host_ValidateEngineFeatures( 0 );
return true; return true;
} }