diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index 87aa2a7cd..f6c9873aa 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -1600,3 +1600,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 33d404316..5496a337b 100644 --- a/core/HalfLife2.h +++ b/core/HalfLife2.h @@ -261,6 +261,8 @@ public: //IGameHelpers 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 bc2ae1246..21f90739f 100644 --- a/public/IGameHelpers.h +++ b/public/IGameHelpers.h @@ -40,7 +40,7 @@ */ #define SMINTERFACE_GAMEHELPERS_NAME "IGameHelpers" -#define SMINTERFACE_GAMEHELPERS_VERSION 12 +#define SMINTERFACE_GAMEHELPERS_VERSION 13 class CBaseEntity; class CBaseHandle; @@ -358,6 +358,21 @@ namespace SourceMod * @return ServerClass pointer on success, nullptr on failure. */ virtual ServerClass *FindEntityServerClass(CBaseEntity *pEntity) = 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; }; }