aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2020-09-04 22:01:25 +0200
committerjackpoz <giacomopoz@gmail.com>2020-09-04 22:01:25 +0200
commitca2159bf405fb96a8eba9f1e58bda7ee6c7eb247 (patch)
tree272074de48093474e53d2a25a4a50632c3789463 /src/server/game
parenta58aeb41f466fd916cdc12e805f7a8130c8ccdf5 (diff)
Scripts/Obsidian Sanctum: Fix portals not being visible
Change NearestGameObjectEntryInObjectRangeCheck to allow returning GameObject not spawned. Fixes other occurrences where a similar issue exists.
Diffstat (limited to 'src/server/game')
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.h4
-rw-r--r--src/server/game/Entities/Object/Object.cpp4
-rw-r--r--src/server/game/Entities/Object/Object.h2
-rw-r--r--src/server/game/Grids/Notifiers/GridNotifiers.h5
4 files changed, 8 insertions, 7 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h
index 08c71cf1c2c..6e80dc30438 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h
@@ -385,9 +385,9 @@ inline Creature* GetClosestCreatureWithEntry(WorldObject* source, uint32 entry,
return source->FindNearestCreature(entry, maxSearchRange, alive);
}
-inline GameObject* GetClosestGameObjectWithEntry(WorldObject* source, uint32 entry, float maxSearchRange)
+inline GameObject* GetClosestGameObjectWithEntry(WorldObject* source, uint32 entry, float maxSearchRange, bool spawnedOnly = true)
{
- return source->FindNearestGameObject(entry, maxSearchRange);
+ return source->FindNearestGameObject(entry, maxSearchRange, spawnedOnly);
}
template <typename Container>
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 6867838b85a..a1bdca52d97 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -2100,10 +2100,10 @@ Creature* WorldObject::FindNearestCreature(uint32 entry, float range, bool alive
return creature;
}
-GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range) const
+GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range, bool spawnedOnly) const
{
GameObject* go = nullptr;
- Trinity::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range);
+ Trinity::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range, spawnedOnly);
Trinity::GameObjectLastSearcher<Trinity::NearestGameObjectEntryInObjectRangeCheck> searcher(this, go, checker);
Cell::VisitGridObjects(this, searcher, range);
return go;
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index 954db82ec1e..1fb239a1031 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -412,7 +412,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = nullptr);
Creature* FindNearestCreature(uint32 entry, float range, bool alive = true) const;
- GameObject* FindNearestGameObject(uint32 entry, float range) const;
+ GameObject* FindNearestGameObject(uint32 entry, float range, bool spawnedOnly = true) const;
GameObject* FindNearestUnspawnedGameObject(uint32 entry, float range) const;
GameObject* FindNearestGameObjectOfType(GameobjectTypes type, float range) const;
Player* SelectNearestPlayer(float distance) const;
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h
index 0b8c45051ed..b116760c411 100644
--- a/src/server/game/Grids/Notifiers/GridNotifiers.h
+++ b/src/server/game/Grids/Notifiers/GridNotifiers.h
@@ -736,11 +736,11 @@ namespace Trinity
class NearestGameObjectEntryInObjectRangeCheck
{
public:
- NearestGameObjectEntryInObjectRangeCheck(WorldObject const& obj, uint32 entry, float range) : i_obj(obj), i_entry(entry), i_range(range) { }
+ NearestGameObjectEntryInObjectRangeCheck(WorldObject const& obj, uint32 entry, float range, bool spawnedOnly = true) : i_obj(obj), i_entry(entry), i_range(range), i_spawnedOnly(spawnedOnly) { }
bool operator()(GameObject* go)
{
- if (go->isSpawned() && go->GetEntry() == i_entry && go->GetGUID() != i_obj.GetGUID() && i_obj.IsWithinDistInMap(go, i_range))
+ if ((!i_spawnedOnly || go->isSpawned()) && go->GetEntry() == i_entry && go->GetGUID() != i_obj.GetGUID() && i_obj.IsWithinDistInMap(go, i_range))
{
i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check
return true;
@@ -752,6 +752,7 @@ namespace Trinity
WorldObject const& i_obj;
uint32 i_entry;
float i_range;
+ bool i_spawnedOnly;
// prevent clone this object
NearestGameObjectEntryInObjectRangeCheck(NearestGameObjectEntryInObjectRangeCheck const&) = delete;