From 90b3df1181ed1684cd7daaca55c267fb46a7da33 Mon Sep 17 00:00:00 2001 From: WildCard65 Date: Sat, 4 Feb 2017 08:18:58 -0500 Subject: [PATCH] Add 2 CSGO gamerules netprops to CSGO blocklist if FollowCSGOServerGuidelines is enabled. (#514) * Add m_bIsValveDS and m_bIsQuestEligible * Fix compile --- extensions/sdktools/extension.cpp | 3 +++ extensions/sdktools/extension.h | 11 +++++++- extensions/sdktools/gamerulesnatives.cpp | 33 ++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/extensions/sdktools/extension.cpp b/extensions/sdktools/extension.cpp index 620b0253..386228e0 100644 --- a/extensions/sdktools/extension.cpp +++ b/extensions/sdktools/extension.cpp @@ -177,6 +177,9 @@ bool SDKTools::SDK_OnLoad(char *error, size_t maxlength, bool late) { m_bFollowCSGOServerGuidelines = false; } + + m_CSGOBadList.add("m_bIsValveDS"); + m_CSGOBadList.add("m_bIsQuestEligible"); #endif return true; diff --git a/extensions/sdktools/extension.h b/extensions/sdktools/extension.h index 8aef2c30..5c5d562a 100644 --- a/extensions/sdktools/extension.h +++ b/extensions/sdktools/extension.h @@ -50,6 +50,10 @@ #include #include #include +#if SOURCE_ENGINE == SE_CSGO +#include +#include +#endif #include "SoundEmitterSystem/isoundemittersystembase.h" #if SOURCE_ENGINE >= SE_ORANGEBOX @@ -111,10 +115,15 @@ public: void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax); public: bool HasAnyLevelInited() { return m_bAnyLevelInited; } +#if SOURCE_ENGINE == SE_CSGO +public: bool ShouldFollowCSGOServerGuidelines() const { return m_bFollowCSGOServerGuidelines; } - + bool CanSetCSGOEntProp(const char *pszPropName) { return !ShouldFollowCSGOServerGuidelines() || !m_CSGOBadList.has(pszPropName); } private: + ke::HashSet m_CSGOBadList; bool m_bFollowCSGOServerGuidelines = false; +#endif +private: bool m_bAnyLevelInited = false; }; diff --git a/extensions/sdktools/gamerulesnatives.cpp b/extensions/sdktools/gamerulesnatives.cpp index 9fac96f6..6fe89582 100644 --- a/extensions/sdktools/gamerulesnatives.cpp +++ b/extensions/sdktools/gamerulesnatives.cpp @@ -46,7 +46,7 @@ static CBaseEntity *FindEntityByNetClass(int start, const char *classname) for (int i = start; i < maxEntities; i++) { edict_t *current = gamehelpers->EdictOfIndex(i); - if (current == NULL || current->IsFree()) + if (current == NULL || current->IsFree()) continue; IServerNetworkable *network = current->GetNetworkable(); @@ -183,7 +183,8 @@ static cell_t GameRules_GetProp(IPluginContext *pContext, const cell_t *params) bit_count = sizeof(int) * 8; } #endif - if (bit_count < 1) + + if (bit_count < 1) { bit_count = params[2] * 8; } @@ -240,6 +241,13 @@ static cell_t GameRules_SetProp(IPluginContext *pContext, const cell_t *params) pContext->LocalToString(params[1], &prop); +#if SOURCE_ENGINE == SE_CSGO + if (!g_SdkTools.CanSetCSGOEntProp(prop)) + { + return pContext->ThrowNativeError("Cannot set ent prop %s with core.cfg option \"FollowCSGOServerGuidelines\" enabled.", prop); + } +#endif + FIND_PROP_SEND(DPT_Int, "integer"); #if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 \ @@ -318,6 +326,13 @@ static cell_t GameRules_SetPropFloat(IPluginContext *pContext, const cell_t *par pContext->LocalToString(params[1], &prop); +#if SOURCE_ENGINE == SE_CSGO + if (!g_SdkTools.CanSetCSGOEntProp(prop)) + { + return pContext->ThrowNativeError("Cannot set ent prop %s with core.cfg option \"FollowCSGOServerGuidelines\" enabled.", prop); + } +#endif + FIND_PROP_SEND(DPT_Float, "float"); float newVal = sp_ctof(params[2]); @@ -376,6 +391,13 @@ static cell_t GameRules_SetPropEnt(IPluginContext *pContext, const cell_t *param pContext->LocalToString(params[1], &prop); +#if SOURCE_ENGINE == SE_CSGO + if (!g_SdkTools.CanSetCSGOEntProp(prop)) + { + return pContext->ThrowNativeError("Cannot set ent prop %s with core.cfg option \"FollowCSGOServerGuidelines\" enabled.", prop); + } +#endif + FIND_PROP_SEND(DPT_Int, "integer"); CBaseHandle &hndl = *(CBaseHandle *)((intptr_t)pGameRules + offset); @@ -451,6 +473,13 @@ static cell_t GameRules_SetPropVector(IPluginContext *pContext, const cell_t *pa pContext->LocalToString(params[1], &prop); +#if SOURCE_ENGINE == SE_CSGO + if (!g_SdkTools.CanSetCSGOEntProp(prop)) + { + return pContext->ThrowNativeError("Cannot set ent prop %s with core.cfg option \"FollowCSGOServerGuidelines\" enabled.", prop); + } +#endif + FIND_PROP_SEND(DPT_Vector, "vector"); Vector *v = (Vector *)((intptr_t)pGameRules + offset);