Skip to content

Commit

Permalink
Allow onClientElementDestroy events (reviews)
Browse files Browse the repository at this point in the history
  • Loading branch information
tederis committed Jan 28, 2025
1 parent acaab7a commit 791dd0c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
4 changes: 3 additions & 1 deletion Client/mods/deathmatch/logic/CClientRenderElementManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ CClientTexture* CClientRenderElementManager::FindAutoTexture(const SString& strF
if (!pNewTextureElement)
return nullptr;

pNewTextureElement->MakeSystemEntity();

// Add to automap if created
MapSet(m_AutoTextureMap, strUniqueName, SAutoTexture{pNewTextureElement});
ppTextureElement = MapFind(m_AutoTextureMap, strUniqueName);
Expand Down Expand Up @@ -390,5 +392,5 @@ void CClientRenderElementManager::DoPulse()
}

for (CClientTexture* texture : deleteCandidates)
g_pClientGame->GetElementDeleter()->Delete(texture, true);
g_pClientGame->GetElementDeleter()->Delete(texture);
}
9 changes: 3 additions & 6 deletions Client/mods/deathmatch/logic/CElementDeleter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@ CElementDeleter::CElementDeleter()
m_bAllowUnreference = true;
}

void CElementDeleter::Delete(class CClientEntity* pElement, bool silent)
void CElementDeleter::Delete(class CClientEntity* pElement)
{
// Make sure we don't try to delete it twice
if (pElement && !IsBeingDeleted(pElement))
{
// Before we do anything, fire the on-destroy event
if (!silent)
{
CLuaArguments Arguments;
pElement->CallEvent("onClientElementDestroy", Arguments, true);
}
CLuaArguments Arguments;
pElement->CallEvent("onClientElementDestroy", Arguments, true);

// Add it to our list
if (!pElement->IsBeingDeleted())
Expand Down
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/logic/CElementDeleter.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CElementDeleter
CElementDeleter();
~CElementDeleter() { DoDeleteAll(); };

void Delete(class CClientEntity* pElement, bool silent = false);
void Delete(class CClientEntity* pElement);
void DeleteRecursive(class CClientEntity* pElement);
void DoDeleteAll();
bool IsBeingDeleted(class CClientEntity* pElement);
Expand Down

0 comments on commit 791dd0c

Please sign in to comment.