From 0aaf89da22798de9fccc92060b0f4a8b9342af85 Mon Sep 17 00:00:00 2001 From: sirdigbot Date: Fri, 31 Mar 2023 11:57:06 +1100 Subject: [PATCH] Expose cache-clearing methods to extensions --- core/HalfLife2.cpp | 10 ++++++++++ core/HalfLife2.h | 2 ++ public/IGameHelpers.h | 17 ++++++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index b7bb3fe30..772517573 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -1592,3 +1592,13 @@ uint64_t CHalfLife2::GetServerSteamId64() const return 1ULL; } + +void CHalfLife2::RemoveDataTableCache(datamap_t *pMap) +{ + this->ClearDataTableCache(pMap); +} + +bool CHalfLife2::RemoveSendPropCache(const char *classname) +{ + return this->ClearSendPropCache(classname); +} diff --git a/core/HalfLife2.h b/core/HalfLife2.h index c440be331..918db711a 100644 --- a/core/HalfLife2.h +++ b/core/HalfLife2.h @@ -258,6 +258,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); + bool RemoveSendPropCache(const char *classname); public: void AddToFakeCliCmdQueue(int client, int userid, const char *cmd); void ProcessFakeCliCmdQueue(); diff --git a/public/IGameHelpers.h b/public/IGameHelpers.h index b05c98d40..14d6ce7bc 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 Removes a datamap from the DataTable cache. + * + * @param pMap datamap_t pointer. + */ + virtual void RemoveDataTableCache(datamap_t *pMap) =0; + + /** + * @brief Removes a class from the SendProp cache. + * + * @param classname Entity class name. + * @return True if cache was found and removed. + */ + virtual bool RemoveSendPropCache(const char *classname) =0; }; }