diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Grids/Notifiers/GridNotifiers.h | 311 |
1 files changed, 169 insertions, 142 deletions
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index 66540add24b..75f33d099ec 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -626,6 +626,7 @@ namespace Trinity { public: GameObjectFocusCheck(Unit const* unit, uint32 focusId) : i_unit(unit), i_focusId(focusId) { } + bool operator()(GameObject* go) const { if (go->GetGOInfo()->type != GAMEOBJECT_TYPE_SPELL_FOCUS) @@ -638,6 +639,7 @@ namespace Trinity return go->IsWithinDistInMap(i_unit, dist); } + private: Unit const* i_unit; uint32 i_focusId; @@ -648,6 +650,7 @@ namespace Trinity { public: NearestGameObjectFishingHole(WorldObject const& obj, float range) : i_obj(obj), i_range(range) { } + bool operator()(GameObject* go) { if (go->GetGOInfo()->type == GAMEOBJECT_TYPE_FISHINGHOLE && go->isSpawned() && i_obj.IsWithinDistInMap(go, i_range) && i_obj.IsWithinDistInMap(go, (float)go->GetGOInfo()->fishingHole.radius)) @@ -657,19 +660,20 @@ namespace Trinity } return false; } - float GetLastRange() const { return i_range; } + private: WorldObject const& i_obj; - float i_range; + float i_range; // prevent clone - NearestGameObjectFishingHole(NearestGameObjectFishingHole const&); + NearestGameObjectFishingHole(NearestGameObjectFishingHole const&) = delete; }; class NearestGameObjectCheck { public: - NearestGameObjectCheck(WorldObject const& obj) : i_obj(obj), i_range(999) { } + NearestGameObjectCheck(WorldObject const& obj) : i_obj(obj), i_range(999.f) { } + bool operator()(GameObject* go) { if (i_obj.IsWithinDistInMap(go, i_range)) @@ -679,13 +683,13 @@ namespace Trinity } return false; } - float GetLastRange() const { return i_range; } + private: WorldObject const& i_obj; float i_range; // prevent clone this object - NearestGameObjectCheck(NearestGameObjectCheck const&); + NearestGameObjectCheck(NearestGameObjectCheck const&) = delete; }; // Success at unit in range, range update for next check (this can be use with GameobjectLastSearcher to find nearest GO) @@ -693,6 +697,7 @@ namespace Trinity { public: NearestGameObjectEntryInObjectRangeCheck(WorldObject const& obj, uint32 entry, float range) : i_obj(obj), i_entry(entry), i_range(range) { } + bool operator()(GameObject* go) { if (go->GetEntry() == i_entry && i_obj.IsWithinDistInMap(go, i_range)) @@ -702,38 +707,39 @@ namespace Trinity } return false; } - float GetLastRange() const { return i_range; } + private: WorldObject const& i_obj; uint32 i_entry; float i_range; // prevent clone this object - NearestGameObjectEntryInObjectRangeCheck(NearestGameObjectEntryInObjectRangeCheck const&); + NearestGameObjectEntryInObjectRangeCheck(NearestGameObjectEntryInObjectRangeCheck const&) = delete; }; // Success at unit in range, range update for next check (this can be use with GameobjectLastSearcher to find nearest GO with a certain type) class NearestGameObjectTypeInObjectRangeCheck { - public: - NearestGameObjectTypeInObjectRangeCheck(WorldObject const& obj, GameobjectTypes type, float range) : i_obj(obj), i_type(type), i_range(range) { } - bool operator()(GameObject* go) - { - if (go->GetGoType() == i_type && i_obj.IsWithinDistInMap(go, i_range)) + public: + NearestGameObjectTypeInObjectRangeCheck(WorldObject const& obj, GameobjectTypes type, float range) : i_obj(obj), i_type(type), i_range(range) { } + + bool operator()(GameObject* go) { - i_range = i_obj.GetDistance(go); // use found GO range as new range limit for next check - return true; + if (go->GetGoType() == i_type && 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; + } + return false; } - return false; - } - float GetLastRange() const { return i_range; } - private: - WorldObject const& i_obj; - GameobjectTypes i_type; - float i_range; - // prevent clone this object - NearestGameObjectTypeInObjectRangeCheck(NearestGameObjectTypeInObjectRangeCheck const&); + private: + WorldObject const& i_obj; + GameobjectTypes i_type; + float i_range; + + // prevent clone this object + NearestGameObjectTypeInObjectRangeCheck(NearestGameObjectTypeInObjectRangeCheck const&) = delete; }; // Unit checks @@ -742,6 +748,7 @@ namespace Trinity { public: MostHPMissingInRange(Unit const* obj, float range, uint32 hp) : i_obj(obj), i_range(range), i_hp(hp) { } + bool operator()(Unit* u) { if (u->IsAlive() && u->IsInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && u->GetMaxHealth() - u->GetHealth() > i_hp) @@ -751,6 +758,7 @@ namespace Trinity } return false; } + private: Unit const* i_obj; float i_range; @@ -761,7 +769,8 @@ namespace Trinity { public: FriendlyCCedInRange(Unit const* obj, float range) : i_obj(obj), i_range(range) { } - bool operator()(Unit* u) + + bool operator()(Unit* u) const { if (u->IsAlive() && u->IsInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && (u->isFeared() || u->IsCharmed() || u->isFrozen() || u->HasUnitState(UNIT_STATE_STUNNED) || u->HasUnitState(UNIT_STATE_CONFUSED))) @@ -770,6 +779,7 @@ namespace Trinity } return false; } + private: Unit const* i_obj; float i_range; @@ -779,15 +789,15 @@ namespace Trinity { public: FriendlyMissingBuffInRange(Unit const* obj, float range, uint32 spellid) : i_obj(obj), i_range(range), i_spell(spellid) { } - bool operator()(Unit* u) + + bool operator()(Unit* u) const { - if (u->IsAlive() && u->IsInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && - !(u->HasAura(i_spell))) - { + if (u->IsAlive() && u->IsInCombat() && !i_obj->IsHostileTo(u) && i_obj->IsWithinDistInMap(u, i_range) && !u->HasAura(i_spell)) return true; - } + return false; } + private: Unit const* i_obj; float i_range; @@ -798,13 +808,15 @@ namespace Trinity { public: AnyUnfriendlyUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) { } - bool operator()(Unit* u) + + bool operator()(Unit* u) const { if (u->IsAlive() && i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u)) return true; - else - return false; + + return false; } + private: WorldObject const* i_obj; Unit const* i_funit; @@ -815,6 +827,7 @@ namespace Trinity { 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()) @@ -831,6 +844,7 @@ namespace Trinity return i_obj->IsWithinDistInMap(u, i_range) && !i_funit->IsFriendlyTo(u); } + private: WorldObject const* i_obj; Unit const* i_funit; @@ -841,13 +855,15 @@ namespace Trinity { public: AnyFriendlyUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range, bool playerOnly = false) : i_obj(obj), i_funit(funit), i_range(range), i_playerOnly(playerOnly) { } - bool operator()(Unit* u) + + bool operator()(Unit* u) const { if (u->IsAlive() && i_obj->IsWithinDistInMap(u, i_range) && i_funit->IsFriendlyTo(u) && (!i_playerOnly || u->GetTypeId() == TYPEID_PLAYER)) return true; else return false; } + private: WorldObject const* i_obj; Unit const* i_funit; @@ -859,7 +875,8 @@ namespace Trinity { public: AnyGroupedUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range, bool raid) : _source(obj), _refUnit(funit), _range(range), _raid(raid) { } - bool operator()(Unit* u) + + bool operator()(Unit* u) const { if (G3D::fuzzyEq(_range, 0)) return false; @@ -886,13 +903,15 @@ namespace Trinity { public: AnyUnitInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) { } - bool operator()(Unit* u) + + bool operator()(Unit* u) const { if (u->IsAlive() && i_obj->IsWithinDistInMap(u, i_range)) return true; return false; } + private: WorldObject const* i_obj; float i_range; @@ -903,6 +922,7 @@ namespace Trinity { public: NearestAttackableUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) { } + bool operator()(Unit* u) { if (u->isTargetableForAttack() && i_obj->IsWithinDistInMap(u, i_range) && @@ -914,13 +934,14 @@ namespace Trinity return false; } + private: WorldObject const* i_obj; Unit const* i_funit; float i_range; // prevent clone this object - NearestAttackableUnitInObjectRangeCheck(NearestAttackableUnitInObjectRangeCheck const&); + NearestAttackableUnitInObjectRangeCheck(NearestAttackableUnitInObjectRangeCheck const&) = delete; }; class AnyAoETargetUnitInObjectRangeCheck @@ -929,15 +950,11 @@ namespace Trinity AnyAoETargetUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), _spellInfo(NULL), i_range(range) { - Unit const* check = i_funit; - Unit const* owner = i_funit->GetOwner(); - if (owner) - check = owner; - i_targetForPlayer = (check->GetTypeId() == TYPEID_PLAYER); if (DynamicObject const* dynObj = i_obj->ToDynObject()) _spellInfo = sSpellMgr->GetSpellInfo(dynObj->GetSpellId()); } - bool operator()(Unit* u) + + bool operator()(Unit* u) const { // Check contains checks for: live, non-selectable, non-attackable flags, flight check and GM check, ignore totems if (u->GetTypeId() == TYPEID_UNIT && u->IsTotem()) @@ -948,8 +965,8 @@ namespace Trinity return false; } + private: - bool i_targetForPlayer; WorldObject const* i_obj; Unit const* i_funit; SpellInfo const* _spellInfo; @@ -961,9 +978,9 @@ namespace Trinity { public: CallOfHelpCreatureInRangeDo(Unit* funit, Unit* enemy, float range) - : i_funit(funit), i_enemy(enemy), i_range(range) - { } - void operator()(Creature* u) + : i_funit(funit), i_enemy(enemy), i_range(range) { } + + void operator()(Creature* u) const { if (u == i_funit) return; @@ -990,25 +1007,22 @@ namespace Trinity struct AnyDeadUnitCheck { - bool operator()(Unit* u) { return !u->IsAlive(); } - }; - - /* - struct AnyStealthedCheck - { - bool operator()(Unit* u) { return u->GetVisibility() == VISIBILITY_GROUP_STEALTH; } + bool operator()(Unit* u) const + { + return !u->IsAlive(); + } }; - */ // Creature checks class NearestHostileUnitCheck { public: - explicit NearestHostileUnitCheck(Creature const* creature, float dist = 0, bool playerOnly = false) : me(creature), i_playerOnly(playerOnly) + explicit NearestHostileUnitCheck(Creature const* creature, float dist = 0.f, bool playerOnly = false) : me(creature), i_playerOnly(playerOnly) { - m_range = (dist == 0 ? 9999 : dist); + m_range = (dist == 0.f ? 9999.f : dist); } + bool operator()(Unit* u) { if (!me->IsWithinDistInMap(u, m_range)) @@ -1024,21 +1038,22 @@ namespace Trinity return true; } - private: + private: Creature const* me; float m_range; bool i_playerOnly; - NearestHostileUnitCheck(NearestHostileUnitCheck const&); + NearestHostileUnitCheck(NearestHostileUnitCheck const&) = delete; }; class NearestHostileUnitInAttackDistanceCheck { public: - explicit NearestHostileUnitInAttackDistanceCheck(Creature const* creature, float dist = 0) : me(creature) + explicit NearestHostileUnitInAttackDistanceCheck(Creature const* creature, float dist = 0.f) : me(creature) { - m_range = (dist == 0 ? 9999 : dist); - m_force = (dist == 0 ? false : true); + m_range = (dist == 0.f ? 9999.f : dist); + m_force = (dist == 0.f ? false : true); } + bool operator()(Unit* u) { if (!me->IsWithinDistInMap(u, m_range)) @@ -1058,21 +1073,20 @@ namespace Trinity m_range = me->GetDistance(u); // use found unit range as new range limit for next check return true; } - float GetLastRange() const { return m_range; } + private: Creature const* me; float m_range; bool m_force; - NearestHostileUnitInAttackDistanceCheck(NearestHostileUnitInAttackDistanceCheck const&); + NearestHostileUnitInAttackDistanceCheck(NearestHostileUnitInAttackDistanceCheck const&) = delete; }; class NearestHostileUnitInAggroRangeCheck { public: - explicit NearestHostileUnitInAggroRangeCheck(Creature const* creature, bool useLOS = false) : _me(creature), _useLOS(useLOS) - { - } - bool operator()(Unit* u) + explicit NearestHostileUnitInAggroRangeCheck(Creature const* creature, bool useLOS = false) : _me(creature), _useLOS(useLOS) { } + + bool operator()(Unit* u) const { if (!u->IsHostileTo(_me)) return false; @@ -1089,20 +1103,19 @@ namespace Trinity return true; } - private: + private: Creature const* _me; bool _useLOS; - NearestHostileUnitInAggroRangeCheck(NearestHostileUnitInAggroRangeCheck const&); + NearestHostileUnitInAggroRangeCheck(NearestHostileUnitInAggroRangeCheck const&) = delete; }; class AnyAssistCreatureInRangeCheck { public: AnyAssistCreatureInRangeCheck(Unit* funit, Unit* enemy, float range) - : i_funit(funit), i_enemy(enemy), i_range(range) - { - } - bool operator()(Creature* u) + : i_funit(funit), i_enemy(enemy), i_range(range) { } + + bool operator()(Creature* u) const { if (u == i_funit) return false; @@ -1120,6 +1133,7 @@ namespace Trinity return true; } + private: Unit* const i_funit; Unit* const i_enemy; @@ -1148,14 +1162,14 @@ namespace Trinity i_range = i_obj->GetDistance(u); // use found unit range as new range limit for next check return true; } - float GetLastRange() const { return i_range; } + private: Creature* const i_obj; Unit* const i_enemy; float i_range; // prevent clone this object - NearestAssistCreatureInCreatureRangeCheck(NearestAssistCreatureInCreatureRangeCheck const&); + NearestAssistCreatureInCreatureRangeCheck(NearestAssistCreatureInCreatureRangeCheck const&) = delete; }; // Success at unit in range, range update for next check (this can be use with CreatureLastSearcher to find nearest creature) @@ -1174,7 +1188,7 @@ namespace Trinity } return false; } - float GetLastRange() const { return i_range; } + private: WorldObject const& i_obj; uint32 i_entry; @@ -1182,14 +1196,15 @@ namespace Trinity float i_range; // prevent clone this object - NearestCreatureEntryWithLiveStateInObjectRangeCheck(NearestCreatureEntryWithLiveStateInObjectRangeCheck const&); + NearestCreatureEntryWithLiveStateInObjectRangeCheck(NearestCreatureEntryWithLiveStateInObjectRangeCheck const&) = delete; }; class AnyPlayerInObjectRangeCheck { public: AnyPlayerInObjectRangeCheck(WorldObject const* obj, float range, bool reqAlive = true) : _obj(obj), _range(range), _reqAlive(reqAlive) { } - bool operator()(Player* u) + + bool operator()(Player* u) const { if (_reqAlive && !u->IsAlive()) return false; @@ -1209,9 +1224,7 @@ namespace Trinity class NearestPlayerInObjectRangeCheck { public: - NearestPlayerInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) - { - } + NearestPlayerInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) { } bool operator()(Player* u) { @@ -1227,46 +1240,51 @@ namespace Trinity WorldObject const* i_obj; float i_range; - NearestPlayerInObjectRangeCheck(NearestPlayerInObjectRangeCheck const&); + NearestPlayerInObjectRangeCheck(NearestPlayerInObjectRangeCheck const&) = delete; }; class AllFriendlyCreaturesInGrid { - public: - AllFriendlyCreaturesInGrid(Unit const* obj) : unit(obj) { } - bool operator() (Unit* u) - { - if (u->IsAlive() && u->IsVisible() && u->IsFriendlyTo(unit)) - return true; + public: + AllFriendlyCreaturesInGrid(Unit const* obj) : unit(obj) { } - return false; - } - private: - Unit const* unit; + bool operator()(Unit* u) const + { + if (u->IsAlive() && u->IsVisible() && u->IsFriendlyTo(unit)) + return true; + + return false; + } + + private: + Unit const* unit; }; class AllGameObjectsWithEntryInRange { - public: - AllGameObjectsWithEntryInRange(const WorldObject* object, uint32 entry, float maxRange) : m_pObject(object), m_uiEntry(entry), m_fRange(maxRange) { } - bool operator() (GameObject* go) - { - if (go->GetEntry() == m_uiEntry && m_pObject->IsWithinDist(go, m_fRange, false)) - return true; + public: + AllGameObjectsWithEntryInRange(const WorldObject* object, uint32 entry, float maxRange) : m_pObject(object), m_uiEntry(entry), m_fRange(maxRange) { } - return false; - } - private: - const WorldObject* m_pObject; - uint32 m_uiEntry; - float m_fRange; + bool operator()(GameObject* go) const + { + if (go->GetEntry() == m_uiEntry && m_pObject->IsWithinDist(go, m_fRange, false)) + return true; + + return false; + } + + private: + WorldObject const* m_pObject; + uint32 m_uiEntry; + float m_fRange; }; class AllCreaturesOfEntryInRange { public: AllCreaturesOfEntryInRange(const WorldObject* object, uint32 entry, float maxRange) : m_pObject(object), m_uiEntry(entry), m_fRange(maxRange) { } - bool operator() (Unit* unit) + + bool operator()(Unit* unit) const { if (unit->GetEntry() == m_uiEntry && m_pObject->IsWithinDist(unit, m_fRange, false)) return true; @@ -1275,63 +1293,69 @@ namespace Trinity } private: - const WorldObject* m_pObject; + WorldObject const* m_pObject; uint32 m_uiEntry; float m_fRange; }; class PlayerAtMinimumRangeAway { - public: - PlayerAtMinimumRangeAway(Unit const* unit, float fMinRange) : unit(unit), fRange(fMinRange) { } - bool operator() (Player* player) - { - //No threat list check, must be done explicit if expected to be in combat with creature - if (!player->IsGameMaster() && player->IsAlive() && !unit->IsWithinDist(player, fRange, false)) - return true; + public: + PlayerAtMinimumRangeAway(Unit const* unit, float fMinRange) : unit(unit), fRange(fMinRange) { } - return false; - } + bool operator()(Player* player) const + { + //No threat list check, must be done explicit if expected to be in combat with creature + if (!player->IsGameMaster() && player->IsAlive() && !unit->IsWithinDist(player, fRange, false)) + return true; - private: - Unit const* unit; - float fRange; + return false; + } + + private: + Unit const* unit; + float fRange; }; class GameObjectInRangeCheck { - public: - GameObjectInRangeCheck(float _x, float _y, float _z, float _range, uint32 _entry = 0) : - x(_x), y(_y), z(_z), range(_range), entry(_entry) { } - bool operator() (GameObject* go) - { - if (!entry || (go->GetGOInfo() && go->GetGOInfo()->entry == entry)) - return go->IsInRange(x, y, z, range); - else return false; - } - private: - float x, y, z, range; - uint32 entry; + public: + GameObjectInRangeCheck(float _x, float _y, float _z, float _range, uint32 _entry = 0) : + x(_x), y(_y), z(_z), range(_range), entry(_entry) { } + + bool operator()(GameObject* go) const + { + if (!entry || (go->GetGOInfo() && go->GetGOInfo()->entry == entry)) + return go->IsInRange(x, y, z, range); + else return false; + } + + private: + float x, y, z, range; + uint32 entry; }; class AllWorldObjectsInRange { - public: - AllWorldObjectsInRange(const WorldObject* object, float maxRange) : m_pObject(object), m_fRange(maxRange) { } - bool operator() (WorldObject* go) - { - return m_pObject->IsWithinDist(go, m_fRange, false) && m_pObject->IsInPhase(go); - } - private: - const WorldObject* m_pObject; - float m_fRange; + public: + AllWorldObjectsInRange(const WorldObject* object, float maxRange) : m_pObject(object), m_fRange(maxRange) { } + + bool operator()(WorldObject* go) const + { + return m_pObject->IsWithinDist(go, m_fRange, false) && m_pObject->IsInPhase(go); + } + + private: + WorldObject const* m_pObject; + float m_fRange; }; class ObjectTypeIdCheck { public: ObjectTypeIdCheck(TypeID typeId, bool equals) : _typeId(typeId), _equals(equals) { } - bool operator()(WorldObject* object) + + bool operator()(WorldObject* object) const { return (object->GetTypeId() == _typeId) == _equals; } @@ -1345,7 +1369,8 @@ namespace Trinity { public: ObjectGUIDCheck(ObjectGuid GUID) : _GUID(GUID) { } - bool operator()(WorldObject* object) + + bool operator()(WorldObject* object) const { return object->GetGUID() == _GUID; } @@ -1377,6 +1402,7 @@ namespace Trinity { public: UnitAuraCheck(bool present, uint32 spellId, ObjectGuid casterGUID = ObjectGuid::Empty) : _present(present), _spellId(spellId), _casterGUID(casterGUID) { } + bool operator()(Unit* unit) const { return unit->HasAura(_spellId, _casterGUID) == _present; @@ -1407,6 +1433,7 @@ namespace Trinity for (size_t i = 0; i < i_data_cache.size(); ++i) delete i_data_cache[i]; } + void operator()(Player* p); private: |