diff --git a/core/HalfLife2.cpp b/core/HalfLife2.cpp index 772517573..ff4fc9795 100644 --- a/core/HalfLife2.cpp +++ b/core/HalfLife2.cpp @@ -518,26 +518,6 @@ bool CHalfLife2::FindDataMapInfo(datamap_t *pMap, const char *offset, sm_datatab return pDataTable->prop != nullptr; } -void CHalfLife2::ClearDataTableCache() -{ - m_Maps.clear(); -} - -void CHalfLife2::ClearDataTableCache(datamap_t *pMap) -{ - m_Maps.removeIfExists(pMap); -} - -void CHalfLife2::ClearSendPropCache() -{ - m_Classes.clear(); -} - -bool CHalfLife2::ClearSendPropCache(const char *classname) -{ - return m_Classes.remove(classname); -} - void CHalfLife2::SetEdictStateChanged(edict_t *pEdict, unsigned short offset) { #if SOURCE_ENGINE != SE_DARKMESSIAH @@ -1595,10 +1575,23 @@ uint64_t CHalfLife2::GetServerSteamId64() const void CHalfLife2::RemoveDataTableCache(datamap_t *pMap) { - this->ClearDataTableCache(pMap); + if (pMap == nullptr) + { + m_Maps.clear(); + return; + } + + m_Maps.removeIfExists(pMap); } bool CHalfLife2::RemoveSendPropCache(const char *classname) { - return this->ClearSendPropCache(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 918db711a..eee2dcf2e 100644 --- a/core/HalfLife2.h +++ b/core/HalfLife2.h @@ -258,8 +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); + void RemoveDataTableCache(datamap_t *pMap = nullptr); + bool RemoveSendPropCache(const char *classname = nullptr); public: void AddToFakeCliCmdQueue(int client, int userid, const char *cmd); void ProcessFakeCliCmdQueue(); @@ -275,11 +275,6 @@ private: private: void InitLogicalEntData(); void InitCommandLine(); -public: - void ClearDataTableCache(); - void ClearDataTableCache(datamap_t *pMap); - void ClearSendPropCache(); - bool ClearSendPropCache(const char *classname); private: typedef ke::HashMap > DataTableMap; diff --git a/public/IGameHelpers.h b/public/IGameHelpers.h index 14d6ce7bc..ee1c91b55 100644 --- a/public/IGameHelpers.h +++ b/public/IGameHelpers.h @@ -353,19 +353,19 @@ namespace SourceMod virtual uint64_t GetServerSteamId64() const =0; /** - * @brief Removes a datamap from the DataTable cache. + * @brief Clears all, or removes a single datamap from the DataTable cache. * - * @param pMap datamap_t pointer. + * @param pMap NULL or datamap_t pointer. */ - virtual void RemoveDataTableCache(datamap_t *pMap) =0; + virtual void RemoveDataTableCache(datamap_t *pMap = nullptr) =0; /** - * @brief Removes a class from the SendProp cache. + * @brief Clears all, or removes a single class from the SendProp cache. * - * @param classname Entity class name. + * @param classname NULL pointer or entity class name. * @return True if cache was found and removed. */ - virtual bool RemoveSendPropCache(const char *classname) =0; + virtual bool RemoveSendPropCache(const char *classname = nullptr) =0; }; }