@@ -6117,10 +6117,10 @@ void Unit::RemoveAllControlled()
61176117 m_Controlled.erase(m_Controlled.begin());
61186118 if (target->GetCharmerGUID() == GetGUID())
61196119 target->RemoveCharmAuras();
6120- else if (target->GetOwnerOrCreatorGUID () == GetGUID() && target->IsSummon())
6120+ else if (target->GetOwnerGUID () == GetGUID() && target->IsSummon())
61216121 target->ToTempSummon()->UnSummon();
6122- else
6123- TC_LOG_ERROR("entities.unit", "Unit %u is trying to release unit %u which is neither charmed nor owned by it", GetEntry(), target->GetEntry());
6122+ // else
6123+ // TC_LOG_ERROR("entities.unit", "Unit %u is trying to release unit %u which is neither charmed nor owned by it", GetEntry(), target->GetEntry());
61246124 }
61256125 if (GetPetGUID())
61266126 TC_LOG_FATAL("entities.unit", "Unit %u is not able to release its pet %s", GetEntry(), GetPetGUID().ToString().c_str());
@@ -8874,6 +8874,21 @@ void Unit::UnregisterSummon(SummonInfo* summon)
88748874 _slottedSummons[targetSlot] = nullptr;
88758875}
88768876
8877+ void Unit::DespawnSummonsOnSummonerLogout()
8878+ {
8879+ // Summons which are stored in a summon slot will always despawn
8880+ std::vector<SummonInfo*> slottedSummons = _slottedSummons;
8881+ for (SummonInfo* summon : slottedSummons)
8882+ if (summon)
8883+ summon->GetSummonedCreature()->DespawnOrUnsummon();
8884+
8885+ // Wild summons on the other hand only despawn when the according flag is set
8886+ std::vector<SummonInfo*> wildSummons = _wildSummons;
8887+ for (SummonInfo* summon : wildSummons)
8888+ if (summon->DespawnsOnSummonerLogout())
8889+ summon->GetSummonedCreature()->DespawnOrUnsummon();
8890+ }
8891+
88778892SummonInfo* Unit::GetSummonInSlot(SummonPropertiesSlot slot) const
88788893{
88798894 if (slot == SummonPropertiesSlot::None ||
@@ -9690,7 +9705,7 @@ void Unit::RemoveFromWorld()
96909705 RemoveAllDynObjects();
96919706
96929707 ExitVehicle(); // Remove applied auras with SPELL_AURA_CONTROL_VEHICLE
9693- UnsummonAllTotems ();
9708+ DespawnSummonsOnSummonerLogout ();
96949709 RemoveAllControlled();
96959710
96969711 RemoveAreaAurasDueToLeaveWorld();
0 commit comments