Fixes/3.3.5 aura infinite loop

* Core/Auras: Attempt to fix infinite loop with aura 18950 on map unload

* Core/Auras: Log a detailed error and assert when failing to remove all auras after a few tries

* Code cleanup
This commit is contained in:
Giacomo Pozzoni authored and Ovahlord committed 2022-09-12 09:15:28 +02:00
1 parent eb181ca99f
commit 2b2237b7bc
2 files changed
+38 -15

No files matched your search

+15 -1
View File
@@ -3989,7 +3989,7 @@ void Unit::RemoveAllAuras()
{
// this may be a dead loop if some events on aura remove will continiously apply aura on remove
// we want to have all auras removed, so use your brain when linking events
while (!m_appliedAuras.empty() || !m_ownedAuras.empty())
for (uint32 counter = 0; !m_appliedAuras.empty() || !m_ownedAuras.empty(); counter++)
{
AuraApplicationMap::iterator aurAppIter;
for (aurAppIter = m_appliedAuras.begin(); aurAppIter != m_appliedAuras.end();)
@@ -3998,6 +3998,20 @@ void Unit::RemoveAllAuras()
AuraMap::iterator aurIter;
for (aurIter = m_ownedAuras.begin(); aurIter != m_ownedAuras.end();)
RemoveOwnedAura(aurIter);
const int maxIteration = 50;
// give this loop a few tries, if there are still auras then log as much information as possible
if (counter >= maxIteration)
{
std::stringstream sstr;
sstr << "Unit::RemoveAllAuras() iterated " << maxIteration << " times already but there are still "
<< m_appliedAuras.size() << " m_appliedAuras and " << m_ownedAuras.size() << " m_ownedAuras.\n";
TC_LOG_ERROR("entities.unit", "%s", sstr.str().c_str());
ASSERT(false, sstr.str().c_str());
break;
}
}
}