diff options
author | ariel- <ariel-@users.noreply.github.com> | 2016-11-13 17:55:40 -0300 |
---|---|---|
committer | ariel- <ariel-@users.noreply.github.com> | 2016-11-13 19:13:10 -0300 |
commit | c98ab6bd94f2f5e4b8b28f06a326a4b4da8d3915 (patch) | |
tree | 3c335b841cdfe757399b5fea50df28c154206937 | |
parent | bf5799fce5da19a78af6805e29ee75da4d147f12 (diff) |
Core/Misc: codestyle fixes in GridNotifiers.h
- Removed dead code, outdated comments
- Fixed indentation
- Explicitly delete copy ctors
- const'd the operator() definitions
-rw-r--r-- | src/server/game/Grids/Notifiers/GridNotifiers.h | 312 |
1 files changed, 165 insertions, 147 deletions
diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index d029f0fb8d0..263ba355865 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -642,6 +642,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) @@ -657,6 +658,7 @@ namespace Trinity return go->IsWithinDistInMap(i_unit, dist); } + private: Unit const* i_unit; uint32 i_focusId; @@ -667,6 +669,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)) @@ -676,19 +679,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)) @@ -698,13 +702,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) @@ -712,6 +716,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)) @@ -721,38 +726,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 @@ -761,6 +767,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) @@ -770,6 +777,7 @@ namespace Trinity } return false; } + private: Unit const* i_obj; float i_range; @@ -780,7 +788,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))) @@ -789,6 +798,7 @@ namespace Trinity } return false; } + private: Unit const* i_obj; float i_range; @@ -798,15 +808,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; @@ -817,13 +827,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; @@ -834,6 +846,7 @@ namespace Trinity { public: NearestUnfriendlyNoTotemUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range) : i_obj(obj), i_funit(funit), i_range(range) { } + bool operator()(Unit* u) { if (!u->IsAlive()) @@ -854,6 +867,7 @@ namespace Trinity i_range = i_obj->GetDistance(*u); return true; } + private: WorldObject const* i_obj; Unit const* i_funit; @@ -864,13 +878,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; @@ -882,7 +898,8 @@ namespace Trinity { public: AnyGroupedUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range, bool raid, bool playerOnly = false) : _source(obj), _refUnit(funit), _range(range), _raid(raid), _playerOnly(playerOnly) { } - bool operator()(Unit* u) + + bool operator()(Unit* u) const { if (G3D::fuzzyEq(_range, 0.0f)) return false; @@ -913,13 +930,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; @@ -930,6 +949,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) && @@ -941,13 +961,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 @@ -956,17 +977,12 @@ namespace Trinity AnyAoETargetUnitInObjectRangeCheck(WorldObject const* obj, Unit const* funit, float range, SpellInfo const* spellInfo = nullptr) : i_obj(obj), i_funit(funit), _spellInfo(spellInfo), 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 (!_spellInfo) 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()) @@ -977,8 +993,8 @@ namespace Trinity return i_funit->_IsValidAttackTarget(u, _spellInfo, i_obj->GetTypeId() == TYPEID_DYNAMICOBJECT ? i_obj : nullptr) && i_obj->IsWithinDistInMap(u, i_range); } + private: - bool i_targetForPlayer; WorldObject const* i_obj; Unit const* i_funit; SpellInfo const* _spellInfo; @@ -990,9 +1006,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; @@ -1017,27 +1033,16 @@ namespace Trinity float i_range; }; - struct AnyDeadUnitCheck - { - bool operator()(Unit* u) { return !u->IsAlive(); } - }; - - /* - struct AnyStealthedCheck - { - bool operator()(Unit* u) { return u->GetVisibility() == VISIBILITY_GROUP_STEALTH; } - }; - */ - // 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)) @@ -1053,21 +1058,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)) @@ -1087,21 +1093,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; @@ -1118,20 +1123,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; @@ -1149,6 +1153,7 @@ namespace Trinity return true; } + private: Unit* const i_funit; Unit* const i_enemy; @@ -1177,14 +1182,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) @@ -1203,7 +1208,7 @@ namespace Trinity } return false; } - float GetLastRange() const { return i_range; } + private: WorldObject const& i_obj; uint32 i_entry; @@ -1211,14 +1216,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; @@ -1238,9 +1244,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) { @@ -1256,46 +1260,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 ((!m_uiEntry || 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 ((!m_uiEntry || 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 ((!m_uiEntry || unit->GetEntry() == m_uiEntry) && m_pObject->IsWithinDist(unit, m_fRange, false)) return true; @@ -1304,63 +1313,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->InSamePhase(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->InSamePhase(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; } @@ -1374,7 +1389,8 @@ namespace Trinity { public: ObjectGUIDCheck(ObjectGuid GUID) : _GUID(GUID) { } - bool operator()(WorldObject* object) + + bool operator()(WorldObject* object) const { return object->GetGUID() == _GUID; } @@ -1387,6 +1403,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; @@ -1417,6 +1434,7 @@ namespace Trinity for (size_t i = 0; i < i_data_cache.size(); ++i) delete i_data_cache[i]; } + void operator()(Player* p); private: |