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 AllCreaturesOfEntryInRange(WorldObject obj, uint entry, float maxRange)
public AllCreaturesOfEntryInRange(WorldObject obj, uint entry, float maxRange = 0f)
{
m_pObject = obj;
m_uiEntry = entry;
@@ -2490,10 +2490,20 @@ namespace Game.Maps
public bool Invoke(Creature creature)
{
if (m_uiEntry == 0 || creature.GetEntry() == m_uiEntry && m_pObject.IsWithinDist(creature, m_fRange, false))
return true;
if (m_uiEntry != 0)
{
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;
@@ -2740,7 +2750,7 @@ namespace Game.Maps
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
return true;