Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add methods for clearing netprop cache #1943

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Remove redundant API
sirdigbot committed Apr 27, 2023

Verified

This commit was signed with the committer’s verified signature.
Serubin Solomon
commit eb98f362caa7b2d4bce1e9991f44ab757b711eb6
37 changes: 15 additions & 22 deletions core/HalfLife2.cpp
Original file line number Diff line number Diff line change
@@ -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);
}

9 changes: 2 additions & 7 deletions core/HalfLife2.h
Original file line number Diff line number Diff line change
@@ -258,8 +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);
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 @@ class CHalfLife2 :
private:
void InitLogicalEntData();
void InitCommandLine();
public:
void ClearDataTableCache();
void ClearDataTableCache(datamap_t *pMap);
void ClearSendPropCache();
bool ClearSendPropCache(const char *classname);
private:
typedef ke::HashMap<datamap_t *, DataMapCache *, ke::PointerPolicy<datamap_t> > DataTableMap;

12 changes: 6 additions & 6 deletions public/IGameHelpers.h
Original file line number Diff line number Diff line change
@@ -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;
};
}