Entities/GO: FindNearestGameObject no longer incorrectly returns despawned gameobjects.

Port From (https://github.com/TrinityCore/TrinityCore/commit/6de4c3cd72de1c7ae6e467b09ec181445b397338)
This commit is contained in:
hondacrx
2021-12-27 16:56:27 -05:00
parent 51bf6d6ecd
commit b7f85e9e43
+15 -5
View File
@@ -2481,7 +2481,7 @@ namespace Game.Maps
public class AllCreaturesOfEntryInRange : ICheck<Creature> public class AllCreaturesOfEntryInRange : ICheck<Creature>
{ {
public AllCreaturesOfEntryInRange(WorldObject obj, uint entry, float maxRange) public AllCreaturesOfEntryInRange(WorldObject obj, uint entry, float maxRange = 0f)
{ {
m_pObject = obj; m_pObject = obj;
m_uiEntry = entry; m_uiEntry = entry;
@@ -2490,12 +2490,22 @@ namespace Game.Maps
public bool Invoke(Creature creature) public bool Invoke(Creature creature)
{ {
if (m_uiEntry == 0 || creature.GetEntry() == m_uiEntry && m_pObject.IsWithinDist(creature, m_fRange, false)) if (m_uiEntry != 0)
return true; {
if (creature.GetEntry() != m_uiEntry)
return false; return false;
} }
if (m_fRange != 0f)
{
if (m_fRange > 0.0f && !m_pObject.IsWithinDist(creature, m_fRange, false))
return false;
if (m_fRange < 0.0f && m_pObject.IsWithinDist(creature, m_fRange, false))
return false;
}
return true;
}
WorldObject m_pObject; WorldObject m_pObject;
uint m_uiEntry; uint m_uiEntry;
float m_fRange; float m_fRange;
@@ -2740,7 +2750,7 @@ namespace Game.Maps
public bool Invoke(GameObject go) public bool Invoke(GameObject go)
{ {
if (go.GetEntry() == i_entry && go.GetGUID() != i_obj.GetGUID() && i_obj.IsWithinDistInMap(go, i_range)) if (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 i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check
return true; return true;