Core/Phases: some cleanup

- implemented CopyPhaseFrom(obj)
This commit is contained in:
Rat committed 2014-10-30 13:35:12 +01:00
1 parent 4fab55d703
commit 5993b946c9
16 files changed
+43 -59

No files matched your search

+14 -8
View File
@@ -2191,10 +2191,6 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
}
}
std::set<uint32> phases;
if (summoner)
phases = summoner->GetPhases();
TempSummon* summon = NULL;
switch (mask)
{
@@ -2222,8 +2218,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
}
// Set the summon to the summoner's phase
for (auto phaseId : phases)
summon->SetInPhase(phaseId, false, true);
summon->CopyPhaseFrom(summoner);
summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId);
@@ -2319,8 +2314,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float
return NULL;
}
for (auto phase : GetPhases())
go->SetInPhase(phase, false, true);
go->CopyPhaseFrom(this);
go->SetRespawnTime(respawnTime);
if (GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT) //not sure how to handle this
@@ -2737,6 +2731,18 @@ void WorldObject::SetInPhase(uint32 id, bool update, bool apply)
UpdateObjectVisibility();
}
void WorldObject::CopyPhaseFrom(WorldObject* obj, bool update)
{
if (!obj)
return;
for (uint32 phase : obj->GetPhases())
SetInPhase(phase, false, true);
if (update && IsInWorld())
UpdateObjectVisibility();
}
bool WorldObject::IsInPhase(WorldObject const* obj) const
{
// PhaseId 169 is the default fallback phase