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

This commit is contained in:
Jeremy
2023-05-21 15:31:14 +02:00
committed by GitHub
parent ae9ec38345
commit 7ba4e2df84
2 changed files with 25 additions and 4 deletions

View File

@@ -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)

View File

@@ -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();