diff options
author | Shauren <shauren.trinity@gmail.com> | 2021-02-27 01:44:44 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-02-27 01:44:44 +0100 |
commit | ec9f5be6a657003a94f95b4e4067a37a9f113c7c (patch) | |
tree | a1c3117f4f9cf3a32975000e29855041c05cdeaf /src/server/game/Phasing/PhasingHandler.cpp | |
parent | c9344c145ad1f981492c35d4aad7ca7a60e9f8f2 (diff) |
Core/Phasing: Implemented setting personal guid on PhaseShift
Diffstat (limited to 'src/server/game/Phasing/PhasingHandler.cpp')
-rw-r--r-- | src/server/game/Phasing/PhasingHandler.cpp | 45 |
1 files changed, 36 insertions, 9 deletions
diff --git a/src/server/game/Phasing/PhasingHandler.cpp b/src/server/game/Phasing/PhasingHandler.cpp index 943144ded64..57260d54c18 100644 --- a/src/server/game/Phasing/PhasingHandler.cpp +++ b/src/server/game/Phasing/PhasingHandler.cpp @@ -55,23 +55,31 @@ inline void ForAllControlled(Unit* unit, Func&& func) if (controlled->GetTypeId() != TYPEID_PLAYER) func(controlled); - for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i) - if (!unit->m_SummonSlot[i].IsEmpty()) - if (Creature* summon = unit->GetMap()->GetCreature(unit->m_SummonSlot[i])) + for (ObjectGuid summonGuid : unit->m_SummonSlot) + if (!summonGuid.IsEmpty()) + if (Creature* summon = unit->GetMap()->GetCreature(summonGuid)) func(summon); } } void PhasingHandler::AddPhase(WorldObject* object, uint32 phaseId, bool updateVisibility) { + AddPhase(object, phaseId, object->GetGUID(), updateVisibility); +} + +void PhasingHandler::AddPhase(WorldObject* object, uint32 phaseId, ObjectGuid const& personalGuid, bool updateVisibility) +{ bool changed = object->GetPhaseShift().AddPhase(phaseId, GetPhaseFlags(phaseId), nullptr); + if (object->GetPhaseShift().PersonalReferences) + object->GetPhaseShift().PersonalGuid = personalGuid; + if (Unit* unit = object->ToUnit()) { unit->OnPhaseChange(); ForAllControlled(unit, [&](Unit* controlled) { - AddPhase(controlled, phaseId, updateVisibility); + AddPhase(controlled, phaseId, personalGuid, updateVisibility); }); unit->RemoveNotOwnSingleTargetAuras(true); } @@ -98,6 +106,11 @@ void PhasingHandler::RemovePhase(WorldObject* object, uint32 phaseId, bool updat void PhasingHandler::AddPhaseGroup(WorldObject* object, uint32 phaseGroupId, bool updateVisibility) { + AddPhaseGroup(object, phaseGroupId, object->GetGUID(), updateVisibility); +} + +void PhasingHandler::AddPhaseGroup(WorldObject* object, uint32 phaseGroupId, ObjectGuid const& personalGuid, bool updateVisibility) +{ std::vector<uint32> const* phasesInGroup = sDB2Manager.GetPhasesForGroup(phaseGroupId); if (!phasesInGroup) return; @@ -106,12 +119,15 @@ void PhasingHandler::AddPhaseGroup(WorldObject* object, uint32 phaseGroupId, boo for (uint32 phaseId : *phasesInGroup) changed = object->GetPhaseShift().AddPhase(phaseId, GetPhaseFlags(phaseId), nullptr) || changed; + if (object->GetPhaseShift().PersonalReferences) + object->GetPhaseShift().PersonalGuid = personalGuid; + if (Unit* unit = object->ToUnit()) { unit->OnPhaseChange(); ForAllControlled(unit, [&](Unit* controlled) { - AddPhaseGroup(controlled, phaseGroupId, updateVisibility); + AddPhaseGroup(controlled, phaseGroupId, personalGuid, updateVisibility); }); unit->RemoveNotOwnSingleTargetAuras(true); } @@ -269,6 +285,9 @@ void PhasingHandler::OnAreaChange(WorldObject* object) for (uint32 phaseId : *phasesInGroup) changed = phaseShift.AddPhase(phaseId, GetPhaseFlags(phaseId), nullptr) || changed; + if (phaseShift.PersonalReferences) + phaseShift.PersonalGuid = unit->GetGUID(); + if (changed) unit->OnPhaseChange(); @@ -280,6 +299,11 @@ void PhasingHandler::OnAreaChange(WorldObject* object) if (changed) unit->RemoveNotOwnSingleTargetAuras(true); } + else + { + if (phaseShift.PersonalReferences) + phaseShift.PersonalGuid = object->GetGUID(); + } UpdateVisibilityIfNeeded(object, true, changed); } @@ -371,12 +395,15 @@ void PhasingHandler::OnConditionChange(WorldObject* object) } } + if (phaseShift.PersonalReferences) + phaseShift.PersonalGuid = object->GetGUID(); + changed = changed || !newSuppressions.Phases.empty() || !newSuppressions.VisibleMapIds.empty(); - for (auto itr = newSuppressions.Phases.begin(); itr != newSuppressions.Phases.end(); ++itr) - suppressedPhaseShift.AddPhase(itr->Id, itr->Flags, itr->AreaConditions, itr->References); + for (PhaseShift::PhaseRef const& phaseRef : newSuppressions.Phases) + suppressedPhaseShift.AddPhase(phaseRef.Id, phaseRef.Flags, phaseRef.AreaConditions, phaseRef.References); - for (auto itr = newSuppressions.VisibleMapIds.begin(); itr != newSuppressions.VisibleMapIds.end(); ++itr) - suppressedPhaseShift.AddVisibleMapId(itr->first, itr->second.VisibleMapInfo, itr->second.References); + for (std::pair<uint32 const, PhaseShift::VisibleMapIdRef> const& visibleMap : newSuppressions.VisibleMapIds) + suppressedPhaseShift.AddVisibleMapId(visibleMap.first, visibleMap.second.VisibleMapInfo, visibleMap.second.References); if (unit) { |