From 0d8dceea4310fde5706b3ce1c70609d72a38efdf Mon Sep 17 00:00:00 2001 From: John Schoenick Date: Wed, 9 Sep 2015 18:35:41 -0700 Subject: Updated the SDK with the latest code from the TF and HL2 branches. --- mp/src/game/server/client.cpp | 73 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) (limited to 'mp/src/game/server/client.cpp') diff --git a/mp/src/game/server/client.cpp b/mp/src/game/server/client.cpp index f500ad5e..eced1df1 100644 --- a/mp/src/game/server/client.cpp +++ b/mp/src/game/server/client.cpp @@ -57,6 +57,60 @@ extern bool IsInCommentaryMode( void ); ConVar *sv_cheats = NULL; +enum eAllowPointServerCommand { + eAllowNever, + eAllowOfficial, + eAllowAlways +}; + +#ifdef TF_DLL +// The default value here should match the default of the convar +eAllowPointServerCommand sAllowPointServerCommand = eAllowOfficial; +#else +eAllowPointServerCommand sAllowPointServerCommand = eAllowAlways; +#endif // TF_DLL + +void sv_allow_point_servercommand_changed( IConVar *pConVar, const char *pOldString, float flOldValue ) +{ + ConVarRef var( pConVar ); + if ( !var.IsValid() ) + { + return; + } + + const char *pNewValue = var.GetString(); + if ( V_strcasecmp ( pNewValue, "always" ) == 0 ) + { + sAllowPointServerCommand = eAllowAlways; + } +#ifdef TF_DLL + else if ( V_strcasecmp ( pNewValue, "official" ) == 0 ) + { + sAllowPointServerCommand = eAllowOfficial; + } +#endif // TF_DLL + else + { + sAllowPointServerCommand = eAllowNever; + } +} + +ConVar sv_allow_point_servercommand ( "sv_allow_point_servercommand", +#ifdef TF_DLL + // The default value here should match the default of the convar + "official", +#else + // Other games may use this in their official maps, and only TF exposes IsValveMap() currently + "always", +#endif // TF_DLL + FCVAR_NONE, + "Allow use of point_servercommand entities in map. Potentially dangerous for untrusted maps.\n" + " disallow : Always disallow\n" +#ifdef TF_DLL + " official : Allowed for valve maps only\n" +#endif // TF_DLL + " always : Allow for all maps", sv_allow_point_servercommand_changed ); + void ClientKill( edict_t *pEdict, const Vector &vecForce, bool bExplode = false ) { CBasePlayer *pPlayer = static_cast( GetContainingEntity( pEdict ) ); @@ -569,7 +623,22 @@ void CPointServerCommand::InputCommand( inputdata_t& inputdata ) if ( !inputdata.value.String()[0] ) return; - engine->ServerCommand( UTIL_VarArgs( "%s\n", inputdata.value.String() ) ); + bool bAllowed = ( sAllowPointServerCommand == eAllowAlways ); +#ifdef TF_DLL + if ( sAllowPointServerCommand == eAllowOfficial ) + { + bAllowed = TFGameRules() && TFGameRules()->IsValveMap(); + } +#endif // TF_DLL + + if ( bAllowed ) + { + engine->ServerCommand( UTIL_VarArgs( "%s\n", inputdata.value.String() ) ); + } + else + { + Warning( "point_servercommand usage blocked by sv_allow_point_servercommand setting\n" ); + } } BEGIN_DATADESC( CPointServerCommand ) @@ -600,7 +669,7 @@ void CC_DrawLine( const CCommand &args ) static ConCommand drawline("drawline", CC_DrawLine, "Draws line between two 3D Points.\n\tGreen if no collision\n\tRed is collides with something\n\tArguments: x1 y1 z1 x2 y2 z2", FCVAR_CHEAT); //------------------------------------------------------------------------------ -// Purpose : Draw a cross at a points. +// Purpose : Draw a cross at a points. // Input : // Output : //------------------------------------------------------------------------------ -- cgit v1.2.3