fix(Core/Misc): prevent crash and undefined behavior in Warden destructor and Object visibility (#24900)

This commit is contained in:
Francesco Borzì 2026-03-05 12:41:08 +01:00 committed by GitHub
parent 5a3c48b281
commit b1d159c225
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 12 deletions

View file

@ -1763,7 +1763,7 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
// pussywizard: arena spectator
if (obj->IsPlayer())
if (((Player const*)obj)->IsSpectator() && ((Player const*)obj)->FindMap()->IsBattleArena())
if (((Player const*)obj)->IsSpectator() && ((Player const*)obj)->FindMap() && ((Player const*)obj)->FindMap()->IsBattleArena())
return false;
bool corpseVisibility = false;
@ -1807,11 +1807,12 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
return false;
// pussywizard: during arena preparation, don't allow to detect pets if can't see its owner (spoils enemy arena frames)
if (target->IsPet() && target->GetOwnerGUID() && target->FindMap()->IsBattleArena() && GetGUID() != target->GetOwnerGUID())
if (BattlegroundMap* bgmap = target->FindMap()->ToBattlegroundMap())
if (Battleground* bg = bgmap->GetBG())
if (bg->GetStatus() < STATUS_IN_PROGRESS && !thisPlayer->HaveAtClient(target->GetOwnerGUID()))
return false;
if (Map* targetMap = target->FindMap())
if (target->IsPet() && target->GetOwnerGUID() && targetMap->IsBattleArena() && GetGUID() != target->GetOwnerGUID())
if (BattlegroundMap* bgmap = targetMap->ToBattlegroundMap())
if (Battleground* bg = bgmap->GetBG())
if (bg->GetStatus() < STATUS_IN_PROGRESS && !thisPlayer->HaveAtClient(target->GetOwnerGUID()))
return false;
}
if (thisPlayer->GetFarSightDistance() && !thisPlayer->isInFront(obj))
@ -1856,7 +1857,7 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
// pussywizard: arena spectator
if (this->IsPlayer())
if (((Player const*)this)->IsSpectator() && ((Player const*)this)->FindMap()->IsBattleArena() && (obj->m_invisibility.GetFlags() || obj->m_stealth.GetFlags()))
if (((Player const*)this)->IsSpectator() && ((Player const*)this)->FindMap() && ((Player const*)this)->FindMap()->IsBattleArena() && (obj->m_invisibility.GetFlags() || obj->m_stealth.GetFlags()))
return false;
if (!CanDetect(obj, ignoreStealth, !distanceCheck, checkAlert))