diff --git a/Client/mods/deathmatch/logic/lua/CLuaMain.cpp b/Client/mods/deathmatch/logic/lua/CLuaMain.cpp index 53f16c0f661..02131133d72 100644 --- a/Client/mods/deathmatch/logic/lua/CLuaMain.cpp +++ b/Client/mods/deathmatch/logic/lua/CLuaMain.cpp @@ -57,6 +57,11 @@ CLuaMain::~CLuaMain() // Delete the timer manager delete m_pLuaTimerManager; + + for (auto& xmlNode : m_XMLNodes) + { + delete xmlNode; + } CClientPerfStatLuaMemory::GetSingleton()->OnLuaMainDestroy(this); CClientPerfStatLuaTiming::GetSingleton()->OnLuaMainDestroy(this); @@ -366,6 +371,8 @@ CXMLFile* CLuaMain::CreateXML(const char* szFilename, bool bUseIDs, bool bReadOn CXMLNode* CLuaMain::ParseString(const char* strXmlContent) { CXMLNode* xmlNode = g_pCore->GetXML()->ParseString(strXmlContent); + if (xmlNode) + m_XMLNodes.push_back(xmlNode); return xmlNode; } diff --git a/Client/mods/deathmatch/logic/lua/CLuaMain.h b/Client/mods/deathmatch/logic/lua/CLuaMain.h index fb7eb6103c6..387311dcaf8 100644 --- a/Client/mods/deathmatch/logic/lua/CLuaMain.h +++ b/Client/mods/deathmatch/logic/lua/CLuaMain.h @@ -96,6 +96,7 @@ class CLuaMain //: public CClient class CResource* m_pResource; std::list m_XMLFiles; + std::list m_XMLNodes; static SString ms_strExpectedUndumpHash; bool m_bEnableOOP; diff --git a/Server/mods/deathmatch/logic/lua/CLuaMain.cpp b/Server/mods/deathmatch/logic/lua/CLuaMain.cpp index be691f618a8..398023601e0 100644 --- a/Server/mods/deathmatch/logic/lua/CLuaMain.cpp +++ b/Server/mods/deathmatch/logic/lua/CLuaMain.cpp @@ -72,10 +72,14 @@ CLuaMain::~CLuaMain() delete m_pLuaTimerManager; // Eventually delete the XML files the LUA script didn't - list::iterator iterXML = m_XMLFiles.begin(); - for (; iterXML != m_XMLFiles.end(); ++iterXML) + for (auto& xmlFile : m_XMLFiles) { - delete *iterXML; + delete xmlFile; + } + + for (auto& xmlNode : m_XMLNodes) + { + delete xmlNode; } // Eventually delete the text displays the LUA script didn't @@ -419,6 +423,8 @@ CXMLFile* CLuaMain::CreateXML(const char* szFilename, bool bUseIDs, bool bReadOn CXMLNode* CLuaMain::ParseString(const char* strXmlContent) { CXMLNode* xmlNode = g_pServerInterface->GetXML()->ParseString(strXmlContent); + if (xmlNode) + m_XMLNodes.push_back(xmlNode); return xmlNode; } diff --git a/Server/mods/deathmatch/logic/lua/CLuaMain.h b/Server/mods/deathmatch/logic/lua/CLuaMain.h index 47bb8c4ca1d..c54ac8303a4 100644 --- a/Server/mods/deathmatch/logic/lua/CLuaMain.h +++ b/Server/mods/deathmatch/logic/lua/CLuaMain.h @@ -134,6 +134,7 @@ class CLuaMain //: public CClient CMapManager* m_pMapManager; list m_XMLFiles; + list m_XMLNodes; list m_Displays; list m_TextItems;