fix(Core/Unit): Keep Lightwell alive on player death (#24675)

This commit is contained in:
sogladev
2026-03-14 16:43:24 +01:00
committed by GitHub
parent a7f49ff6b2
commit fda5093e59
2 changed files with 24 additions and 4 deletions

View File

@@ -8077,24 +8077,36 @@ void Unit::RemoveAllControlled(bool onDeath /*= false*/)
if (IsPlayer())
ToPlayer()->StopCastingCharm();
while (!m_Controlled.empty())
for (auto it = m_Controlled.begin(); it != m_Controlled.end();)
{
Unit* target = *m_Controlled.begin();
m_Controlled.erase(m_Controlled.begin());
Unit* target = *it;
if (target->GetCharmerGUID() == GetGUID())
{
it = m_Controlled.erase(it);
target->RemoveCharmAuras();
}
else if (target->GetOwnerGUID() == GetGUID() && target->IsSummon())
{
// Keep Lightwell alive on owner death
if (onDeath)
if (TempSummon* ts = target->ToTempSummon())
if (ts->m_Properties && ts->m_Properties->Type == SUMMON_TYPE_LIGHTWELL)
{
++it;
continue;
}
if (!(onDeath && !IsPlayer() && target->IsGuardian()))
{
target->ToTempSummon()->UnSummon();
it = m_Controlled.erase(it);
}
}
else
{
LOG_ERROR("entities.unit", "Unit {} is trying to release unit {} which is neither charmed nor owned by it", GetEntry(), target->GetEntry());
++it;
}
}
}