Browse Source

engine: add a function that validates requested features bits

pull/2/head
Alibek Omarov 11 months ago
parent
commit
ce73838f1b
  1. 6
      engine/client/cl_parse.c
  2. 2
      engine/common/common.h
  3. 32
      engine/common/host.c
  4. 6
      engine/server/sv_phys.c

6
engine/client/cl_parse.c

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

2
engine/common/common.h

@ -554,7 +554,7 @@ qboolean Host_IsLocalGame( void ); @@ -554,7 +554,7 @@ qboolean Host_IsLocalGame( void );
qboolean Host_IsLocalClient( void );
void Host_ShutdownServer( void );
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_InitDecals( void );
void Host_Credits( void );

32
engine/common/host.c

@ -190,7 +190,7 @@ void Host_ShutdownServer( void ) @@ -190,7 +190,7 @@ void Host_ShutdownServer( void )
Host_PrintEngineFeatures
================
*/
void Host_PrintEngineFeatures( int features )
static void Host_PrintEngineFeatures( int features )
{
const char *features_str[] =
{
@ -213,6 +213,36 @@ void Host_PrintEngineFeatures( int features ) @@ -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

6
engine/server/sv_phys.c

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

Loading…
Cancel
Save