From 99cd990dc9ff245aceb0637a3620c0f90c3b362c Mon Sep 17 00:00:00 2001 From: Rain Date: Wed, 28 Jan 2026 11:25:58 +0200 Subject: [PATCH] Require boolean bMin/bMax for cvar ctors Require the bMin and bMax values of ConVar constructors to be evaluated from boolean values, to prevent bugs with typo'd argument order where an incorrect argument would silently get evaluated as the boolean value without raising a compiler error. --- src/game/client/c_baseentity.cpp | 4 +++ src/public/tier1/convar.h | 54 ++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/src/game/client/c_baseentity.cpp b/src/game/client/c_baseentity.cpp index fd889800cc..5e60df83c6 100644 --- a/src/game/client/c_baseentity.cpp +++ b/src/game/client/c_baseentity.cpp @@ -79,7 +79,11 @@ void cc_cl_interp_all_changed( IConVar *pConVar, const char *pOldString, float f static ConVar cl_extrapolate( "cl_extrapolate", "1", FCVAR_CHEAT, "Enable/disable extrapolation if interpolation history runs out." ); static ConVar cl_interp_npcs( "cl_interp_npcs", "0.0", FCVAR_USERINFO, "Interpolate NPC positions starting this many seconds in past (or cl_interp, if greater)" ); +#ifdef NEO +static ConVar cl_interp_all( "cl_interp_all", "0", 0, "Disable interpolation list optimizations.", false, 0, false, 0, cc_cl_interp_all_changed ); +#else static ConVar cl_interp_all( "cl_interp_all", "0", 0, "Disable interpolation list optimizations.", 0, 0, 0, 0, cc_cl_interp_all_changed ); +#endif ConVar r_drawmodeldecals( "r_drawmodeldecals", "1", FCVAR_ALLOWED_IN_COMPETITIVE ); extern ConVar cl_showerror; int C_BaseEntity::m_nPredictionRandomSeed = -1; diff --git a/src/public/tier1/convar.h b/src/public/tier1/convar.h index 67d5ea3b30..75e3f306f1 100644 --- a/src/public/tier1/convar.h +++ b/src/public/tier1/convar.h @@ -30,6 +30,13 @@ #error "implement me" #endif +#ifdef NEO +#include +#include + +template +concept NotBoolean = !std::is_same_v; +#endif //----------------------------------------------------------------------------- // Forward declarations @@ -339,7 +346,54 @@ friend class ConVarRef; bool bCompMin, float fCompMin, bool bCompMax, float fCompMax, FnChangeCallback_t callback ); +#ifdef NEO + // You may have a typo in your constructor argument order if the compiler is + // attempting to invoke one or more of the deleted constructors below. + // If you really meant to evaluate bMin/bMax or bCompMin/bCompMax from a non-boolean type, + // please cast them to bool to silence the error. + + template + ConVar( const char *pName, const char *pDefaultValue, int flags, + const char *pHelpString, T bMin, float fMin, bool bMax, float fMax ) = delete; + + template + ConVar( const char *pName, const char *pDefaultValue, int flags, + const char *pHelpString, bool bMin, float fMin, T bMax, float fMax ) = delete; + + template + ConVar( const char *pName, const char *pDefaultValue, int flags, + const char *pHelpString, T bMin, float fMin, bool bMax, float fMax, + FnChangeCallback_t callback ) = delete; + + template + ConVar( const char *pName, const char *pDefaultValue, int flags, + const char *pHelpString, bool bMin, float fMin, T bMax, float fMax, + FnChangeCallback_t callback ) = delete; + + template + ConVar( const char *pName, const char *pDefaultValue, int flags, + const char *pHelpString, T bMin, float fMin, bool bMax, float fMax, + bool bCompMin, float fCompMin, bool bCompMax, float fCompMax, + FnChangeCallback_t callback ) = delete; + + template + ConVar( const char *pName, const char *pDefaultValue, int flags, + const char *pHelpString, bool bMin, float fMin, T bMax, float fMax, + bool bCompMin, float fCompMin, bool bCompMax, float fCompMax, + FnChangeCallback_t callback ) = delete; + template + ConVar( const char *pName, const char *pDefaultValue, int flags, + const char *pHelpString, bool bMin, float fMin, bool bMax, float fMax, + T bCompMin, float fCompMin, bool bCompMax, float fCompMax, + FnChangeCallback_t callback ) = delete; + + template + ConVar( const char *pName, const char *pDefaultValue, int flags, + const char *pHelpString, bool bMin, float fMin, bool bMax, float fMax, + bool bCompMin, float fCompMin, T bCompMax, float fCompMax, + FnChangeCallback_t callback ) = delete; +#endif virtual ~ConVar( void );