aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy <Golrag@users.noreply.github.com>2023-05-21 15:31:14 +0200
committerGitHub <noreply@github.com>2023-05-21 15:31:14 +0200
commit7ba4e2df84e4ddefb080f71685294c619a8397de (patch)
treef55732d497fc8e20c4677e5ac210b1a67e551d00 /src
parentae9ec3834588f85707a640d55fb68afe0847181b (diff)
Core/Graveyards: Fix graveyards in subzones when there is no valid graveyard in that subzone (#29003)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp28
-rw-r--r--src/server/game/Globals/ObjectMgr.h1
2 files changed, 25 insertions, 4 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index a3627c1658d..a0ec6d3c411 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -7096,6 +7096,28 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveyard(WorldLocation const& lo
}
}
+ WorldSafeLocsEntry const* graveyard = GetClosestGraveyardInZone(location, team, conditionObject, zoneId);
+ AreaTableEntry const* zoneEntry = sAreaTableStore.AssertEntry(zoneId);
+ AreaTableEntry const* parentEntry = sAreaTableStore.LookupEntry(zoneEntry->ParentAreaID);
+
+ while (!graveyard && parentEntry)
+ {
+ graveyard = GetClosestGraveyardInZone(location, team, conditionObject, parentEntry->ID);
+ if (!graveyard && parentEntry->ParentAreaID != 0)
+ parentEntry = sAreaTableStore.LookupEntry(parentEntry->ParentAreaID);
+ else // nothing found, cant look further, give up.
+ parentEntry = nullptr;
+ }
+
+ return graveyard;
+}
+
+WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveyardInZone(WorldLocation const& location, uint32 team, WorldObject* conditionObject, uint32 zoneId) const
+{
+ float x, y, z;
+ location.GetPosition(x, y, z);
+ uint32 MapId = location.GetMapId();
+
// Simulate std. algorithm:
// found some graveyard associated to (ghost_zone, ghost_map)
//
@@ -7104,10 +7126,10 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveyard(WorldLocation const& lo
// if mapId != graveyard.mapId (ghost in instance) and search any graveyard associated
// then check faction
GraveyardMapBounds range = GraveyardStore.equal_range(zoneId);
- MapEntry const* map = sMapStore.LookupEntry(MapId);
+ MapEntry const* mapEntry = sMapStore.LookupEntry(MapId);
// not need to check validity of map object; MapId _MUST_ be valid here
- if (range.first == range.second && !map->IsBattlegroundOrArena())
+ if (range.first == range.second && !mapEntry->IsBattlegroundOrArena())
{
if (zoneId != 0) // zone == 0 can't be fixed, used by bliz for bugged zones
TC_LOG_ERROR("sql.sql", "Table `game_graveyard_zone` incomplete: Zone {} Team {} does not have a linked graveyard.", zoneId, team);
@@ -7127,8 +7149,6 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveyard(WorldLocation const& lo
// some where other
WorldSafeLocsEntry const* entryFar = nullptr;
- MapEntry const* mapEntry = sMapStore.LookupEntry(MapId);
-
ConditionSourceInfo conditionSource(conditionObject);
for (; range.first != range.second; ++range.first)
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index b95ff959fcc..c0a2f5b228c 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -1230,6 +1230,7 @@ class TC_GAME_API ObjectMgr
WorldSafeLocsEntry const* GetDefaultGraveyard(uint32 team) const;
WorldSafeLocsEntry const* GetClosestGraveyard(WorldLocation const& location, uint32 team, WorldObject* conditionObject) const;
+ WorldSafeLocsEntry const* GetClosestGraveyardInZone(WorldLocation const& location, uint32 team, WorldObject* conditionObject, uint32 zoneId) const;
bool AddGraveyardLink(uint32 id, uint32 zoneId, uint32 team, bool persist = true);
void RemoveGraveyardLink(uint32 id, uint32 zoneId, uint32 team, bool persist = false);
void LoadGraveyardZones();