Core/Objects: Refactor private object checks into separate function

This commit is contained in:
Shauren authored and Ovahlord committed 2021-03-29 20:47:38 +02:00
1 parent 434bc017c2
commit 3ab52418ef
3 files changed
+26 -4

No files matched your search

+19 -3
View File
@@ -1726,20 +1726,36 @@ float WorldObject::GetSightRange(const WorldObject* target) const
return 0.0f;
}
bool WorldObject::CheckPrivateObjectOwnerVisibility(WorldObject const* seer) const
{
if (!IsPrivateObject())
return true;
// Owner of this private object
if (_privateObjectOwner == seer->GetGUID())
return true;
// Another private object of the same owner
if (_privateObjectOwner == seer->GetPrivateObjectOwner())
return true;
return false;
}
bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, bool distanceCheck, bool checkAlert) const
{
if (this == obj)
return true;
if (!obj->GetPrivateObjectOwner().IsEmpty())
return GetGUID() == obj->GetPrivateObjectOwner() || GetPrivateObjectOwner() == obj->GetPrivateObjectOwner();
if (obj->IsNeverVisible() || CanNeverSee(obj))
return false;
if (obj->IsAlwaysVisibleFor(this) || CanAlwaysSee(obj))
return true;
if (!obj->CheckPrivateObjectOwnerVisibility(this))
return false;
bool corpseVisibility = false;
if (distanceCheck)
{