Enable GameObject faction check for worldobject searchers and fix a typo
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
#include "World.h"
|
||||
#include "Object.h"
|
||||
#include "Unit.h"
|
||||
#include "GameObject.h"
|
||||
#include "DBCStores.h"
|
||||
|
||||
uint32 ElunaUtil::GetCurrTime()
|
||||
{
|
||||
@@ -46,8 +48,14 @@ bool ElunaUtil::ObjectDistanceOrderPred::operator()(WorldObject const* pLeft, Wo
|
||||
|
||||
ElunaUtil::WorldObjectInRangeCheck::WorldObjectInRangeCheck(bool nearest, WorldObject const* obj, float range,
|
||||
uint16 typeMask, uint32 entry, uint32 hostile, uint32 dead) :
|
||||
i_obj(obj), i_hostile(hostile), i_entry(entry), i_range(range), i_typeMask(typeMask), i_dead(dead), i_nearest(nearest)
|
||||
i_obj(obj), i_obj_unit(nullptr), i_obj_fact(nullptr), i_hostile(hostile), i_entry(entry), i_range(range), i_typeMask(typeMask), i_dead(dead), i_nearest(nearest)
|
||||
{
|
||||
i_obj_unit = i_obj->ToUnit();
|
||||
if (!i_obj_unit)
|
||||
if (GameObject const* go = i_obj->ToGameObject())
|
||||
i_obj_unit = go->GetOwner();
|
||||
if (!i_obj_unit)
|
||||
i_obj_fact = sFactionTemplateStore.LookupEntry(14);
|
||||
}
|
||||
WorldObject const& ElunaUtil::WorldObjectInRangeCheck::GetFocusObject() const
|
||||
{
|
||||
@@ -63,22 +71,38 @@ bool ElunaUtil::WorldObjectInRangeCheck::operator()(WorldObject* u)
|
||||
return false;
|
||||
if (!i_obj->IsWithinDistInMap(u, i_range))
|
||||
return false;
|
||||
if (Unit* unit = u->ToUnit())
|
||||
Unit const* target = u->ToUnit();
|
||||
if (!target)
|
||||
if (GameObject const* go = u->ToGameObject())
|
||||
target = go->GetOwner();
|
||||
if (target)
|
||||
{
|
||||
#ifdef CMANGOS
|
||||
if (i_dead && (i_dead == 1) != unit->isAlive())
|
||||
if (i_dead && (i_dead == 1) != target->isAlive())
|
||||
return false;
|
||||
#else
|
||||
if (i_dead && (i_dead == 1) != unit->IsAlive())
|
||||
if (i_dead && (i_dead == 1) != target->IsAlive())
|
||||
return false;
|
||||
#endif
|
||||
if (i_hostile)
|
||||
{
|
||||
if (const Unit* obj = i_obj->ToUnit())
|
||||
if (!i_obj_unit)
|
||||
{
|
||||
if ((i_hostile == 1) != obj->IsHostileTo(unit))
|
||||
if (i_obj_fact)
|
||||
{
|
||||
#ifdef TRINITY
|
||||
if ((i_obj_fact->IsHostileTo(*target->GetFactionTemplateEntry())) != (i_hostile == 1))
|
||||
return false;
|
||||
#else
|
||||
if ((i_obj_fact->IsHostileTo(*target->getFactionTemplateEntry())) != (i_hostile == 1))
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
else if (i_hostile == 1)
|
||||
return false;
|
||||
}
|
||||
else if ((i_hostile == 1) != i_obj_unit->IsHostileTo(target))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (i_nearest)
|
||||
|
||||
Reference in New Issue
Block a user