From 852d63ba6f2ef5553390435e5e5ee3f188dfd8d5 Mon Sep 17 00:00:00 2001 From: Blixibon Date: Sun, 16 Oct 2022 15:16:53 -0500 Subject: [PATCH] Added support for "custom" conditionals in KeyValues --- sp/src/tier1/KeyValues.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sp/src/tier1/KeyValues.cpp b/sp/src/tier1/KeyValues.cpp index 19d6d66c..16fae59c 100644 --- a/sp/src/tier1/KeyValues.cpp +++ b/sp/src/tier1/KeyValues.cpp @@ -2081,6 +2081,28 @@ bool EvaluateConditional( const char *str ) if ( Q_stristr( str, "$POSIX" ) ) return IsPosix() ^ bNot; + +#ifdef MAPBASE + // Custom conditional + switch( str[bNot ? 1 : 0] ) + { + case '%': + { + // Look for a cvar + ConVarRef cvar( str + (bNot ? 2 : 1), true ); + if (cvar.IsValid()) + { + return cvar.GetBool() ^ bNot; + } + } break; + + case '-': + { + // Look for a command line param + return (CommandLine()->CheckParm( bNot ? str+1 : str ) != 0) ^ bNot; + } break; + } +#endif return false; }