From d41a80bc2c54f37f769d71372adcb86949f25887 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 17 Dec 2023 17:29:11 +0300 Subject: [PATCH] engine: add mask to sanitize possible engine features bits --- common/enginefeatures.h | 12 ++++++++++++ engine/client/cl_parse.c | 1 + engine/server/sv_phys.c | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/common/enginefeatures.h b/common/enginefeatures.h index dc949dbf..8fe254d0 100644 --- a/common/enginefeatures.h +++ b/common/enginefeatures.h @@ -27,4 +27,16 @@ GNU General Public License for more details. #define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine #define ENGINE_LINEAR_GAMMA_SPACE (1<<8) // disable influence of gamma/brightness cvars to textures/lightmaps, for mods with custom renderer +// adjust the mask when features will be added or removed +#define ENGINE_FEATURES_MASK \ + ( ENGINE_WRITE_LARGE_COORD \ + | ENGINE_QUAKE_COMPATIBLE \ + | ENGINE_LOAD_DELUXEDATA \ + | ENGINE_PHYSICS_PUSHER_EXT \ + | ENGINE_LARGE_LIGHTMAPS \ + | ENGINE_COMPENSATE_QUAKE_BUG \ + | ENGINE_IMPROVED_LINETRACE \ + | ENGINE_COMPUTE_STUDIO_LERP \ + | ENGINE_LINEAR_GAMMA_SPACE ) + #endif//FEATURES_H diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index 81fd545f..f19de6e0 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -904,6 +904,7 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy ) background = MSG_ReadOneBit( msg ); Q_strncpy( gamefolder, MSG_ReadString( msg ), sizeof( gamefolder )); host.features = (uint)MSG_ReadLong( msg ); + host.features &= ENGINE_FEATURES_MASK; if( !legacy ) { diff --git a/engine/server/sv_phys.c b/engine/server/sv_phys.c index 912932da..51e7cfff 100644 --- a/engine/server/sv_phys.c +++ b/engine/server/sv_phys.c @@ -2139,7 +2139,7 @@ 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(); + host.features = svgame.physFuncs.SV_CheckFeatures() & ENGINE_FEATURES_MASK; Host_PrintEngineFeatures (); } return true;