aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQAston <none@none>2009-02-13 20:16:38 +0100
committerQAston <none@none>2009-02-13 20:16:38 +0100
commit5f6705535b9ef5d37521a9078e7dea84a303ebe2 (patch)
tree0dba41dcf98931023e51d790bc2d729fc2a1c90a /src
parent5113bd989dc5666425fffa85b3bd24b1d02aaffb (diff)
*Fix bug that traps were activated by totems.
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/GameObject.cpp8
-rw-r--r--src/game/GridNotifiers.h17
2 files changed, 21 insertions, 4 deletions
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index b7487568e62..82102a99444 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -309,18 +309,18 @@ void GameObject::Update(uint32 /*p_time*/)
// search unfriendly creature
if(owner && NeedDespawn) // hunter trap
{
- Trinity::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, owner, radius);
- Trinity::UnitSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck> checker(ok, u_check);
+ Trinity::AnyUnfriendlyNoTotemUnitInObjectRangeCheck u_check(this, owner, radius);
+ Trinity::UnitSearcher<Trinity::AnyUnfriendlyNoTotemUnitInObjectRangeCheck> checker(ok, u_check);
CellLock<GridReadGuard> cell_lock(cell, p);
- TypeContainerVisitor<Trinity::UnitSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_object_checker(checker);
+ TypeContainerVisitor<Trinity::UnitSearcher<Trinity::AnyUnfriendlyNoTotemUnitInObjectRangeCheck>, GridTypeMapContainer > grid_object_checker(checker);
cell_lock->Visit(cell_lock, grid_object_checker, *MapManager::Instance().GetMap(GetMapId(), this));
// or unfriendly player/pet
if(!ok)
{
- TypeContainerVisitor<Trinity::UnitSearcher<Trinity::AnyUnfriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker);
+ TypeContainerVisitor<Trinity::UnitSearcher<Trinity::AnyUnfriendlyNoTotemUnitInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker);
cell_lock->Visit(cell_lock, world_object_checker, *MapManager::Instance().GetMap(GetMapId(), this));
}
}
diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h
index 4bbb31c65c0..f0d7a5da034 100644
--- a/src/game/GridNotifiers.h
+++ b/src/game/GridNotifiers.h
@@ -596,6 +596,23 @@ namespace Trinity
float i_range;
};
+ class AnyUnfriendlyNoTotemUnitInObjectRangeCheck
+ {
+ public:
+ AnyUnfriendlyNoTotemUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) {}
+ bool operator()(Unit* u)
+ {
+ if(u->isAlive() && i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u) && !((Creature*)u)->isTotem())
+ return true;
+ else
+ return false;
+ }
+ private:
+ WorldObject const* i_obj;
+ Unit const* i_funit;
+ float i_range;
+ };
+
class CreatureWithDbGUIDCheck
{
public: