diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index 53af3dc891..ff4fc97951 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -1572,3 +1572,26 @@ uint64_t CHalfLife2::GetServerSteamId64() const return 1ULL; } + +void CHalfLife2::RemoveDataTableCache(datamap_t *pMap) +{ + if (pMap == nullptr) + { + m_Maps.clear(); + return; + } + + m_Maps.removeIfExists(pMap); +} + +bool CHalfLife2::RemoveSendPropCache(const char *classname) +{ + if (classname == nullptr) + { + m_Classes.clear(); + return true; + } + + return m_Classes.remove(classname); +} + diff --git a/core/HalfLife2.h b/core/HalfLife2.h index b3f9b534ef..eee2dcf2e1 100644 --- a/core/HalfLife2.h +++ b/core/HalfLife2.h @@ -258,6 +258,8 @@ class CHalfLife2 : string_t AllocPooledString(const char *pszValue); bool GetServerSteam3Id(char *pszOut, size_t len) const override; uint64_t GetServerSteamId64() const override; + void RemoveDataTableCache(datamap_t *pMap = nullptr); + bool RemoveSendPropCache(const char *classname = nullptr); public: void AddToFakeCliCmdQueue(int client, int userid, const char *cmd); void ProcessFakeCliCmdQueue(); diff --git a/public/IGameHelpers.h b/public/IGameHelpers.h index b05c98d403..ee1c91b55f 100644 --- a/public/IGameHelpers.h +++ b/public/IGameHelpers.h @@ -40,7 +40,7 @@ */ #define SMINTERFACE_GAMEHELPERS_NAME "IGameHelpers" -#define SMINTERFACE_GAMEHELPERS_VERSION 11 +#define SMINTERFACE_GAMEHELPERS_VERSION 12 class CBaseEntity; class CBaseHandle; @@ -351,6 +351,21 @@ namespace SourceMod * @return 64-bit server Steam id. */ virtual uint64_t GetServerSteamId64() const =0; + + /** + * @brief Clears all, or removes a single datamap from the DataTable cache. + * + * @param pMap NULL or datamap_t pointer. + */ + virtual void RemoveDataTableCache(datamap_t *pMap = nullptr) =0; + + /** + * @brief Clears all, or removes a single class from the SendProp cache. + * + * @param classname NULL pointer or entity class name. + * @return True if cache was found and removed. + */ + virtual bool RemoveSendPropCache(const char *classname = nullptr) =0; }; }