Core/Graveyards: Fix graveyards in subzones when there is no valid graveyard in that subzone

This commit is contained in:
Jeremy authored and Ovahlord committed 2023-07-16 15:33:06 +02:00
1 parent ee8e20d81f
commit 929a804052
2 files changed
+24 -4

No files matched your search

+23 -4
View File
@@ -6389,6 +6389,27 @@ 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)
//
@@ -6397,10 +6418,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 `graveyard_zone` incomplete: Zone %u Team %u does not have a linked graveyard.", zoneId, team);
@@ -6420,8 +6441,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)
+1
View File
@@ -1086,6 +1086,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();