diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 6ae7016384..c07333ba92 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -2470,6 +2470,7 @@ public: virtual bool IsSpawned() const override { return _owner->isSpawned(); } virtual uint32 GetDisplayId() const override { return _owner->GetDisplayId(); } + virtual bool IsInPhase(PhaseShift const& phaseShift) const override { return _owner->GetPhaseShift().CanSee(phaseShift); } virtual G3D::Vector3 GetPosition() const override { return G3D::Vector3(_owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ()); } virtual float GetOrientation() const override { return _owner->GetOrientation(); } virtual float GetScale() const override { return _owner->GetObjectScale(); } diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 8c1da64918..d6b425de86 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -6342,7 +6342,7 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(WorldLocation const& lo uint32 MapId = location.GetMapId(); // search for zone associated closest graveyard - uint32 zoneId = sMapMgr->GetZoneId(conditionObject->GetPhaseShift(), MapId, x, y, z); + uint32 zoneId = sMapMgr->GetZoneId(conditionObject ? conditionObject->GetPhaseShift() : PhasingHandler::GetEmptyPhaseShift(), MapId, x, y, z); if (!zoneId) { @@ -9630,12 +9630,6 @@ void ObjectMgr::LoadTerrainWorldMaps() continue; } - if (!sWorldMapAreaStore.LookupEntry(worldMapArea)) - { - TC_LOG_ERROR("sql.sql", "WorldMapArea %u defined in `terrain_worldmap` does not exist, skipped.", worldMapArea); - continue; - } - TerrainSwapInfo* terrainSwapInfo = &_terrainSwapInfoById[mapId]; terrainSwapInfo->Id = mapId; terrainSwapInfo->UiWorldMapAreaIDSwaps.push_back(worldMapArea); diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 3a380be38d..ad844fd91e 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -2730,7 +2730,7 @@ bool Map::getObjectHitPos(PhaseShift const& phaseShift, float x1, float y1, floa float Map::GetHeight(PhaseShift const& phaseShift, float x, float y, float z, bool vmap /*= true*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/) const { - return std::max(GetStaticHeight(phaseShift, x, y, z, vmap, maxSearchDist), _dynamicTree.getHeight(x, y, z, maxSearchDist, phaseShift)); + return std::max(GetStaticHeight(phaseShift, x, y, z, vmap, maxSearchDist), GetGameObjectFloor(phaseShift, x, y, z, maxSearchDist)); } bool Map::IsInWater(PhaseShift const& phaseShift, float x, float y, float pZ, LiquidData* data) const diff --git a/src/server/game/Phasing/PhaseShift.h b/src/server/game/Phasing/PhaseShift.h index 8755868ae9..f192916861 100644 --- a/src/server/game/Phasing/PhaseShift.h +++ b/src/server/game/Phasing/PhaseShift.h @@ -82,6 +82,8 @@ public: typedef std::map VisibleMapIdContainer; typedef std::map UiWorldMapAreaIdSwapContainer; + PhaseShift() : Flags(PhaseShiftFlags::Unphased), NonCosmeticReferences(0), CosmeticReferences(0), DefaultReferences(0), IsDbPhaseShift(false) { } + bool AddPhase(uint32 phaseId, PhaseFlags flags, std::vector const* areaConditions, int32 references = 1); EraseResult RemovePhase(uint32 phaseId); bool HasPhase(uint32 phaseId) const { return Phases.find(PhaseRef(phaseId, PhaseFlags::None, nullptr)) != Phases.end(); } @@ -105,7 +107,7 @@ public: protected: friend class PhasingHandler; - EnumClassFlag Flags = PhaseShiftFlags::Unphased; + EnumClassFlag Flags; ObjectGuid PersonalGuid; PhaseContainer Phases; VisibleMapIdContainer VisibleMapIds; @@ -113,10 +115,10 @@ protected: void ModifyPhasesReferences(PhaseContainer::iterator itr, int32 references); void UpdateUnphasedFlag(); - int32 NonCosmeticReferences = 0; - int32 CosmeticReferences = 0; - int32 DefaultReferences = 0; - bool IsDbPhaseShift = false; + int32 NonCosmeticReferences; + int32 CosmeticReferences; + int32 DefaultReferences; + bool IsDbPhaseShift; }; #endif // PhaseShift_h__ diff --git a/src/server/game/Phasing/PhasingHandler.cpp b/src/server/game/Phasing/PhasingHandler.cpp index bd65b93175..b4c91e7529 100644 --- a/src/server/game/Phasing/PhasingHandler.cpp +++ b/src/server/game/Phasing/PhasingHandler.cpp @@ -230,14 +230,15 @@ void PhasingHandler::OnAreaChange(WorldObject* object) object->GetPhaseShift().ClearPhases(); object->GetSuppressedPhaseShift().ClearPhases(); - AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(object->GetAreaId()); + uint32 areaId = object->GetAreaId(); + AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaId); while (areaEntry) { if (std::vector const* newAreaPhases = sObjectMgr->GetPhasesForArea(areaEntry->ID)) { for (PhaseAreaInfo const& phaseArea : *newAreaPhases) { - if (phaseArea.SubAreaExclusions.find(areaEntry->ID) != phaseArea.SubAreaExclusions.end()) + if (phaseArea.SubAreaExclusions.find(areaId) != phaseArea.SubAreaExclusions.end()) continue; uint32 phaseId = phaseArea.PhaseInfo->Id;