aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Object
diff options
context:
space:
mode:
authorMatan Shukry <matanshukry@gmail.com>2021-03-14 21:23:07 +0200
committerShauren <shauren.trinity@gmail.com>2024-10-05 16:54:13 +0200
commit262a1e5b36dfea97f2dfc4b838dd3d59c6ed2fb3 (patch)
treebf4ba2fbf46a031346c6a50d25f40dba197190b6 /src/server/game/Entities/Object
parent4d083b074ff7307d8f492d6f55f315425f299720 (diff)
Core/Objects: Move personal summon handling from TemporarySummon/GameObject to WorldObject and check it using dedicated guid field
(cherry picked from commit 1082a6645e96c611b3145b5d6208fc4db6e4b2d3)
Diffstat (limited to 'src/server/game/Entities/Object')
-rw-r--r--src/server/game/Entities/Object/Object.cpp23
-rw-r--r--src/server/game/Entities/Object/Object.h12
2 files changed, 20 insertions, 15 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 059fb6ebcec..5e94549bc60 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -1547,6 +1547,9 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool implicitDetect, bo
if (this == obj)
return true;
+ if (!obj->GetPrivateObjectOwner().IsEmpty())
+ return GetGUID() == obj->GetPrivateObjectOwner() || GetPrivateObjectOwner() == obj->GetPrivateObjectOwner();
+
if (obj->IsNeverVisible(implicitDetect) || CanNeverSee(obj))
return false;
@@ -1582,15 +1585,8 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool implicitDetect, bo
WorldObject const* viewpoint = this;
if (Player const* player = ToPlayer())
- {
viewpoint = player->GetViewpoint();
- if (Creature const* creature = obj->ToCreature())
- if (TempSummon const* tempSummon = creature->ToTempSummon())
- if (tempSummon->IsVisibleBySummonerOnly() && GetGUID() != tempSummon->GetSummonerGUID())
- return false;
- }
-
if (!viewpoint)
viewpoint = this;
@@ -1858,7 +1854,7 @@ void WorldObject::AddObjectToRemoveList()
map->AddObjectToRemoveList(this);
}
-TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= nullptr*/, uint32 duration /*= 0*/, WorldObject* summoner /*= nullptr*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/, bool visibleBySummonerOnly /*= false*/)
+TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= nullptr*/, uint32 duration /*= 0*/, WorldObject* summoner /*= nullptr*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/, bool personalSpawn /*= false*/)
{
uint32 mask = UNIT_MASK_SUMMON;
if (properties)
@@ -1946,7 +1942,8 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
summon->InitStats(duration);
- summon->SetVisibleBySummonerOnly(visibleBySummonerOnly);
+ if (personalSpawn && summoner)
+ summon->SetPrivateObjectOwner(summoner->IsPrivateObject() ? summoner->GetPrivateObjectOwner() : summoner->GetGUID());
AddToMap(summon->ToCreature());
summon->InitSummon();
@@ -1998,11 +1995,11 @@ void WorldObject::ClearZoneScript()
m_zoneScript = nullptr;
}
-TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, Milliseconds despawnTime /*= 0s*/, uint32 /*vehId = 0*/, uint32 spellId /*= 0*/, bool visibleBySummonerOnly /*= false*/)
+TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, Milliseconds despawnTime /*= 0s*/, uint32 /*vehId = 0*/, uint32 spellId /*= 0*/, bool personalSpawn /* = false */)
{
if (Map* map = FindMap())
{
- if (TempSummon* summon = map->SummonCreature(entry, pos, nullptr, despawnTime.count(), this, spellId, 0, visibleBySummonerOnly))
+ if (TempSummon* summon = map->SummonCreature(entry, pos, nullptr, despawnTime.count(), this, spellId, 0, personalSpawn))
{
summon->SetTempSummonType(despawnType);
return summon;
@@ -2012,13 +2009,13 @@ TempSummon* WorldObject::SummonCreature(uint32 entry, Position const& pos, TempS
return nullptr;
}
-TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float o /*= 0*/, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, Milliseconds despawnTime /*= 0s*/, bool visibleBySummonerOnly /*= false*/)
+TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float o /*= 0*/, TempSummonType despawnType /*= TEMPSUMMON_MANUAL_DESPAWN*/, Milliseconds despawnTime /*= 0s*/, bool personalSpawn /*= false*/)
{
if (!x && !y && !z)
GetClosePoint(x, y, z, GetCombatReach());
if (!o)
o = GetOrientation();
- return SummonCreature(id, { x,y,z,o }, despawnType, despawnTime, 0, 0, visibleBySummonerOnly);
+ return SummonCreature(id, { x,y,z,o }, despawnType, despawnTime, 0, 0, personalSpawn);
}
GameObject* WorldObject::SummonGameObject(uint32 entry, Position const& pos, QuaternionData const& rot, Seconds respawnTime, GOSummonType summonType)
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index 9dca2efa026..54c9267f45a 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -418,8 +418,8 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
void ClearZoneScript();
ZoneScript* GetZoneScript() const { return m_zoneScript; }
- TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime = 0s, uint32 vehId = 0, uint32 spellId = 0, bool visibleBySummonerOnly = false);
- TempSummon* SummonCreature(uint32 entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime = 0s, bool visibleBySummonerOnly = false);
+ TempSummon* SummonCreature(uint32 entry, Position const& pos, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime = 0s, uint32 vehId = 0, uint32 spellId = 0, bool personalSpawn = false);
+ TempSummon* SummonCreature(uint32 entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime = 0s, bool personalSpawn = false);
GameObject* SummonGameObject(uint32 entry, Position const& pos, QuaternionData const& rot, Seconds respawnTime, GOSummonType summonType = GO_SUMMON_TIMED_OR_CORPSE_DESPAWN);
GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, QuaternionData const& rot, Seconds respawnTime, GOSummonType summonType = GO_SUMMON_TIMED_OR_CORPSE_DESPAWN);
Creature* SummonTrigger(float x, float y, float z, float ang, Milliseconds despawnTime, CreatureAI* (*GetAI)(Creature*) = nullptr);
@@ -546,6 +546,11 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
// Event handler
EventProcessor m_Events;
+ // Watcher
+ bool IsPrivateObject() const { return !_privateObjectOwner.IsEmpty(); }
+ ObjectGuid GetPrivateObjectOwner() const { return _privateObjectOwner; }
+ void SetPrivateObjectOwner(ObjectGuid const& owner) { _privateObjectOwner = owner; }
+
protected:
std::string m_name;
bool m_isActive;
@@ -582,6 +587,9 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
uint32 m_phaseMask; // in area phase state
uint16 m_notifyflags;
+
+ ObjectGuid _privateObjectOwner;
+
virtual bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D, bool incOwnRadius = true, bool incTargetRadius = true) const;
bool CanNeverSee(WorldObject const* obj) const;