diff options
author | Machiavelli <machiaveltman@gmail.com> | 2011-08-18 12:14:15 -0700 |
---|---|---|
committer | Machiavelli <machiaveltman@gmail.com> | 2011-08-18 12:14:15 -0700 |
commit | f960fcce6540494bc8dc9eaec4856095e46b8be5 (patch) | |
tree | bde8ac53a5ba5fb20a925695d87a382af2a7fcd7 | |
parent | fb87b41a752bf6d2aa75aa594364f66bca4fccea (diff) | |
parent | 0b64d726c29ad9faaccafdf6fbcb7c5ff27ce587 (diff) |
Merge pull request #2639 from Fredi/clean
Core/AI: Code style and cleanups
31 files changed, 430 insertions, 428 deletions
diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp index d35710aa40f..67e75633b05 100755 --- a/src/server/game/AI/CoreAI/CombatAI.cpp +++ b/src/server/game/AI/CoreAI/CombatAI.cpp @@ -22,7 +22,7 @@ #include "Vehicle.h" #include "ObjectAccessor.h" -int AggressorAI::Permissible(const Creature *creature) +int AggressorAI::Permissible(const Creature* creature) { // have some hostile factions, it will be selected by IsHostileTo check at MoveInLineOfSight if (!creature->isCivilian() && !creature->IsNeutralToAll()) @@ -81,7 +81,7 @@ void CombatAI::JustDied(Unit* killer) me->CastSpell(killer, *i, true); } -void CombatAI::EnterCombat(Unit *who) +void CombatAI::EnterCombat(Unit* who) { for (SpellVct::iterator i = spells.begin(); i != spells.end(); ++i) { @@ -127,7 +127,7 @@ void CasterAI::InitializeAI() m_attackDist = MELEE_RANGE; } -void CasterAI::EnterCombat(Unit *who) +void CasterAI::EnterCombat(Unit* who) { if (spells.empty()) return; @@ -173,7 +173,7 @@ void CasterAI::UpdateAI(const uint32 diff) //ArcherAI ////////////// -ArcherAI::ArcherAI(Creature *c) : CreatureAI(c) +ArcherAI::ArcherAI(Creature* c) : CreatureAI(c) { if (!me->m_spells[0]) sLog->outError("ArcherAI set for creature (entry = %u) with spell1=0. AI will do nothing", me->GetEntry()); @@ -187,7 +187,7 @@ ArcherAI::ArcherAI(Creature *c) : CreatureAI(c) me->m_SightDistance = me->m_CombatDistance; } -void ArcherAI::AttackStart(Unit *who) +void ArcherAI::AttackStart(Unit* who) { if (!who) return; @@ -222,7 +222,7 @@ void ArcherAI::UpdateAI(const uint32 /*diff*/) //TurretAI ////////////// -TurretAI::TurretAI(Creature *c) : CreatureAI(c) +TurretAI::TurretAI(Creature* c) : CreatureAI(c) { if (!me->m_spells[0]) sLog->outError("TurretAI set for creature (entry = %u) with spell1=0. AI will do nothing", me->GetEntry()); @@ -242,7 +242,7 @@ bool TurretAI::CanAIAttack(const Unit* /*who*/) const return true; } -void TurretAI::AttackStart(Unit *who) +void TurretAI::AttackStart(Unit* who) { if (who) me->Attack(who, false); @@ -260,7 +260,7 @@ void TurretAI::UpdateAI(const uint32 /*diff*/) //VehicleAI ////////////// -VehicleAI::VehicleAI(Creature *c) : CreatureAI(c), m_vehicle(c->GetVehicleKit()), m_IsVehicleInUse(false), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME) +VehicleAI::VehicleAI(Creature* c) : CreatureAI(c), m_vehicle(c->GetVehicleKit()), m_IsVehicleInUse(false), m_ConditionsTimer(VEHICLE_CONDITION_CHECK_TIME) { LoadConditions(); m_DoDismiss = false; @@ -318,11 +318,11 @@ void VehicleAI::CheckConditions(const uint32 diff) for (SeatMap::iterator itr = m_vehicle->Seats.begin(); itr != m_vehicle->Seats.end(); ++itr) if (Unit* passenger = ObjectAccessor::GetUnit(*m_vehicle->GetBase(), itr->second.Passenger)) { - if (Player* plr = passenger->ToPlayer()) + if (Player* player = passenger->ToPlayer()) { - if (!sConditionMgr->IsPlayerMeetToConditions(plr, conditions)) + if (!sConditionMgr->IsPlayerMeetToConditions(player, conditions)) { - plr->ExitVehicle(); + player->ExitVehicle(); return;//check other pessanger in next tick } } diff --git a/src/server/game/AI/CoreAI/CombatAI.h b/src/server/game/AI/CoreAI/CombatAI.h index 94f11ba8431..fca964826d3 100755 --- a/src/server/game/AI/CoreAI/CombatAI.h +++ b/src/server/game/AI/CoreAI/CombatAI.h @@ -28,10 +28,10 @@ class Creature; class AggressorAI : public CreatureAI { public: - explicit AggressorAI(Creature *c) : CreatureAI(c) {} + explicit AggressorAI(Creature* c) : CreatureAI(c) {} void UpdateAI(const uint32); - static int Permissible(const Creature *); + static int Permissible(const Creature*); }; typedef std::vector<uint32> SpellVct; @@ -39,14 +39,14 @@ typedef std::vector<uint32> SpellVct; class CombatAI : public CreatureAI { public: - explicit CombatAI(Creature *c) : CreatureAI(c) {} + explicit CombatAI(Creature* c) : CreatureAI(c) {} void InitializeAI(); void Reset(); void EnterCombat(Unit* who); void JustDied(Unit* killer); void UpdateAI(const uint32 diff); - static int Permissible(const Creature *); + static int Permissible(const Creature*); protected: EventMap events; SpellVct spells; @@ -55,7 +55,7 @@ class CombatAI : public CreatureAI class CasterAI : public CombatAI { public: - explicit CasterAI(Creature *c) : CombatAI(c) { m_attackDist = MELEE_RANGE; } + explicit CasterAI(Creature* c) : CombatAI(c) { m_attackDist = MELEE_RANGE; } void InitializeAI(); void AttackStart(Unit* victim) { AttackStartCaster(victim, m_attackDist); } void UpdateAI(const uint32 diff); @@ -67,11 +67,11 @@ class CasterAI : public CombatAI struct ArcherAI : public CreatureAI { public: - explicit ArcherAI(Creature *c); - void AttackStart(Unit *who); + explicit ArcherAI(Creature* c); + void AttackStart(Unit* who); void UpdateAI(const uint32 diff); - static int Permissible(const Creature *); + static int Permissible(const Creature*); protected: float m_minRange; }; @@ -79,12 +79,12 @@ struct ArcherAI : public CreatureAI struct TurretAI : public CreatureAI { public: - explicit TurretAI(Creature *c); - bool CanAIAttack(const Unit *who) const; - void AttackStart(Unit *who); + explicit TurretAI(Creature* c); + bool CanAIAttack(const Unit* who) const; + void AttackStart(Unit* who); void UpdateAI(const uint32 diff); - static int Permissible(const Creature *); + static int Permissible(const Creature*); protected: float m_minRange; }; @@ -94,13 +94,13 @@ struct TurretAI : public CreatureAI struct VehicleAI : public CreatureAI { public: - explicit VehicleAI(Creature *c); + explicit VehicleAI(Creature* c); void UpdateAI(const uint32 diff); - static int Permissible(const Creature *); + static int Permissible(const Creature*); void Reset(); - void MoveInLineOfSight(Unit *) {} - void AttackStart(Unit *) {} + void MoveInLineOfSight(Unit*) {} + void AttackStart(Unit*) {} void OnCharmed(bool apply); private: diff --git a/src/server/game/AI/CoreAI/GameObjectAI.cpp b/src/server/game/AI/CoreAI/GameObjectAI.cpp index 7262530d7ac..28c42a8ccdb 100644 --- a/src/server/game/AI/CoreAI/GameObjectAI.cpp +++ b/src/server/game/AI/CoreAI/GameObjectAI.cpp @@ -26,4 +26,4 @@ int GameObjectAI::Permissible(const GameObject* go) return PERMIT_BASE_NO; } -NullGameObjectAI::NullGameObjectAI(GameObject *g) : GameObjectAI(g) {}
\ No newline at end of file +NullGameObjectAI::NullGameObjectAI(GameObject* g) : GameObjectAI(g) {}
\ No newline at end of file diff --git a/src/server/game/AI/CoreAI/GameObjectAI.h b/src/server/game/AI/CoreAI/GameObjectAI.h index ed3a5b47e76..8d0e0508113 100644 --- a/src/server/game/AI/CoreAI/GameObjectAI.h +++ b/src/server/game/AI/CoreAI/GameObjectAI.h @@ -30,7 +30,7 @@ class GameObjectAI protected: GameObject* const go; public: - explicit GameObjectAI(GameObject *g) : go(g) {} + explicit GameObjectAI(GameObject* g) : go(g) {} virtual ~GameObjectAI() {} virtual void UpdateAI(const uint32 /*diff*/) {} @@ -54,7 +54,7 @@ class GameObjectAI class NullGameObjectAI : public GameObjectAI { public: - explicit NullGameObjectAI(GameObject *g); + explicit NullGameObjectAI(GameObject* g); void UpdateAI(const uint32 /*diff*/) {} diff --git a/src/server/game/AI/CoreAI/GuardAI.cpp b/src/server/game/AI/CoreAI/GuardAI.cpp index 1ebc9e69078..228996e5d2d 100755 --- a/src/server/game/AI/CoreAI/GuardAI.cpp +++ b/src/server/game/AI/CoreAI/GuardAI.cpp @@ -40,8 +40,8 @@ bool GuardAI::CanSeeAlways(WorldObject const* obj) if (!obj->isType(TYPEMASK_UNIT)) return false; - std::list<HostileReference *> t_list = me->getThreatManager().getThreatList(); - for (std::list<HostileReference *>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) + std::list<HostileReference*> t_list = me->getThreatManager().getThreatList(); + for (std::list<HostileReference*>::const_iterator itr = t_list.begin(); itr!= t_list.end(); ++itr) { if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid())) if (unit == obj) diff --git a/src/server/game/AI/CoreAI/GuardAI.h b/src/server/game/AI/CoreAI/GuardAI.h index 7b9c8d6808c..c0b80ac5174 100755 --- a/src/server/game/AI/CoreAI/GuardAI.h +++ b/src/server/game/AI/CoreAI/GuardAI.h @@ -34,15 +34,15 @@ class GuardAI : public ScriptedAI public: - explicit GuardAI(Creature *c); + explicit GuardAI(Creature* c); - void MoveInLineOfSight(Unit *); + void MoveInLineOfSight(Unit*); void EnterEvadeMode(); - void JustDied(Unit *); + void JustDied(Unit*); bool CanSeeAlways(WorldObject const* obj); void UpdateAI(const uint32); - static int Permissible(const Creature *); + static int Permissible(const Creature*); private: uint64 i_victimGuid; diff --git a/src/server/game/AI/CoreAI/PassiveAI.cpp b/src/server/game/AI/CoreAI/PassiveAI.cpp index 1b449f44fbd..4107179f6f7 100755 --- a/src/server/game/AI/CoreAI/PassiveAI.cpp +++ b/src/server/game/AI/CoreAI/PassiveAI.cpp @@ -20,9 +20,9 @@ #include "Creature.h" #include "TemporarySummon.h" -PassiveAI::PassiveAI(Creature *c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); } -PossessedAI::PossessedAI(Creature *c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); } -NullCreatureAI::NullCreatureAI(Creature *c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); } +PassiveAI::PassiveAI(Creature* c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); } +PossessedAI::PossessedAI(Creature* c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); } +NullCreatureAI::NullCreatureAI(Creature* c) : CreatureAI(c) { me->SetReactState(REACT_PASSIVE); } void PassiveAI::UpdateAI(const uint32) { @@ -59,7 +59,7 @@ void PossessedAI::KilledUnit(Unit* victim) victim->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); } -void CritterAI::DamageTaken(Unit* /*done_by*/, uint32 &) +void CritterAI::DamageTaken(Unit* /*done_by*/, uint32&) { if (!me->HasUnitState(UNIT_STAT_FLEEING)) me->SetControlled(true, UNIT_STAT_FLEEING); @@ -72,7 +72,7 @@ void CritterAI::EnterEvadeMode() CreatureAI::EnterEvadeMode(); } -void TriggerAI::IsSummonedBy(Unit *summoner) +void TriggerAI::IsSummonedBy(Unit* summoner) { if (me->m_spells[0]) me->CastSpell(me, me->m_spells[0], false, 0, 0, summoner->GetGUID()); diff --git a/src/server/game/AI/CoreAI/PassiveAI.h b/src/server/game/AI/CoreAI/PassiveAI.h index be78918c608..e23fb41d608 100755 --- a/src/server/game/AI/CoreAI/PassiveAI.h +++ b/src/server/game/AI/CoreAI/PassiveAI.h @@ -25,21 +25,21 @@ class PassiveAI : public CreatureAI { public: - explicit PassiveAI(Creature *c); + explicit PassiveAI(Creature* c); - void MoveInLineOfSight(Unit *) {} - void AttackStart(Unit *) {} + void MoveInLineOfSight(Unit*) {} + void AttackStart(Unit*) {} void UpdateAI(const uint32); - static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; } + static int Permissible(const Creature*) { return PERMIT_BASE_IDLE; } }; class PossessedAI : public CreatureAI { public: - explicit PossessedAI(Creature *c); + explicit PossessedAI(Creature* c); - void MoveInLineOfSight(Unit *) {} + void MoveInLineOfSight(Unit*) {} void AttackStart(Unit* target); void UpdateAI(const uint32); void EnterEvadeMode() {} @@ -47,37 +47,37 @@ class PossessedAI : public CreatureAI void JustDied(Unit*); void KilledUnit(Unit* victim); - static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; } + static int Permissible(const Creature*) { return PERMIT_BASE_IDLE; } }; class NullCreatureAI : public CreatureAI { public: - explicit NullCreatureAI(Creature *c); + explicit NullCreatureAI(Creature* c); - void MoveInLineOfSight(Unit *) {} - void AttackStart(Unit *) {} + void MoveInLineOfSight(Unit*) {} + void AttackStart(Unit*) {} void UpdateAI(const uint32) {} void EnterEvadeMode() {} void OnCharmed(bool /*apply*/) {} - static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; } + static int Permissible(const Creature*) { return PERMIT_BASE_IDLE; } }; class CritterAI : public PassiveAI { public: - explicit CritterAI(Creature *c) : PassiveAI(c) {} + explicit CritterAI(Creature* c) : PassiveAI(c) {} - void DamageTaken(Unit *done_by, uint32 & /*damage*/); + void DamageTaken(Unit* done_by, uint32& /*damage*/); void EnterEvadeMode(); }; class TriggerAI : public NullCreatureAI { public: - explicit TriggerAI(Creature *c) : NullCreatureAI(c) {} - void IsSummonedBy(Unit *summoner); + explicit TriggerAI(Creature* c) : NullCreatureAI(c) {} + void IsSummonedBy(Unit* summoner); }; #endif diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index ff67e3b344b..21cc19d5831 100755 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -30,7 +30,7 @@ #include "Group.h" #include "SpellInfo.h" -int PetAI::Permissible(const Creature *creature) +int PetAI::Permissible(const Creature* creature) { if (creature->isPet()) return PERMIT_BASE_SPECIAL; @@ -38,7 +38,7 @@ int PetAI::Permissible(const Creature *creature) return PERMIT_BASE_NO; } -PetAI::PetAI(Creature *c) : CreatureAI(c), i_tracker(TIME_INTERVAL_LOOK) +PetAI::PetAI(Creature* c) : CreatureAI(c), i_tracker(TIME_INTERVAL_LOOK) { m_AllySet.clear(); UpdateAllies(); @@ -107,7 +107,7 @@ void PetAI::UpdateAI(const uint32 diff) } else if (owner && me->GetCharmInfo()) //no victim { - Unit *nextTarget = SelectNextTarget(); + Unit* nextTarget = SelectNextTarget(); if (me->HasReactState(REACT_PASSIVE)) _stopAttack(); @@ -134,7 +134,7 @@ void PetAI::UpdateAI(const uint32 diff) if (!spellID) continue; - SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spellID); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellID); if (!spellInfo) continue; @@ -239,30 +239,30 @@ void PetAI::UpdateAI(const uint32 diff) void PetAI::UpdateAllies() { Unit* owner = me->GetCharmerOrOwner(); - Group *pGroup = NULL; + Group* group = NULL; m_updateAlliesTimer = 10*IN_MILLISECONDS; //update friendly targets every 10 seconds, lesser checks increase performance if (!owner) return; else if (owner->GetTypeId() == TYPEID_PLAYER) - pGroup = owner->ToPlayer()->GetGroup(); + group = owner->ToPlayer()->GetGroup(); //only pet and owner/not in group->ok - if (m_AllySet.size() == 2 && !pGroup) + if (m_AllySet.size() == 2 && !group) return; //owner is in group; group members filled in already (no raid -> subgroupcount = whole count) - if (pGroup && !pGroup->isRaidGroup() && m_AllySet.size() == (pGroup->GetMembersCount() + 2)) + if (group && !group->isRaidGroup() && m_AllySet.size() == (group->GetMembersCount() + 2)) return; m_AllySet.clear(); m_AllySet.insert(me->GetGUID()); - if (pGroup) //add group + if (group) //add group { - for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { Player* Target = itr->getSource(); - if (!Target || !pGroup->SameSubGroup((Player*)owner, Target)) + if (!Target || !group->SameSubGroup((Player*)owner, Target)) continue; if (Target->GetGUID() == owner->GetGUID()) @@ -289,7 +289,7 @@ void PetAI::KilledUnit(Unit* victim) me->AttackStop(); me->GetCharmInfo()->SetIsCommandAttack(false); - Unit *nextTarget = SelectNextTarget(); + Unit* nextTarget = SelectNextTarget(); if (nextTarget) AttackStart(nextTarget); @@ -310,7 +310,7 @@ void PetAI::AttackStart(Unit* target) DoAttack(target, true); } -Unit *PetAI::SelectNextTarget() +Unit* PetAI::SelectNextTarget() { // Provides next target selection after current target death diff --git a/src/server/game/AI/CoreAI/PetAI.h b/src/server/game/AI/CoreAI/PetAI.h index 2e0e451ef28..9f0472cfe4d 100755 --- a/src/server/game/AI/CoreAI/PetAI.h +++ b/src/server/game/AI/CoreAI/PetAI.h @@ -29,20 +29,20 @@ class PetAI : public CreatureAI { public: - explicit PetAI(Creature *c); + explicit PetAI(Creature* c); void EnterEvadeMode(); void JustDied(Unit* /*who*/) { _stopAttack(); } void UpdateAI(const uint32); - static int Permissible(const Creature *); + static int Permissible(const Creature*); void KilledUnit(Unit* /*victim*/); void AttackStart(Unit* target); void MovementInform(uint32 moveType, uint32 data); private: - bool _isVisible(Unit *) const; + bool _isVisible(Unit*) const; bool _needToStop(void); void _stopAttack(void); @@ -54,7 +54,7 @@ class PetAI : public CreatureAI std::set<uint64> m_AllySet; uint32 m_updateAlliesTimer; - Unit *SelectNextTarget(); + Unit* SelectNextTarget(); void HandleReturnMovement(); void DoAttack(Unit* target, bool chase); bool _CanAttack(Unit* target); diff --git a/src/server/game/AI/CoreAI/ReactorAI.cpp b/src/server/game/AI/CoreAI/ReactorAI.cpp index e2d1c8f601c..df914fbf500 100755 --- a/src/server/game/AI/CoreAI/ReactorAI.cpp +++ b/src/server/game/AI/CoreAI/ReactorAI.cpp @@ -26,7 +26,7 @@ #define REACTOR_VISIBLE_RANGE (26.46f) int -ReactorAI::Permissible(const Creature *creature) +ReactorAI::Permissible(const Creature* creature) { if (creature->isCivilian() || creature->IsNeutralToAll()) return PERMIT_BASE_REACTIVE; @@ -35,7 +35,7 @@ ReactorAI::Permissible(const Creature *creature) } void -ReactorAI::MoveInLineOfSight(Unit *) +ReactorAI::MoveInLineOfSight(Unit*) { } diff --git a/src/server/game/AI/CoreAI/ReactorAI.h b/src/server/game/AI/CoreAI/ReactorAI.h index 5328634c231..e66b382ef68 100755 --- a/src/server/game/AI/CoreAI/ReactorAI.h +++ b/src/server/game/AI/CoreAI/ReactorAI.h @@ -27,12 +27,12 @@ class ReactorAI : public CreatureAI { public: - explicit ReactorAI(Creature *c) : CreatureAI(c) {} + explicit ReactorAI(Creature* c) : CreatureAI(c) {} - void MoveInLineOfSight(Unit *); + void MoveInLineOfSight(Unit*); void UpdateAI(const uint32); - static int Permissible(const Creature *); + static int Permissible(const Creature*); }; #endif diff --git a/src/server/game/AI/CoreAI/TotemAI.cpp b/src/server/game/AI/CoreAI/TotemAI.cpp index f1106f2dc28..96da4c4f4e2 100755 --- a/src/server/game/AI/CoreAI/TotemAI.cpp +++ b/src/server/game/AI/CoreAI/TotemAI.cpp @@ -28,7 +28,7 @@ #include "CellImpl.h" int -TotemAI::Permissible(const Creature *creature) +TotemAI::Permissible(const Creature* creature) { if (creature->isTotem()) return PERMIT_BASE_PROACTIVE; @@ -36,13 +36,13 @@ TotemAI::Permissible(const Creature *creature) return PERMIT_BASE_NO; } -TotemAI::TotemAI(Creature *c) : CreatureAI(c), i_victimGuid(0) +TotemAI::TotemAI(Creature* c) : CreatureAI(c), i_victimGuid(0) { ASSERT(c->isTotem()); } void -TotemAI::MoveInLineOfSight(Unit *) +TotemAI::MoveInLineOfSight(Unit*) { } @@ -61,7 +61,7 @@ TotemAI::UpdateAI(const uint32 /*diff*/) return; // Search spell - SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(me->ToTotem()->GetSpell()); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(me->ToTotem()->GetSpell()); if (!spellInfo) return; @@ -99,7 +99,7 @@ TotemAI::UpdateAI(const uint32 /*diff*/) } void -TotemAI::AttackStart(Unit *) +TotemAI::AttackStart(Unit*) { // Sentry totem sends ping on attack if (me->GetEntry() == SENTRY_TOTEM_ENTRY && me->GetOwner()->GetTypeId() == TYPEID_PLAYER) diff --git a/src/server/game/AI/CoreAI/TotemAI.h b/src/server/game/AI/CoreAI/TotemAI.h index f99e345450d..4791c3af92a 100755 --- a/src/server/game/AI/CoreAI/TotemAI.h +++ b/src/server/game/AI/CoreAI/TotemAI.h @@ -29,14 +29,14 @@ class TotemAI : public CreatureAI { public: - explicit TotemAI(Creature *c); + explicit TotemAI(Creature* c); - void MoveInLineOfSight(Unit *); - void AttackStart(Unit *); + void MoveInLineOfSight(Unit*); + void AttackStart(Unit*); void EnterEvadeMode(); void UpdateAI(const uint32); - static int Permissible(const Creature *); + static int Permissible(const Creature*); private: uint64 i_victimGuid; diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index 92b81e7967b..91de52db9f8 100755 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -91,7 +91,7 @@ Unit* UnitAI::SelectTarget(SelectAggroTarget targetType, uint32 position, float return SelectTarget(targetType, position, DefaultTargetSelector(me, dist, playerOnly, aura)); } -void UnitAI::SelectTargetList(std::list<Unit*> &targetList, uint32 num, SelectAggroTarget targetType, float dist, bool playerOnly, int32 aura) +void UnitAI::SelectTargetList(std::list<Unit*>& targetList, uint32 num, SelectAggroTarget targetType, float dist, bool playerOnly, int32 aura) { SelectTargetList(targetList, DefaultTargetSelector(me, dist, playerOnly, aura), num, targetType); } @@ -109,9 +109,9 @@ void UnitAI::DoAddAuraToAllHostilePlayers(uint32 spellid) std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); for (std::list<HostileReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { - if (Unit *pTemp = Unit::GetUnit(*me, (*itr)->getUnitGuid())) - if (pTemp->GetTypeId() == TYPEID_PLAYER) - me->AddAura(spellid, pTemp); + if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid())) + if (unit->GetTypeId() == TYPEID_PLAYER) + me->AddAura(spellid, unit); } }else return; @@ -124,9 +124,9 @@ void UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered) std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); for (std::list<HostileReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { - if (Unit *pTemp = Unit::GetUnit(*me, (*itr)->getUnitGuid())) - if (pTemp->GetTypeId() == TYPEID_PLAYER) - me->CastSpell(pTemp, spellid, triggered); + if (Unit* unit = Unit::GetUnit(*me, (*itr)->getUnitGuid())) + if (unit->GetTypeId() == TYPEID_PLAYER) + me->CastSpell(unit, spellid, triggered); } }else return; @@ -143,7 +143,7 @@ void UnitAI::DoCast(uint32 spellId) case AITARGET_VICTIM: target = me->getVictim(); break; case AITARGET_ENEMY: { - const SpellInfo * spellInfo = sSpellMgr->GetSpellInfo(spellId); + const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId); bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS; //float range = GetSpellMaxRange(spellInfo, false); target = SelectTarget(SELECT_TARGET_RANDOM, 0, spellInfo->GetMaxRange(false), playerOnly); @@ -153,7 +153,7 @@ void UnitAI::DoCast(uint32 spellId) case AITARGET_BUFF: target = me; break; case AITARGET_DEBUFF: { - const SpellInfo * spellInfo = sSpellMgr->GetSpellInfo(spellId); + const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId); bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS; float range = spellInfo->GetMaxRange(false); @@ -178,8 +178,8 @@ void UnitAI::FillAISpellInfo() { AISpellInfo = new AISpellInfoType[sSpellMgr->GetSpellInfoStoreSize()]; - AISpellInfoType *AIInfo = AISpellInfo; - const SpellInfo * spellInfo; + AISpellInfoType* AIInfo = AISpellInfo; + const SpellInfo* spellInfo; for (uint32 i = 0; i < sSpellMgr->GetSpellInfoStoreSize(); ++i, ++AIInfo) { @@ -230,7 +230,7 @@ void PlayerAI::OnCharmed(bool apply) { me->IsAIEnabled = apply; } void SimpleCharmedAI::UpdateAI(const uint32 /*diff*/) { - Creature *charmer = me->GetCharmer()->ToCreature(); + Creature* charmer = me->GetCharmer()->ToCreature(); //kill self if charm aura has infinite duration if (charmer->IsInEvadeMode()) diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index f17c74fe7cf..ec00b53b5ca 100755 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -60,7 +60,7 @@ struct DefaultTargetSelector : public std::unary_function<Unit* , bool> // dist: if 0: ignored, if > 0: maximum distance to the reference unit, if < 0: minimum distance to the reference unit // playerOnly: self explaining // aura: if 0: ignored, if > 0: the target shall have the aura, if < 0, the target shall NOT have the aura - DefaultTargetSelector(Unit const* pUnit, float dist, bool playerOnly, int32 aura) : me(pUnit), m_dist(dist), m_playerOnly(playerOnly), m_aura(aura) {} + DefaultTargetSelector(Unit const* unit, float dist, bool playerOnly, int32 aura) : me(unit), m_dist(dist), m_playerOnly(playerOnly), m_aura(aura) {} bool operator()(Unit const* target) const { @@ -128,7 +128,7 @@ class UnitAI // predicate shall extend std::unary_function<Unit* , bool> template <class PREDICATE> Unit* SelectTarget(SelectAggroTarget targetType, uint32 position, PREDICATE const& predicate) { - const std::list<HostileReference* > &threatlist = me->getThreatManager().getThreatList(); + const std::list<HostileReference*>& threatlist = me->getThreatManager().getThreatList(); if (position >= threatlist.size()) return NULL; @@ -172,11 +172,11 @@ class UnitAI return NULL; } - void SelectTargetList(std::list<Unit*> &targetList, uint32 num, SelectAggroTarget targetType, float dist = 0.0f, bool playerOnly = false, int32 aura = 0); + void SelectTargetList(std::list<Unit*>& targetList, uint32 num, SelectAggroTarget targetType, float dist = 0.0f, bool playerOnly = false, int32 aura = 0); // Select the targets satifying the predicate. // predicate shall extend std::unary_function<Unit* , bool> - template <class PREDICATE> void SelectTargetList(std::list<Unit*> &targetList, PREDICATE const& predicate, uint32 maxTargets, SelectAggroTarget targetType) + template <class PREDICATE> void SelectTargetList(std::list<Unit*>& targetList, PREDICATE const& predicate, uint32 maxTargets, SelectAggroTarget targetType) { std::list<HostileReference*> const& threatlist = me->getThreatManager().getThreatList(); if (threatlist.empty()) @@ -247,7 +247,7 @@ class PlayerAI : public UnitAI protected: Player* const me; public: - explicit PlayerAI(Player* p) : UnitAI((Unit*)p), me(p) {} + explicit PlayerAI(Player* player) : UnitAI((Unit*)player), me(player) {} void OnCharmed(bool apply); }; diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index ee822d9df40..b72556dbab1 100755 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -34,8 +34,8 @@ void CreatureAI::OnCharmed(bool /*apply*/) me->IsAIEnabled = false; } -AISpellInfoType * UnitAI::AISpellInfo; - AISpellInfoType * GetAISpellInfo(uint32 i) { return &CreatureAI::AISpellInfo[i]; } +AISpellInfoType* UnitAI::AISpellInfo; +AISpellInfoType* GetAISpellInfo(uint32 i) { return &CreatureAI::AISpellInfo[i]; } void CreatureAI::Talk(uint8 id, uint64 WhisperGuid) { @@ -50,7 +50,7 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/) if (!creature->CanHaveThreatList()) return; - Map *map = creature->GetMap(); + Map* map = creature->GetMap(); if (!map->IsDungeon()) //use IsDungeon instead of Instanceable, in case battlegrounds will be instantiated { sLog->outError("DoZoneInCombat call for map that isn't an instance (creature entry = %d)", creature->GetTypeId() == TYPEID_UNIT ? creature->ToCreature()->GetEntry() : 0); @@ -63,7 +63,7 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/) creature->AI()->AttackStart(target); else if (creature->isSummon()) { - if (Unit *summoner = creature->ToTempSummon()->GetSummoner()) + if (Unit* summoner = creature->ToTempSummon()->GetSummoner()) { Unit* target = summoner->getAttackerForHelper(); if (!target && summoner->CanHaveThreatList() && !summoner->getThreatManager().isThreatListEmpty()) @@ -80,23 +80,23 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/) return; } - Map::PlayerList const &PlList = map->GetPlayers(); + Map::PlayerList const& playerList = map->GetPlayers(); - if (PlList.isEmpty()) + if (playerList.isEmpty()) return; - for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i) + for (Map::PlayerList::const_iterator itr = playerList.begin(); itr != playerList.end(); ++itr) { - if (Player* pPlayer = i->getSource()) + if (Player* player = itr->getSource()) { - if (pPlayer->isGameMaster()) + if (player->isGameMaster()) continue; - if (pPlayer->isAlive()) + if (player->isAlive()) { - creature->SetInCombatWith(pPlayer); - pPlayer->SetInCombatWith(creature); - creature->AddThreat(pPlayer, 0.0f); + creature->SetInCombatWith(player); + player->SetInCombatWith(creature); + creature->AddThreat(player, 0.0f); } /* Causes certain things to never leave the threat list (Priest Lightwell, etc): @@ -112,7 +112,7 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= NULL*/) // scripts does not take care about MoveInLineOfSight loops // MoveInLineOfSight can be called inside another MoveInLineOfSight and cause stack overflow -void CreatureAI::MoveInLineOfSight_Safe(Unit *who) +void CreatureAI::MoveInLineOfSight_Safe(Unit* who) { if (m_MoveInLineOfSight_locked == true) return; @@ -121,7 +121,7 @@ void CreatureAI::MoveInLineOfSight_Safe(Unit *who) m_MoveInLineOfSight_locked = false; } -void CreatureAI::MoveInLineOfSight(Unit *who) +void CreatureAI::MoveInLineOfSight(Unit* who) { if (me->getVictim()) return; @@ -146,7 +146,7 @@ void CreatureAI::EnterEvadeMode() if (!me->GetVehicle()) // otherwise me will be in evade mode forever { - if (Unit *owner = me->GetCharmerOrOwner()) + if (Unit* owner = me->GetCharmerOrOwner()) { me->GetMotionMaster()->Clear(false); me->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, me->GetFollowAngle(), MOTION_SLOT_ACTIVE); diff --git a/src/server/game/AI/CreatureAIFactory.h b/src/server/game/AI/CreatureAIFactory.h index ba0de3a4ddd..4cedb3d9545 100755 --- a/src/server/game/AI/CreatureAIFactory.h +++ b/src/server/game/AI/CreatureAIFactory.h @@ -25,24 +25,24 @@ struct SelectableAI : public FactoryHolder<CreatureAI>, public Permissible<Creature> { - SelectableAI(const char *id) : FactoryHolder<CreatureAI>(id) {} + SelectableAI(const char* id) : FactoryHolder<CreatureAI>(id) {} }; template<class REAL_AI> struct CreatureAIFactory : public SelectableAI { - CreatureAIFactory(const char *name) : SelectableAI(name) {} + CreatureAIFactory(const char* name) : SelectableAI(name) {} - CreatureAI* Create(void *) const; + CreatureAI* Create(void*) const; - int Permit(const Creature *c) const { return REAL_AI::Permissible(c); } + int Permit(const Creature* c) const { return REAL_AI::Permissible(c); } }; template<class REAL_AI> inline CreatureAI* -CreatureAIFactory<REAL_AI>::Create(void *data) const +CreatureAIFactory<REAL_AI>::Create(void* data) const { - Creature* creature = reinterpret_cast<Creature *>(data); + Creature* creature = reinterpret_cast<Creature*>(data); return (new REAL_AI(creature)); } @@ -53,24 +53,24 @@ typedef FactoryHolder<CreatureAI>::FactoryHolderRepository CreatureAIRepository; //GO struct SelectableGameObjectAI : public FactoryHolder<GameObjectAI>, public Permissible<GameObject> { - SelectableGameObjectAI(const char *id) : FactoryHolder<GameObjectAI>(id) {} + SelectableGameObjectAI(const char* id) : FactoryHolder<GameObjectAI>(id) {} }; template<class REAL_GO_AI> struct GameObjectAIFactory : public SelectableGameObjectAI { - GameObjectAIFactory(const char *name) : SelectableGameObjectAI(name) {} + GameObjectAIFactory(const char* name) : SelectableGameObjectAI(name) {} - GameObjectAI* Create(void *) const; + GameObjectAI* Create(void*) const; - int Permit(const GameObject *g) const { return REAL_GO_AI::Permissible(g); } + int Permit(const GameObject* g) const { return REAL_GO_AI::Permissible(g); } }; template<class REAL_GO_AI> inline GameObjectAI* -GameObjectAIFactory<REAL_GO_AI>::Create(void *data) const +GameObjectAIFactory<REAL_GO_AI>::Create(void* data) const { - GameObject* go = reinterpret_cast<GameObject *>(data); + GameObject* go = reinterpret_cast<GameObject*>(data); return (new REAL_GO_AI(go)); } diff --git a/src/server/game/AI/CreatureAIImpl.h b/src/server/game/AI/CreatureAIImpl.h index 5bb0580ae7c..7e57082827c 100755 --- a/src/server/game/AI/CreatureAIImpl.h +++ b/src/server/game/AI/CreatureAIImpl.h @@ -524,7 +524,7 @@ struct AISpellInfoType float maxRange; }; - AISpellInfoType * GetAISpellInfo(uint32 i); +AISpellInfoType* GetAISpellInfo(uint32 i); inline void CreatureAI::SetGazeOn(Unit* target) { @@ -615,7 +615,7 @@ inline void UnitAI::DoCastAOE(uint32 spellId, bool triggered) me->CastSpell((Unit*)NULL, spellId, triggered); } -inline Creature* CreatureAI::DoSummon(uint32 entry, const Position &pos, uint32 despawnTime, TempSummonType summonType) +inline Creature* CreatureAI::DoSummon(uint32 entry, const Position& pos, uint32 despawnTime, TempSummonType summonType) { return me->SummonCreature(entry, pos, summonType, despawnTime); } diff --git a/src/server/game/AI/CreatureAISelector.cpp b/src/server/game/AI/CreatureAISelector.cpp index f7e760c7b79..5b7ee7750bc 100755 --- a/src/server/game/AI/CreatureAISelector.cpp +++ b/src/server/game/AI/CreatureAISelector.cpp @@ -28,9 +28,9 @@ namespace FactorySelector { - CreatureAI* selectAI(Creature *creature) + CreatureAI* selectAI(Creature* creature) { - const CreatureAICreator *ai_factory = NULL; + const CreatureAICreator* ai_factory = NULL; CreatureAIRegistry& ai_registry(*CreatureAIRepository::instance()); if (creature->isPet()) @@ -77,11 +77,11 @@ namespace FactorySelector { int best_val = -1; typedef CreatureAIRegistry::RegistryMapType RMT; - RMT const &l = ai_registry.GetRegisteredItems(); + RMT const& l = ai_registry.GetRegisteredItems(); for (RMT::const_iterator iter = l.begin(); iter != l.end(); ++iter) { - const CreatureAICreator *factory = iter->second; - const SelectableAI *p = dynamic_cast<const SelectableAI *>(factory); + const CreatureAICreator* factory = iter->second; + const SelectableAI* p = dynamic_cast<const SelectableAI*>(factory); ASSERT(p != NULL); int val = p->Permit(creature); if (val > best_val) @@ -99,11 +99,11 @@ namespace FactorySelector return (ai_factory == NULL ? new NullCreatureAI(creature) : ai_factory->Create(creature)); } - MovementGenerator* selectMovementGenerator(Creature *creature) + MovementGenerator* selectMovementGenerator(Creature* creature) { MovementGeneratorRegistry& mv_registry(*MovementGeneratorRepository::instance()); ASSERT(creature->GetCreatureInfo() != NULL); - const MovementGeneratorCreator *mv_factory = mv_registry.GetRegistryItem(creature->GetDefaultMovementType()); + const MovementGeneratorCreator* mv_factory = mv_registry.GetRegistryItem(creature->GetDefaultMovementType()); /* if (mv_factory == NULL) { @@ -128,9 +128,9 @@ namespace FactorySelector } - GameObjectAI* SelectGameObjectAI(GameObject *go) + GameObjectAI* SelectGameObjectAI(GameObject* go) { - const GameObjectAICreator *ai_factory = NULL; + const GameObjectAICreator* ai_factory = NULL; GameObjectAIRegistry& ai_registry(*GameObjectAIRepository::instance()); ai_factory = ai_registry.GetRegistryItem(go->GetAIName()); diff --git a/src/server/game/AI/CreatureAISelector.h b/src/server/game/AI/CreatureAISelector.h index 4b45a73c64d..64bf96c01af 100755 --- a/src/server/game/AI/CreatureAISelector.h +++ b/src/server/game/AI/CreatureAISelector.h @@ -27,9 +27,9 @@ class GameObject; namespace FactorySelector { - CreatureAI* selectAI(Creature *); - MovementGenerator* selectMovementGenerator(Creature *); - GameObjectAI* SelectGameObjectAI(GameObject *); + CreatureAI* selectAI(Creature*); + MovementGenerator* selectMovementGenerator(Creature*); + GameObjectAI* SelectGameObjectAI(GameObject*); } #endif diff --git a/src/server/game/AI/EventAI/CreatureEventAI.cpp b/src/server/game/AI/EventAI/CreatureEventAI.cpp index a1a3cc6c48a..d09939c3243 100755 --- a/src/server/game/AI/EventAI/CreatureEventAI.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAI.cpp @@ -48,14 +48,14 @@ bool CreatureEventAIHolder::UpdateRepeatTimer(Creature* creature, uint32 repeatM return true; } -int CreatureEventAI::Permissible(const Creature *creature) +int CreatureEventAI::Permissible(const Creature* creature) { if (creature->GetAIName() == "EventAI") return PERMIT_BASE_SPECIAL; return PERMIT_BASE_NO; } -CreatureEventAI::CreatureEventAI(Creature *c) : CreatureAI(c) +CreatureEventAI::CreatureEventAI(Creature* c) : CreatureAI(c) { // Need make copy for filter unneeded steps and safe in case table reload CreatureEventAI_Event_Map::const_iterator CreatureEvents = sEventAIMgr->GetCreatureEventAIMap().find(me->GetEntry()); @@ -106,16 +106,16 @@ CreatureEventAI::CreatureEventAI(Creature *c) : CreatureAI(c) } } -bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker /*=NULL*/) +bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& holder, Unit* actionInvoker /*=NULL*/) { - if (!pHolder.Enabled || pHolder.Time) + if (!holder.Enabled || holder.Time) return false; //Check the inverse phase mask (event doesn't trigger if current phase bit is set in mask) - if (pHolder.Event.event_inverse_phase_mask & (1 << m_Phase)) + if (holder.Event.event_inverse_phase_mask & (1 << m_Phase)) return false; - CreatureEventAI_Event const& event = pHolder.Event; + CreatureEventAI_Event const& event = holder.Event; //Check event conditions based on the event type, also reset events switch (event.event_type) @@ -125,14 +125,14 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.timer.repeatMin, event.timer.repeatMax); + holder.UpdateRepeatTimer(me, event.timer.repeatMin, event.timer.repeatMax); break; case EVENT_T_TIMER_OOC: if (me->isInCombat()) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.timer.repeatMin, event.timer.repeatMax); + holder.UpdateRepeatTimer(me, event.timer.repeatMin, event.timer.repeatMax); break; case EVENT_T_HP: { @@ -145,7 +145,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); + holder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); break; } case EVENT_T_MANA: @@ -159,14 +159,14 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); + holder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); break; } case EVENT_T_AGGRO: break; case EVENT_T_KILL: //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.kill.repeatMin, event.kill.repeatMax); + holder.UpdateRepeatTimer(me, event.kill.repeatMin, event.kill.repeatMax); break; case EVENT_T_DEATH: case EVENT_T_EVADE: @@ -175,15 +175,15 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction //Spell hit is special case, param1 and param2 handled within CreatureEventAI::SpellHit //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.spell_hit.repeatMin, event.spell_hit.repeatMax); + holder.UpdateRepeatTimer(me, event.spell_hit.repeatMin, event.spell_hit.repeatMax); break; case EVENT_T_RANGE: //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.range.repeatMin, event.range.repeatMax); + holder.UpdateRepeatTimer(me, event.range.repeatMin, event.range.repeatMax); break; case EVENT_T_OOC_LOS: //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.ooc_los.repeatMin, event.ooc_los.repeatMax); + holder.UpdateRepeatTimer(me, event.ooc_los.repeatMin, event.ooc_los.repeatMax); break; case EVENT_T_RESET: case EVENT_T_SPAWNED: @@ -199,7 +199,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); + holder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); break; } case EVENT_T_TARGET_CASTING: @@ -207,21 +207,21 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.target_casting.repeatMin, event.target_casting.repeatMax); + holder.UpdateRepeatTimer(me, event.target_casting.repeatMin, event.target_casting.repeatMax); break; case EVENT_T_FRIENDLY_HP: { if (!me->isInCombat()) return false; - Unit* pUnit = DoSelectLowestHpFriendly((float)event.friendly_hp.radius, event.friendly_hp.hpDeficit); - if (!pUnit) + Unit* unit = DoSelectLowestHpFriendly((float)event.friendly_hp.radius, event.friendly_hp.hpDeficit); + if (!unit) return false; - pActionInvoker = pUnit; + actionInvoker = unit; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.friendly_hp.repeatMin, event.friendly_hp.repeatMax); + holder.UpdateRepeatTimer(me, event.friendly_hp.repeatMin, event.friendly_hp.repeatMax); break; } case EVENT_T_FRIENDLY_IS_CC: @@ -237,10 +237,10 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //We don't really care about the whole list, just return first available - pActionInvoker = *(pList.begin()); + actionInvoker = *(pList.begin()); //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.friendly_is_cc.repeatMin, event.friendly_is_cc.repeatMax); + holder.UpdateRepeatTimer(me, event.friendly_is_cc.repeatMin, event.friendly_is_cc.repeatMax); break; } case EVENT_T_FRIENDLY_MISSING_BUFF: @@ -253,24 +253,24 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //We don't really care about the whole list, just return first available - pActionInvoker = *(pList.begin()); + actionInvoker = *(pList.begin()); //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.friendly_buff.repeatMin, event.friendly_buff.repeatMax); + holder.UpdateRepeatTimer(me, event.friendly_buff.repeatMin, event.friendly_buff.repeatMax); break; } case EVENT_T_SUMMONED_UNIT: { //Prevent event from occuring on no unit or non creatures - if (!pActionInvoker || pActionInvoker->GetTypeId() != TYPEID_UNIT) + if (!actionInvoker || actionInvoker->GetTypeId() != TYPEID_UNIT) return false; //Creature id doesn't match up - if (pActionInvoker->ToCreature()->GetEntry() != event.summon_unit.creatureId) + if (actionInvoker->ToCreature()->GetEntry() != event.summon_unit.creatureId) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.summon_unit.repeatMin, event.summon_unit.repeatMax); + holder.UpdateRepeatTimer(me, event.summon_unit.repeatMin, event.summon_unit.repeatMax); break; } case EVENT_T_TARGET_MANA: @@ -284,7 +284,7 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); + holder.UpdateRepeatTimer(me, event.percent_range.repeatMin, event.percent_range.repeatMax); break; } case EVENT_T_REACHED_HOME: @@ -299,49 +299,49 @@ bool CreatureEventAI::ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pAction return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.buffed.repeatMin, event.buffed.repeatMax); + holder.UpdateRepeatTimer(me, event.buffed.repeatMin, event.buffed.repeatMax); break; } case EVENT_T_TARGET_BUFFED: { //Prevent event from occuring on no unit - if (!pActionInvoker) + if (!actionInvoker) return false; //Note: checked only aura for effect 0, if need check aura for effect 1/2 then // possible way: pack in event.buffed.amount 2 uint16 (ammount+effectIdx) - Aura const* aura = pActionInvoker->GetAura(event.buffed.spellId); + Aura const* aura = actionInvoker->GetAura(event.buffed.spellId); if (!aura || aura->GetStackAmount() < event.buffed.amount) return false; //Repeat Timers - pHolder.UpdateRepeatTimer(me, event.buffed.repeatMin, event.buffed.repeatMax); + holder.UpdateRepeatTimer(me, event.buffed.repeatMin, event.buffed.repeatMax); break; } default: - sLog->outErrorDb("CreatureEventAI: Creature %u using Event %u has invalid Event Type(%u), missing from ProcessEvent() Switch.", me->GetEntry(), pHolder.Event.event_id, pHolder.Event.event_type); + sLog->outErrorDb("CreatureEventAI: Creature %u using Event %u has invalid Event Type(%u), missing from ProcessEvent() Switch.", me->GetEntry(), holder.Event.event_id, holder.Event.event_type); break; } //Disable non-repeatable events - if (!(pHolder.Event.event_flags & EFLAG_REPEATABLE)) - pHolder.Enabled = false; + if (!(holder.Event.event_flags & EFLAG_REPEATABLE)) + holder.Enabled = false; //Store random here so that all random actions match up uint32 rnd = rand(); //Return if chance for event is not met - if (pHolder.Event.event_chance <= rnd % 100) + if (holder.Event.event_chance <= rnd % 100) return false; //Process actions for (uint8 j = 0; j < MAX_ACTIONS; ++j) - ProcessAction(pHolder.Event.action[j], rnd, pHolder.Event.event_id, pActionInvoker); + ProcessAction(holder.Event.action[j], rnd, holder.Event.event_id, actionInvoker); return true; } -void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 EventId, Unit* pActionInvoker) +void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 eventId, Unit* actionInvoker) { switch (action.type) { @@ -361,11 +361,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 { Unit* target = NULL; - if (pActionInvoker) + if (actionInvoker) { - if (pActionInvoker->GetTypeId() == TYPEID_PLAYER) - target = pActionInvoker; - else if (Unit* owner = pActionInvoker->GetOwner()) + if (actionInvoker->GetTypeId() == TYPEID_PLAYER) + target = actionInvoker; + else if (Unit* owner = actionInvoker->GetOwner()) { if (owner->GetTypeId() == TYPEID_PLAYER) target = owner; @@ -442,7 +442,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } case ACTION_T_CAST: { - Unit* target = GetTargetByType(action.cast.target, pActionInvoker); + Unit* target = GetTargetByType(action.cast.target, actionInvoker); Unit* caster = me; if (!target) @@ -496,29 +496,29 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } else - sLog->outErrorDb("CreatureEventAI: event %d creature %d attempt to cast spell that doesn't exist %d", EventId, me->GetEntry(), action.cast.spellId); + sLog->outErrorDb("CreatureEventAI: event %d creature %d attempt to cast spell that doesn't exist %d", eventId, me->GetEntry(), action.cast.spellId); } break; } case ACTION_T_SUMMON: { - Unit* target = GetTargetByType(action.summon.target, pActionInvoker); + Unit* target = GetTargetByType(action.summon.target, actionInvoker); - Creature* pCreature = NULL; + Creature* creature = NULL; if (action.summon.duration) - pCreature = me->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, action.summon.duration); + creature = me->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, action.summon.duration); else - pCreature = me->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); + creature = me->SummonCreature(action.summon.creatureId, 0.0f, 0.0f, 0.0f, 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); - if (!pCreature) - sLog->outErrorDb("CreatureEventAI: failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, EventId, me->GetEntry()); + if (!creature) + sLog->outErrorDb("CreatureEventAI: failed to spawn creature %u. Spawn event %d is on creature %d", action.summon.creatureId, eventId, me->GetEntry()); else if (action.summon.target != TARGET_T_SELF && target) - pCreature->AI()->AttackStart(target); + creature->AI()->AttackStart(target); break; } case ACTION_T_THREAT_SINGLE_PCT: - if (Unit* target = GetTargetByType(action.threat_single_pct.target, pActionInvoker)) + if (Unit* target = GetTargetByType(action.threat_single_pct.target, actionInvoker)) me->getThreatManager().modifyThreatPercent(target, action.threat_single_pct.percent); break; case ACTION_T_THREAT_ALL_PCT: @@ -530,18 +530,18 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; } case ACTION_T_QUEST_EVENT: - if (Unit* target = GetTargetByType(action.quest_event.target, pActionInvoker)) + if (Unit* target = GetTargetByType(action.quest_event.target, actionInvoker)) if (target->GetTypeId() == TYPEID_PLAYER) target->ToPlayer()->AreaExploredOrEventHappens(action.quest_event.questId); break; case ACTION_T_CAST_EVENT: - if (Unit* target = GetTargetByType(action.cast_event.target, pActionInvoker)) + if (Unit* target = GetTargetByType(action.cast_event.target, actionInvoker)) if (target->GetTypeId() == TYPEID_PLAYER) target->ToPlayer()->CastedCreatureOrGO(action.cast_event.creatureId, me->GetGUID(), action.cast_event.spellId); break; case ACTION_T_SET_UNIT_FIELD: { - Unit* target = GetTargetByType(action.set_unit_field.target, pActionInvoker); + Unit* target = GetTargetByType(action.set_unit_field.target, actionInvoker); // not allow modify important for integrity object fields if (action.set_unit_field.field < OBJECT_END || action.set_unit_field.field >= UNIT_END) @@ -553,11 +553,11 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; } case ACTION_T_SET_UNIT_FLAG: - if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker)) + if (Unit* target = GetTargetByType(action.unit_flag.target, actionInvoker)) target->SetFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); break; case ACTION_T_REMOVE_UNIT_FLAG: - if (Unit* target = GetTargetByType(action.unit_flag.target, pActionInvoker)) + if (Unit* target = GetTargetByType(action.unit_flag.target, actionInvoker)) target->RemoveFlag(UNIT_FIELD_FLAGS, action.unit_flag.value); break; case ACTION_T_AUTO_ATTACK: @@ -608,12 +608,12 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 int32 new_phase = int32(m_Phase)+action.set_inc_phase.step; if (new_phase < 0) { - sLog->outErrorDb("CreatureEventAI: Event %d decrease m_Phase under 0. CreatureEntry = %d", EventId, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: Event %d decrease m_Phase under 0. CreatureEntry = %d", eventId, me->GetEntry()); m_Phase = 0; } else if (new_phase >= MAX_PHASE) { - sLog->outErrorDb("CreatureEventAI: Event %d incremented m_Phase above %u. m_Phase mask cannot be used with phases past %u. CreatureEntry = %d", EventId, MAX_PHASE-1, MAX_PHASE-1, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: Event %d incremented m_Phase above %u. m_Phase mask cannot be used with phases past %u. CreatureEntry = %d", eventId, MAX_PHASE-1, MAX_PHASE-1, me->GetEntry()); m_Phase = MAX_PHASE-1; } else @@ -628,9 +628,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 me->DoFleeToGetAssistance(); break; case ACTION_T_QUEST_EVENT_ALL: - if (pActionInvoker && pActionInvoker->GetTypeId() == TYPEID_PLAYER) + if (actionInvoker && actionInvoker->GetTypeId() == TYPEID_PLAYER) { - if (Unit* Temp = Unit::GetUnit(*me, pActionInvoker->GetGUID())) + if (Unit* Temp = Unit::GetUnit(*me, actionInvoker->GetGUID())) if (Temp->GetTypeId() == TYPEID_PLAYER) Temp->ToPlayer()->GroupEventHappens(action.quest_event_all.questId, me); } @@ -645,7 +645,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; } case ACTION_T_REMOVEAURASFROMSPELL: - if (Unit* target = GetTargetByType(action.remove_aura.target, pActionInvoker)) + if (Unit* target = GetTargetByType(action.remove_aura.target, actionInvoker)) target->RemoveAurasDueToSpell(action.remove_aura.spellId); break; case ACTION_T_RANGED_MOVEMENT: @@ -664,80 +664,80 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 if (action.random_phase_range.phaseMin <= action.random_phase_range.phaseMax) m_Phase = urand(action.random_phase_range.phaseMin, action.random_phase_range.phaseMax); else - sLog->outErrorDb("CreatureEventAI: ACTION_T_RANDOM_PHASE_RANGE cannot have Param2 < Param1. Event = %d. CreatureEntry = %d", EventId, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: ACTION_T_RANDOM_PHASE_RANGE cannot have Param2 < Param1. Event = %d. CreatureEntry = %d", eventId, me->GetEntry()); break; case ACTION_T_SUMMON_ID: { - Unit* target = GetTargetByType(action.summon_id.target, pActionInvoker); + Unit* target = GetTargetByType(action.summon_id.target, actionInvoker); CreatureEventAI_Summon_Map::const_iterator i = sEventAIMgr->GetCreatureEventAISummonMap().find(action.summon_id.spawnId); if (i == sEventAIMgr->GetCreatureEventAISummonMap().end()) { - sLog->outErrorDb("CreatureEventAI: failed to spawn creature %u. Summon map index %u does not exist. EventID %d. CreatureID %d", action.summon_id.creatureId, action.summon_id.spawnId, EventId, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: failed to spawn creature %u. Summon map index %u does not exist. EventID %d. CreatureID %d", action.summon_id.creatureId, action.summon_id.spawnId, eventId, me->GetEntry()); return; } - Creature* pCreature = NULL; + Creature* creature = NULL; if ((*i).second.SpawnTimeSecs) - pCreature = me->SummonCreature(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, (*i).second.SpawnTimeSecs); + creature = me->SummonCreature(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, (*i).second.SpawnTimeSecs); else - pCreature = me->SummonCreature(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); + creature = me->SummonCreature(action.summon_id.creatureId, (*i).second.position_x, (*i).second.position_y, (*i).second.position_z, (*i).second.orientation, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 0); - if (!pCreature) - sLog->outErrorDb("CreatureEventAI: failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, EventId, me->GetEntry()); + if (!creature) + sLog->outErrorDb("CreatureEventAI: failed to spawn creature %u. EventId %d.Creature %d", action.summon_id.creatureId, eventId, me->GetEntry()); else if (action.summon_id.target != TARGET_T_SELF && target) - pCreature->AI()->AttackStart(target); + creature->AI()->AttackStart(target); break; } case ACTION_T_KILLED_MONSTER: //first attempt player who tapped creature - if (Player* pPlayer = me->GetLootRecipient()) - pPlayer->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, pPlayer); // pPlayer as param is a hacky solution not to use GUID + if (Player* player = me->GetLootRecipient()) + player->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, player); // player as param is a hacky solution not to use GUID else { - //if not available, use pActionInvoker - if (Unit* pTarget = GetTargetByType(action.killed_monster.target, pActionInvoker)) - if (Player* pPlayer2 = pTarget->GetCharmerOrOwnerPlayerOrPlayerItself()) - pPlayer2->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, pPlayer2); + //if not available, use actionInvoker + if (Unit* target = GetTargetByType(action.killed_monster.target, actionInvoker)) + if (Player* player2 = target->GetCharmerOrOwnerPlayerOrPlayerItself()) + player2->RewardPlayerAndGroupAtEvent(action.killed_monster.creatureId, player2); } break; case ACTION_T_SET_INST_DATA: { - InstanceScript* pInst = (InstanceScript*)me->GetInstanceScript(); - if (!pInst) + InstanceScript* instance = (InstanceScript*)me->GetInstanceScript(); + if (!instance) { - sLog->outErrorDb("CreatureEventAI: Event %d attempt to set instance data without instance script. Creature %d", EventId, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: Event %d attempt to set instance data without instance script. Creature %d", eventId, me->GetEntry()); return; } - pInst->SetData(action.set_inst_data.field, action.set_inst_data.value); + instance->SetData(action.set_inst_data.field, action.set_inst_data.value); break; } case ACTION_T_SET_INST_DATA64: { - Unit* target = GetTargetByType(action.set_inst_data64.target, pActionInvoker); + Unit* target = GetTargetByType(action.set_inst_data64.target, actionInvoker); if (!target) { - sLog->outErrorDb("CreatureEventAI: Event %d attempt to set instance data64 but Target == NULL. Creature %d", EventId, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: Event %d attempt to set instance data64 but Target == NULL. Creature %d", eventId, me->GetEntry()); return; } - InstanceScript* pInst = (InstanceScript*)me->GetInstanceScript(); - if (!pInst) + InstanceScript* instance = (InstanceScript*)me->GetInstanceScript(); + if (!instance) { - sLog->outErrorDb("CreatureEventAI: Event %d attempt to set instance data64 without instance script. Creature %d", EventId, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: Event %d attempt to set instance data64 without instance script. Creature %d", eventId, me->GetEntry()); return; } - pInst->SetData64(action.set_inst_data64.field, target->GetGUID()); + instance->SetData64(action.set_inst_data64.field, target->GetGUID()); break; } case ACTION_T_UPDATE_TEMPLATE: if (me->GetEntry() == action.update_template.creatureId) { - sLog->outErrorDb("CreatureEventAI: Event %d ACTION_T_UPDATE_TEMPLATE call with param1 == current entry. Creature %d", EventId, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: Event %d ACTION_T_UPDATE_TEMPLATE call with param1 == current entry. Creature %d", eventId, me->GetEntry()); return; } @@ -747,7 +747,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 if (me->isDead()) { - sLog->outErrorDb("CreatureEventAI: Event %d ACTION_T_DIE on dead creature. Creature %d", EventId, me->GetEntry()); + sLog->outErrorDb("CreatureEventAI: Event %d ACTION_T_DIE on dead creature. Creature %d", eventId, me->GetEntry()); return; } me->Kill(me); @@ -792,14 +792,14 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 break; case ACTION_T_SUMMON_GO: { - GameObject* pObject = NULL; + GameObject* object = NULL; float x, y, z; me->GetPosition(x, y, z); - pObject = me->SummonGameObject(action.raw.param1, x, y, z, 0, 0, 0, 0, 0, action.raw.param2); - if (!pObject) + object = me->SummonGameObject(action.raw.param1, x, y, z, 0, 0, 0, 0, 0, action.raw.param2); + if (!object) { - sLog->outErrorDb("TSCR: EventAI failed to spawn object %u. Spawn event %d is on creature %d", action.raw.param1, EventId, me->GetEntry()); + sLog->outErrorDb("TSCR: EventAI failed to spawn object %u. Spawn event %d is on creature %d", action.raw.param1, eventId, me->GetEntry()); } break; } @@ -955,19 +955,19 @@ void CreatureEventAI::KilledUnit(Unit* victim) } } -void CreatureEventAI::JustSummoned(Creature* pUnit) +void CreatureEventAI::JustSummoned(Creature* unit) { - if (m_bEmptyList || !pUnit) + if (m_bEmptyList || !unit) return; for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) { if ((*i).Event.event_type == EVENT_T_SUMMONED_UNIT) - ProcessEvent(*i, pUnit); + ProcessEvent(*i, unit); } } -void CreatureEventAI::EnterCombat(Unit *enemy) +void CreatureEventAI::EnterCombat(Unit* enemy) { //Check for on combat start events if (!m_bEmptyList) @@ -999,7 +999,7 @@ void CreatureEventAI::EnterCombat(Unit *enemy) m_EventDiff = 0; } -void CreatureEventAI::AttackStart(Unit *who) +void CreatureEventAI::AttackStart(Unit* who) { if (!who) return; @@ -1047,7 +1047,7 @@ void CreatureEventAI::MoveInLineOfSight(Unit *who) CreatureAI::MoveInLineOfSight(who); } -void CreatureEventAI::SpellHit(Unit* pUnit, const SpellInfo* pSpell) +void CreatureEventAI::SpellHit(Unit* unit, const SpellInfo* spell) { if (m_bEmptyList) @@ -1056,9 +1056,9 @@ void CreatureEventAI::SpellHit(Unit* pUnit, const SpellInfo* pSpell) for (CreatureEventAIList::iterator i = m_CreatureEventAIList.begin(); i != m_CreatureEventAIList.end(); ++i) if ((*i).Event.event_type == EVENT_T_SPELLHIT) //If spell id matches (or no spell id) & if spell school matches (or no spell school) - if (!(*i).Event.spell_hit.spellId || pSpell->Id == (*i).Event.spell_hit.spellId) - if (pSpell->SchoolMask & (*i).Event.spell_hit.schoolMask) - ProcessEvent(*i, pUnit); + if (!(*i).Event.spell_hit.spellId || spell->Id == (*i).Event.spell_hit.spellId) + if (spell->SchoolMask & (*i).Event.spell_hit.schoolMask) + ProcessEvent(*i, unit); } void CreatureEventAI::UpdateAI(const uint32 diff) @@ -1152,9 +1152,9 @@ inline int32 CreatureEventAI::GetRandActionParam(uint32 rnd, int32 param1, int32 return 0; } -inline Unit* CreatureEventAI::GetTargetByType(uint32 Target, Unit* pActionInvoker) +inline Unit* CreatureEventAI::GetTargetByType(uint32 target, Unit* actionInvoker) { - switch (Target) + switch (target) { case TARGET_T_SELF: return me; @@ -1169,23 +1169,23 @@ inline Unit* CreatureEventAI::GetTargetByType(uint32 Target, Unit* pActionInvoke case TARGET_T_HOSTILE_RANDOM_NOT_TOP: return SelectTarget(SELECT_TARGET_RANDOM, 1); case TARGET_T_ACTION_INVOKER: - return pActionInvoker; + return actionInvoker; default: return NULL; }; } -Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) +Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 minHPDiff) { CellPair p(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); Cell cell(p); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); - Unit* pUnit = NULL; + Unit* unit = NULL; - Trinity::MostHPMissingInRange u_check(me, range, MinHPDiff); - Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(me, pUnit, u_check); + Trinity::MostHPMissingInRange u_check(me, range, minHPDiff); + Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(me, unit, u_check); /* typedef TYPELIST_4(GameObject, Creature*except pets*, DynamicObject, Corpse*Bones*) AllGridObjectTypes; @@ -1194,7 +1194,7 @@ Unit* CreatureEventAI::DoSelectLowestHpFriendly(float range, uint32 MinHPDiff) TypeContainerVisitor<Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange>, GridTypeMapContainer > grid_unit_searcher(searcher); cell.Visit(p, grid_unit_searcher, *me->GetMap(), *me, range); - return pUnit; + return unit; } void CreatureEventAI::DoFindFriendlyCC(std::list<Creature*>& _list, float range) @@ -1230,9 +1230,9 @@ void CreatureEventAI::DoFindFriendlyMissingBuff(std::list<Creature*>& _list, flo // ********************************* // *** Functions used globally *** -void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target) +void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* source, Unit* target) { - if (!pSource) + if (!source) { sLog->outErrorDb("CreatureEventAI: DoScriptText entry %i, invalid Source pointer.", textEntry); return; @@ -1240,7 +1240,7 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit* if (textEntry >= 0) { - sLog->outErrorDb("CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), textEntry); + sLog->outErrorDb("CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) attempts to process text entry %i, but text entry must be negative.", source->GetEntry(), source->GetTypeId(), source->GetGUIDLow(), textEntry); return; } @@ -1248,7 +1248,7 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit* if (i == sEventAIMgr->GetCreatureEventAITextMap().end()) { - sLog->outErrorDb("CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.", pSource->GetEntry(), pSource->GetTypeId(), pSource->GetGUIDLow(), textEntry); + sLog->outErrorDb("CreatureEventAI: DoScriptText with source entry %u (TypeId=%u, guid=%u) could not find text entry %i.", source->GetEntry(), source->GetTypeId(), source->GetGUIDLow(), textEntry); return; } @@ -1257,75 +1257,75 @@ void CreatureEventAI::DoScriptText(int32 textEntry, WorldObject* pSource, Unit* if ((*i).second.SoundId) { if (GetSoundEntriesStore()->LookupEntry((*i).second.SoundId)) - pSource->PlayDirectSound((*i).second.SoundId); + source->PlayDirectSound((*i).second.SoundId); else sLog->outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process invalid sound id %u.", textEntry, (*i).second.SoundId); } if ((*i).second.Emote) { - if (pSource->GetTypeId() == TYPEID_UNIT || pSource->GetTypeId() == TYPEID_PLAYER) + if (source->GetTypeId() == TYPEID_UNIT || source->GetTypeId() == TYPEID_PLAYER) { - ((Unit*)pSource)->HandleEmoteCommand((*i).second.Emote); + ((Unit*)source)->HandleEmoteCommand((*i).second.Emote); } else - sLog->outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process emote for invalid TypeId (%u).", textEntry, pSource->GetTypeId()); + sLog->outErrorDb("CreatureEventAI: DoScriptText entry %i tried to process emote for invalid TypeId (%u).", textEntry, source->GetTypeId()); } switch((*i).second.Type) { case CHAT_TYPE_SAY: - pSource->MonsterSay(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); + source->MonsterSay(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); break; case CHAT_TYPE_YELL: - pSource->MonsterYell(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); + source->MonsterYell(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); break; case CHAT_TYPE_TEXT_EMOTE: - pSource->MonsterTextEmote(textEntry, target ? target->GetGUID() : 0); + source->MonsterTextEmote(textEntry, target ? target->GetGUID() : 0); break; case CHAT_TYPE_BOSS_EMOTE: - pSource->MonsterTextEmote(textEntry, target ? target->GetGUID() : 0, true); + source->MonsterTextEmote(textEntry, target ? target->GetGUID() : 0, true); break; case CHAT_TYPE_WHISPER: { if (target && target->GetTypeId() == TYPEID_PLAYER) - pSource->MonsterWhisper(textEntry, target->GetGUID()); + source->MonsterWhisper(textEntry, target->GetGUID()); else sLog->outErrorDb("CreatureEventAI: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry); }break; case CHAT_TYPE_BOSS_WHISPER: { if (target && target->GetTypeId() == TYPEID_PLAYER) - pSource->MonsterWhisper(textEntry, target->GetGUID(), true); + source->MonsterWhisper(textEntry, target->GetGUID(), true); else sLog->outErrorDb("CreatureEventAI: DoScriptText entry %i cannot whisper without target unit (TYPEID_PLAYER).", textEntry); }break; case CHAT_TYPE_ZONE_YELL: - pSource->MonsterYellToZone(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); + source->MonsterYellToZone(textEntry, (*i).second.Language, target ? target->GetGUID() : 0); break; } } -bool CreatureEventAI::CanCast(Unit* Target, SpellInfo const *Spell, bool Triggered) +bool CreatureEventAI::CanCast(Unit* target, SpellInfo const* spell, bool triggered) { //No target so we can't cast - if (!Target || !Spell) + if (!target || !spell) return false; //Silenced so we can't cast - if (!Triggered && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) + if (!triggered && me->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED)) return false; //Check for power - if (!Triggered && me->GetPower((Powers)Spell->PowerType) < Spell->CalcPowerCost(me, Spell->GetSchoolMask())) + if (!triggered && me->GetPower((Powers)spell->PowerType) < spell->CalcPowerCost(me, spell->GetSchoolMask())) return false; //Unit is out of range of this spell - if (!me->IsInRange(Target, Spell->GetMinRange(false), Spell->GetMaxRange(false))) + if (!me->IsInRange(target, spell->GetMinRange(false), spell->GetMaxRange(false))) return false; return true; } -void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote) +void CreatureEventAI::ReceiveEmote(Player* player, uint32 textEmote) { if (m_bEmptyList) return; @@ -1334,7 +1334,7 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote) { if ((*itr).Event.event_type == EVENT_T_RECEIVE_EMOTE) { - if ((*itr).Event.receive_emote.emoteId != text_emote) + if ((*itr).Event.receive_emote.emoteId != textEmote) return; Condition cond; @@ -1342,10 +1342,10 @@ void CreatureEventAI::ReceiveEmote(Player* pPlayer, uint32 text_emote) cond.mConditionValue1 = (*itr).Event.receive_emote.conditionValue1; cond.mConditionValue2 = (*itr).Event.receive_emote.conditionValue2; - if (cond.Meets(pPlayer)) + if (cond.Meets(player)) { sLog->outDebug(LOG_FILTER_DATABASE_AI, "CreatureEventAI: ReceiveEmote CreatureEventAI: Condition ok, processing"); - ProcessEvent(*itr, pPlayer); + ProcessEvent(*itr, player); } } } diff --git a/src/server/game/AI/EventAI/CreatureEventAI.h b/src/server/game/AI/EventAI/CreatureEventAI.h index 7df0dc2d30d..2fc26bcbd3e 100755 --- a/src/server/game/AI/EventAI/CreatureEventAI.h +++ b/src/server/game/AI/EventAI/CreatureEventAI.h @@ -591,7 +591,7 @@ class CreatureEventAI : public CreatureAI { public: - explicit CreatureEventAI(Creature *c); + explicit CreatureEventAI(Creature* c); ~CreatureEventAI() { m_CreatureEventAIList.clear(); @@ -599,32 +599,32 @@ class CreatureEventAI : public CreatureAI void JustRespawned(); void Reset(); void JustReachedHome(); - void EnterCombat(Unit *enemy); + void EnterCombat(Unit* enemy); void EnterEvadeMode(); void JustDied(Unit* /*killer*/); void KilledUnit(Unit* victim); - void JustSummoned(Creature* pUnit); - void AttackStart(Unit *who); - void MoveInLineOfSight(Unit *who); - void SpellHit(Unit* pUnit, const SpellInfo* pSpell); + void JustSummoned(Creature* unit); + void AttackStart(Unit* who); + void MoveInLineOfSight(Unit* who); + void SpellHit(Unit* unit, const SpellInfo* spell); void DamageTaken(Unit* done_by, uint32& damage); void HealReceived(Unit* /*done_by*/, uint32& /*addhealth*/) {} void UpdateAI(const uint32 diff); - void ReceiveEmote(Player* pPlayer, uint32 text_emote); - static int Permissible(const Creature *); + void ReceiveEmote(Player* player, uint32 textEmote); + static int Permissible(const Creature*); - bool ProcessEvent(CreatureEventAIHolder& pHolder, Unit* pActionInvoker = NULL); - void ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 EventId, Unit* pActionInvoker); + bool ProcessEvent(CreatureEventAIHolder& holder, Unit* actionInvoker = NULL); + void ProcessAction(CreatureEventAI_Action const& action, uint32 rnd, uint32 eventId, Unit* actionInvoker); inline uint32 GetRandActionParam(uint32 rnd, uint32 param1, uint32 param2, uint32 param3); inline int32 GetRandActionParam(uint32 rnd, int32 param1, int32 param2, int32 param3); - inline Unit* GetTargetByType(uint32 Target, Unit* pActionInvoker); + inline Unit* GetTargetByType(uint32 target, Unit* actionInvoker); - void DoScriptText(int32 textEntry, WorldObject* pSource, Unit* target); - bool CanCast(Unit* Target, SpellInfo const *Spell, bool Triggered); + void DoScriptText(int32 textEntry, WorldObject* source, Unit* target); + bool CanCast(Unit* target, SpellInfo const* spell, bool triggered); bool SpawnedEventConditionsCheck(CreatureEventAI_Event const& event); - Unit* DoSelectLowestHpFriendly(float range, uint32 MinHPDiff); + Unit* DoSelectLowestHpFriendly(float range, uint32 minHPDiff); void DoFindFriendlyMissingBuff(std::list<Creature*>& _list, float range, uint32 spellid); void DoFindFriendlyCC(std::list<Creature*>& _list, float range); diff --git a/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp b/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp index 6c3765252f0..72828ad01d6 100755 --- a/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp +++ b/src/server/game/AI/EventAI/CreatureEventAIMgr.cpp @@ -124,7 +124,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Summons() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); CreatureEventAI_Summon temp; @@ -178,7 +178,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); CreatureEventAI_Event temp; temp.event_id = EventAI_Type(fields[0].GetUInt32()); @@ -250,14 +250,14 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() case EVENT_T_SPELLHIT: if (temp.spell_hit.spellId) { - SpellInfo const* pSpell = sSpellMgr->GetSpellInfo(temp.spell_hit.spellId); - if (!pSpell) + SpellInfo const* spell = sSpellMgr->GetSpellInfo(temp.spell_hit.spellId); + if (!spell) { sLog->outErrorDb("CreatureEventAI: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.spell_hit.spellId, i); continue; } - if ((temp.spell_hit.schoolMask & pSpell->SchoolMask) != pSpell->SchoolMask) + if ((temp.spell_hit.schoolMask & spell->SchoolMask) != spell->SchoolMask) sLog->outErrorDb("CreatureEventAI: Creature %u has param1(spellId %u) but param2 is not -1 and not equal to spell's school mask. Event %u can never trigger.", temp.creature_id, temp.spell_hit.schoolMask, i); } @@ -304,8 +304,8 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; case EVENT_T_FRIENDLY_MISSING_BUFF: { - SpellInfo const* pSpell = sSpellMgr->GetSpellInfo(temp.spell_hit.spellId); - if (!pSpell) + SpellInfo const* spell = sSpellMgr->GetSpellInfo(temp.spell_hit.spellId); + if (!spell) { sLog->outErrorDb("CreatureEventAI: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.spell_hit.spellId, i); continue; @@ -381,8 +381,8 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() case EVENT_T_BUFFED: case EVENT_T_TARGET_BUFFED: { - SpellInfo const* pSpell = sSpellMgr->GetSpellInfo(temp.buffed.spellId); - if (!pSpell) + SpellInfo const* spell = sSpellMgr->GetSpellInfo(temp.buffed.spellId); + if (!spell) { sLog->outErrorDb("CreatureEventAI: Creature %u has non-existant SpellID(%u) defined in event %u.", temp.creature_id, temp.spell_hit.spellId, i); continue; @@ -501,7 +501,7 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() break; case ACTION_T_CAST: { - const SpellInfo *spell = sSpellMgr->GetSpellInfo(action.cast.spellId); + const SpellInfo* spell = sSpellMgr->GetSpellInfo(action.cast.spellId); if (!spell) sLog->outErrorDb("CreatureEventAI: Event %u Action %u uses non-existent SpellID %u.", i, j+1, action.cast.spellId); /* FIXME: temp.raw.param3 not have event tipes with recovery time in it.... diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index 001296e5c45..ebca71df079 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -16,13 +16,13 @@ struct TSpellSummary { uint8 Targets; // set of enum SelectTarget uint8 Effects; // set of enum SelectEffect -} extern *SpellSummary; +} extern* SpellSummary; void SummonList::DoZoneInCombat(uint32 entry) { for (iterator i = begin(); i != end();) { - Creature *summon = Unit::GetCreature(*me, *i); + Creature* summon = Unit::GetCreature(*me, *i); ++i; if (summon && summon->IsAIEnabled && (!entry || summon->GetEntry() == entry)) @@ -34,7 +34,7 @@ void SummonList::DoAction(uint32 entry, int32 info) { for (iterator i = begin(); i != end();) { - Creature *summon = Unit::GetCreature(*me, *i); + Creature* summon = Unit::GetCreature(*me, *i); ++i; if (summon && summon->IsAIEnabled && (!entry || summon->GetEntry() == entry)) @@ -46,7 +46,7 @@ void SummonList::DespawnEntry(uint32 entry) { for (iterator i = begin(); i != end();) { - Creature *summon = Unit::GetCreature(*me, *i); + Creature* summon = Unit::GetCreature(*me, *i); if (!summon) erase(i++); else if (summon->GetEntry() == entry) @@ -64,7 +64,7 @@ void SummonList::DespawnAll() { while (!empty()) { - Creature *summon = Unit::GetCreature(*me, *begin()); + Creature* summon = Unit::GetCreature(*me, *begin()); if (!summon) erase(begin()); else @@ -108,8 +108,8 @@ bool SummonList::HasEntry(uint32 entry) return false; } -ScriptedAI::ScriptedAI(Creature* pCreature) : CreatureAI(pCreature), - me(pCreature), +ScriptedAI::ScriptedAI(Creature* creature) : CreatureAI(creature), + me(creature), IsFleeing(false), _evadeCheckCooldown(2500), _isCombatMovementAllowed(true) @@ -118,13 +118,13 @@ ScriptedAI::ScriptedAI(Creature* pCreature) : CreatureAI(pCreature), _difficulty = Difficulty(me->GetMap()->GetSpawnMode()); } -void ScriptedAI::AttackStartNoMove(Unit* pWho) +void ScriptedAI::AttackStartNoMove(Unit* who) { - if (!pWho) + if (!who) return; - if (me->Attack(pWho, false)) - DoStartNoMovement(pWho); + if (me->Attack(who, false)) + DoStartNoMovement(who); } void ScriptedAI::UpdateAI(uint32 const /*diff*/) @@ -144,15 +144,15 @@ void ScriptedAI::UpdateAI(uint32 const /*diff*/) } } -void ScriptedAI::DoStartMovement(Unit* pVictim, float fDistance, float fAngle) +void ScriptedAI::DoStartMovement(Unit* victim, float distance, float angle) { - if (pVictim) - me->GetMotionMaster()->MoveChase(pVictim, fDistance, fAngle); + if (victim) + me->GetMotionMaster()->MoveChase(victim, distance, angle); } -void ScriptedAI::DoStartNoMovement(Unit* pVictim) +void ScriptedAI::DoStartNoMovement(Unit* victim) { - if (!pVictim) + if (!victim) return; me->GetMotionMaster()->MoveIdle(); @@ -164,27 +164,27 @@ void ScriptedAI::DoStopAttack() me->AttackStop(); } -void ScriptedAI::DoCastSpell(Unit* pTarget, SpellInfo const* pSpellInfo, bool bTriggered) +void ScriptedAI::DoCastSpell(Unit* target, SpellInfo const* spellInfo, bool triggered) { - if (!pTarget || me->IsNonMeleeSpellCasted(false)) + if (!target || me->IsNonMeleeSpellCasted(false)) return; me->StopMoving(); - me->CastSpell(pTarget, pSpellInfo, bTriggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE); + me->CastSpell(target, spellInfo, triggered ? TRIGGERED_FULL_MASK : TRIGGERED_NONE); } -void ScriptedAI::DoPlaySoundToSet(WorldObject* pSource, uint32 uiSoundId) +void ScriptedAI::DoPlaySoundToSet(WorldObject* source, uint32 soundId) { - if (!pSource) + if (!source) return; - if (!GetSoundEntriesStore()->LookupEntry(uiSoundId)) + if (!GetSoundEntriesStore()->LookupEntry(soundId)) { - sLog->outError("TSCR: Invalid soundId %u used in DoPlaySoundToSet (Source: TypeId %u, GUID %u)", uiSoundId, pSource->GetTypeId(), pSource->GetGUIDLow()); + sLog->outError("TSCR: Invalid soundId %u used in DoPlaySoundToSet (Source: TypeId %u, GUID %u)", soundId, source->GetTypeId(), source->GetGUIDLow()); return; } - pSource->PlayDirectSound(uiSoundId); + source->PlayDirectSound(soundId); } Creature* ScriptedAI::DoSpawnCreature(uint32 entry, float offsetX, float offsetY, float offsetZ, float angle, uint32 type, uint32 despawntime) @@ -302,105 +302,107 @@ void ScriptedAI::DoResetThreat() for (std::list<HostileReference*>::iterator itr = threatlist.begin(); itr != threatlist.end(); ++itr) { - Unit* pUnit = Unit::GetUnit((*me), (*itr)->getUnitGuid()); + Unit* unit = Unit::GetUnit((*me), (*itr)->getUnitGuid()); - if (pUnit && DoGetThreat(pUnit)) - DoModifyThreatPercent(pUnit, -100); + if (unit && DoGetThreat(unit)) + DoModifyThreatPercent(unit, -100); } } -float ScriptedAI::DoGetThreat(Unit* pUnit) +float ScriptedAI::DoGetThreat(Unit* unit) { - if (!pUnit) return 0.0f; - return me->getThreatManager().getThreat(pUnit); + if (!unit) + return 0.0f; + return me->getThreatManager().getThreat(unit); } -void ScriptedAI::DoModifyThreatPercent(Unit* pUnit, int32 pct) +void ScriptedAI::DoModifyThreatPercent(Unit* unit, int32 pct) { - if (!pUnit) return; - me->getThreatManager().modifyThreatPercent(pUnit, pct); + if (!unit) + return; + me->getThreatManager().modifyThreatPercent(unit, pct); } -void ScriptedAI::DoTeleportTo(float fX, float fY, float fZ, uint32 uiTime) +void ScriptedAI::DoTeleportTo(float x, float y, float z, uint32 time) { - me->Relocate(fX, fY, fZ); - me->SendMonsterMove(fX, fY, fZ, uiTime); + me->Relocate(x, y, z); + me->SendMonsterMove(x, y, z, time); } -void ScriptedAI::DoTeleportTo(const float fPos[4]) +void ScriptedAI::DoTeleportTo(const float position[4]) { - me->NearTeleportTo(fPos[0], fPos[1], fPos[2], fPos[3]); + me->NearTeleportTo(position[0], position[1], position[2], position[3]); } -void ScriptedAI::DoTeleportPlayer(Unit* pUnit, float fX, float fY, float fZ, float fO) +void ScriptedAI::DoTeleportPlayer(Unit* unit, float x, float y, float z, float o) { - if (!pUnit || pUnit->GetTypeId() != TYPEID_PLAYER) + if (!unit || unit->GetTypeId() != TYPEID_PLAYER) { - if (pUnit) - sLog->outError("TSCR: Creature " UI64FMTD " (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: " UI64FMTD ") to x: %f y:%f z: %f o: %f. Aborted.", me->GetGUID(), me->GetEntry(), pUnit->GetTypeId(), pUnit->GetGUID(), fX, fY, fZ, fO); + if (unit) + sLog->outError("TSCR: Creature " UI64FMTD " (Entry: %u) Tried to teleport non-player unit (Type: %u GUID: " UI64FMTD ") to x: %f y:%f z: %f o: %f. Aborted.", me->GetGUID(), me->GetEntry(), unit->GetTypeId(), unit->GetGUID(), x, y, z, o); return; } - CAST_PLR(pUnit)->TeleportTo(pUnit->GetMapId(), fX, fY, fZ, fO, TELE_TO_NOT_LEAVE_COMBAT); + CAST_PLR(unit)->TeleportTo(unit->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); } -void ScriptedAI::DoTeleportAll(float fX, float fY, float fZ, float fO) +void ScriptedAI::DoTeleportAll(float x, float y, float z, float o) { - Map *map = me->GetMap(); + Map* map = me->GetMap(); if (!map->IsDungeon()) return; - Map::PlayerList const &PlayerList = map->GetPlayers(); - for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) - if (Player* i_pl = i->getSource()) - if (i_pl->isAlive()) - i_pl->TeleportTo(me->GetMapId(), fX, fY, fZ, fO, TELE_TO_NOT_LEAVE_COMBAT); + Map::PlayerList const& PlayerList = map->GetPlayers(); + for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr) + if (Player* player = itr->getSource()) + if (player->isAlive()) + player->TeleportTo(me->GetMapId(), x, y, z, o, TELE_TO_NOT_LEAVE_COMBAT); } -Unit* ScriptedAI::DoSelectLowestHpFriendly(float fRange, uint32 uiMinHPDiff) +Unit* ScriptedAI::DoSelectLowestHpFriendly(float range, uint32 minHPDiff) { - Unit* pUnit = NULL; - Trinity::MostHPMissingInRange u_check(me, fRange, uiMinHPDiff); - Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(me, pUnit, u_check); - me->VisitNearbyObject(fRange, searcher); + Unit* unit = NULL; + Trinity::MostHPMissingInRange u_check(me, range, minHPDiff); + Trinity::UnitLastSearcher<Trinity::MostHPMissingInRange> searcher(me, unit, u_check); + me->VisitNearbyObject(range, searcher); - return pUnit; + return unit; } -std::list<Creature*> ScriptedAI::DoFindFriendlyCC(float fRange) +std::list<Creature*> ScriptedAI::DoFindFriendlyCC(float range) { - std::list<Creature*> pList; - Trinity::FriendlyCCedInRange u_check(me, fRange); - Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange> searcher(me, pList, u_check); - me->VisitNearbyObject(fRange, searcher); - return pList; + std::list<Creature*> list; + Trinity::FriendlyCCedInRange u_check(me, range); + Trinity::CreatureListSearcher<Trinity::FriendlyCCedInRange> searcher(me, list, u_check); + me->VisitNearbyObject(range, searcher); + return list; } -std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float fRange, uint32 uiSpellid) +std::list<Creature*> ScriptedAI::DoFindFriendlyMissingBuff(float range, uint32 uiSpellid) { - std::list<Creature*> pList; - Trinity::FriendlyMissingBuffInRange u_check(me, fRange, uiSpellid); - Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange> searcher(me, pList, u_check); - me->VisitNearbyObject(fRange, searcher); - return pList; + std::list<Creature*> list; + Trinity::FriendlyMissingBuffInRange u_check(me, range, uiSpellid); + Trinity::CreatureListSearcher<Trinity::FriendlyMissingBuffInRange> searcher(me, list, u_check); + me->VisitNearbyObject(range, searcher); + return list; } -Player* ScriptedAI::GetPlayerAtMinimumRange(float fMinimumRange) +Player* ScriptedAI::GetPlayerAtMinimumRange(float minimumRange) { - Player* pPlayer = NULL; + Player* player = NULL; CellPair pair(Trinity::ComputeCellPair(me->GetPositionX(), me->GetPositionY())); Cell cell(pair); cell.data.Part.reserved = ALL_DISTRICT; cell.SetNoCreate(); - Trinity::PlayerAtMinimumRangeAway check(me, fMinimumRange); - Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway> searcher(me, pPlayer, check); + Trinity::PlayerAtMinimumRangeAway check(me, minimumRange); + Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway> searcher(me, player, check); TypeContainerVisitor<Trinity::PlayerSearcher<Trinity::PlayerAtMinimumRangeAway>, GridTypeMapContainer> visitor(searcher); cell.Visit(pair, visitor, *(me->GetMap())); - return pPlayer; + return player; } void ScriptedAI::SetEquipmentSlots(bool loadDefault, int32 mainHand /*= EQUIP_NO_CHANGE*/, int32 offHand /*= EQUIP_NO_CHANGE*/, int32 ranged /*= EQUIP_NO_CHANGE*/) @@ -451,14 +453,14 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea(uint32 const diff) if (me->IsInEvadeMode() || !me->getVictim()) return false; - float fX = me->GetPositionX(); - float fY = me->GetPositionY(); - float fZ = me->GetPositionZ(); + float x = me->GetPositionX(); + float y = me->GetPositionY(); + float z = me->GetPositionZ(); switch(me->GetEntry()) { case NPC_BROODLORD: // broodlord (not move down stairs) - if (fZ > 448.60f) + if (z > 448.60f) return false; break; case NPC_VOID_REAVER: // void reaver (calculate from center of room) @@ -466,11 +468,11 @@ bool ScriptedAI::EnterEvadeIfOutOfCombatArea(uint32 const diff) return false; break; case NPC_JAN_ALAI: // jan'alai (calculate by Z) - if (fZ > 12.0f) + if (z > 12.0f) return false; break; case NPC_SARTHARION: // sartharion (calculate box) - if (fX > 3218.86f && fX < 3275.69f && fY < 572.40f && fY > 484.68f) + if (x > 3218.86f && x < 3275.69f && y < 572.40f && y > 484.68f) return false; break; default: diff --git a/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp index a3bbd65aff0..c4142ba2b1b 100755 --- a/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.cpp @@ -26,7 +26,7 @@ EndScriptData */ #include "ScriptPCH.h" #include "ScriptedSimpleAI.h" -SimpleAI::SimpleAI(Creature *c) : ScriptedAI(c) +SimpleAI::SimpleAI(Creature* c) : ScriptedAI(c) { //Clear all data Aggro_TextId[0] = 0; @@ -63,7 +63,7 @@ void SimpleAI::Reset() { } -void SimpleAI::EnterCombat(Unit *who) +void SimpleAI::EnterCombat(Unit* who) { //Reset cast timers if (Spell[0].First_Cast >= 0) @@ -123,36 +123,36 @@ void SimpleAI::KilledUnit(Unit* victim) if (!Kill_Spell) return; - Unit *pTarget = NULL; + Unit* target = NULL; switch (Kill_Target_Type) { case CAST_SELF: - pTarget = me; + target = me; break; case CAST_HOSTILE_TARGET: - pTarget = me->getVictim(); + target = me->getVictim(); break; case CAST_HOSTILE_SECOND_AGGRO: - pTarget = SelectTarget(SELECT_TARGET_TOPAGGRO, 1); + target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1); break; case CAST_HOSTILE_LAST_AGGRO: - pTarget = SelectTarget(SELECT_TARGET_BOTTOMAGGRO, 0); + target = SelectTarget(SELECT_TARGET_BOTTOMAGGRO, 0); break; case CAST_HOSTILE_RANDOM: - pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0); + target = SelectTarget(SELECT_TARGET_RANDOM, 0); break; case CAST_KILLEDUNIT_VICTIM: - pTarget = victim; + target = victim; break; } //Target is ok, cast a spell on it - if (pTarget) - DoCast(pTarget, Kill_Spell); + if (target) + DoCast(target, Kill_Spell); } -void SimpleAI::DamageTaken(Unit* killer, uint32 &damage) +void SimpleAI::DamageTaken(Unit* killer, uint32& damage) { //Return if damage taken won't kill us if (me->GetHealth() > damage) @@ -171,33 +171,33 @@ void SimpleAI::DamageTaken(Unit* killer, uint32 &damage) if (!Death_Spell) return; - Unit *pTarget = NULL; + Unit* target = NULL; switch (Death_Target_Type) { case CAST_SELF: - pTarget = me; + target = me; break; case CAST_HOSTILE_TARGET: - pTarget = me->getVictim(); + target = me->getVictim(); break; case CAST_HOSTILE_SECOND_AGGRO: - pTarget = SelectTarget(SELECT_TARGET_TOPAGGRO, 1); + target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1); break; case CAST_HOSTILE_LAST_AGGRO: - pTarget = SelectTarget(SELECT_TARGET_BOTTOMAGGRO, 0); + target = SelectTarget(SELECT_TARGET_BOTTOMAGGRO, 0); break; case CAST_HOSTILE_RANDOM: - pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0); + target = SelectTarget(SELECT_TARGET_RANDOM, 0); break; case CAST_JUSTDIED_KILLER: - pTarget = killer; + target = killer; break; } //Target is ok, cast a spell on it - if (pTarget) - DoCast(pTarget, Death_Spell); + if (target) + DoCast(target, Death_Spell); } void SimpleAI::UpdateAI(const uint32 diff) @@ -222,34 +222,34 @@ void SimpleAI::UpdateAI(const uint32 diff) //Check Current spell if (!(Spell[i].InterruptPreviousCast && me->IsNonMeleeSpellCasted(false))) { - Unit *pTarget = NULL; + Unit* target = NULL; switch (Spell[i].Cast_Target_Type) { case CAST_SELF: - pTarget = me; + target = me; break; case CAST_HOSTILE_TARGET: - pTarget = me->getVictim(); + target = me->getVictim(); break; case CAST_HOSTILE_SECOND_AGGRO: - pTarget = SelectTarget(SELECT_TARGET_TOPAGGRO, 1); + target = SelectTarget(SELECT_TARGET_TOPAGGRO, 1); break; case CAST_HOSTILE_LAST_AGGRO: - pTarget = SelectTarget(SELECT_TARGET_BOTTOMAGGRO, 0); + target = SelectTarget(SELECT_TARGET_BOTTOMAGGRO, 0); break; case CAST_HOSTILE_RANDOM: - pTarget = SelectTarget(SELECT_TARGET_RANDOM, 0); + target = SelectTarget(SELECT_TARGET_RANDOM, 0); break; } //Target is ok, cast a spell on it and then do our random yell - if (pTarget) + if (target) { if (me->IsNonMeleeSpellCasted(false)) me->InterruptNonMeleeSpells(false); - DoCast(pTarget, Spell[i].Spell_Id); + DoCast(target, Spell[i].Spell_Id); //Yell and sound use the same number so that you can make //the Creature yell with the correct sound effect attached @@ -257,7 +257,7 @@ void SimpleAI::UpdateAI(const uint32 diff) //Random yell if (Spell[i].TextId[random_text]) - DoScriptText(Spell[i].TextId[random_text], me, pTarget); + DoScriptText(Spell[i].TextId[random_text], me, target); //Random sound if (Spell[i].Text_Sound[random_text]) diff --git a/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.h b/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.h index 246f1b9df3e..a38bdf85e14 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.h +++ b/src/server/game/AI/ScriptedAI/ScriptedSimpleAI.h @@ -23,7 +23,7 @@ enum CastTarget struct SimpleAI : public ScriptedAI { - SimpleAI(Creature *c);// : ScriptedAI(c); + SimpleAI(Creature* c);// : ScriptedAI(c); void Reset(); @@ -31,7 +31,7 @@ struct SimpleAI : public ScriptedAI void KilledUnit(Unit* /*victim*/); - void DamageTaken(Unit* killer, uint32 &damage); + void DamageTaken(Unit* killer, uint32& damage); void UpdateAI(const uint32 diff); diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index db8d2ffc2cb..7817465c55e 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -787,7 +787,7 @@ void SmartAI::SetFollow(Unit* target, float dist, float angle, uint32 credit, ui mFollowCreditType = creditType; } -void SmartAI::SetScript9(SmartScriptHolder &e, uint32 entry, Unit* invoker) +void SmartAI::SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker) { if (invoker) GetScript()->mLastInvoker = invoker->GetGUID(); @@ -888,7 +888,7 @@ void SmartGameObjectAI::SetData(uint32 id, uint32 value) GetScript()->ProcessEventsFor(SMART_EVENT_DATA_SET, NULL, id, value); } -void SmartGameObjectAI::SetScript9(SmartScriptHolder &e, uint32 entry, Unit* invoker) +void SmartGameObjectAI::SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker) { if (invoker) GetScript()->mLastInvoker = invoker->GetGUID(); diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index e26d125b442..834a34bf17b 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -48,7 +48,7 @@ class SmartAI : public CreatureAI { public: ~SmartAI(){}; - explicit SmartAI(Creature *c); + explicit SmartAI(Creature* c); // Start moving to the desired MovePoint void StartPath(bool run = false, uint32 path = 0, bool repeat = false, Unit* invoker = NULL); @@ -65,7 +65,7 @@ class SmartAI : public CreatureAI void SetCombatMove(bool on); void SetFollow(Unit* target, float dist = 0.0f, float angle = 0.0f, uint32 credit = 0, uint32 end = 0, uint32 creditType = 0); - void SetScript9(SmartScriptHolder &e, uint32 entry, Unit* invoker); + void SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker); SmartScript* GetScript() { return &mScript; } bool IsEscortInvokerInRange(); @@ -79,7 +79,7 @@ class SmartAI : public CreatureAI void JustReachedHome(); // Called for reaction at enter to combat if not in combat yet (enemy can be NULL) - void EnterCombat(Unit *enemy); + void EnterCombat(Unit* enemy); // Called for reaction at stopping attack at no attackers or targets void EnterEvadeMode(); @@ -97,7 +97,7 @@ class SmartAI : public CreatureAI void AttackStart(Unit* who); // Called if IsVisible(Unit *who) is true at each *who move, reaction at visibility zone enter - void MoveInLineOfSight(Unit *who); + void MoveInLineOfSight(Unit* who); // Called when hit by a spell void SpellHit(Unit* pUnit, const SpellInfo* pSpell); @@ -124,13 +124,13 @@ class SmartAI : public CreatureAI void IsSummonedBy(Unit* summoner); // Called at any Damage to any victim (before damage apply) - void DamageDealt(Unit* done_to, uint32 & damage, DamageEffectType /*damagetype*/); + void DamageDealt(Unit* done_to, uint32& damage, DamageEffectType /*damagetype*/); // Called when a summoned creature dissapears (UnSommoned) void SummonedCreatureDespawn(Creature* unit); // called when the corpse of this creature gets removed - void CorpseRemoved(uint32 & respawnDelay); + void CorpseRemoved(uint32& respawnDelay); // Called at World update tick if creature is charmed void UpdateAIWhileCharmed(const uint32 diff); @@ -163,7 +163,7 @@ class SmartAI : public CreatureAI uint64 GetGUID(int32 id = 0); //core related - static int Permissible(const Creature *); + static int Permissible(const Creature*); // Called at movepoint reached void MovepointReached(uint32 id); @@ -231,7 +231,7 @@ class SmartAI : public CreatureAI class SmartGameObjectAI : public GameObjectAI { public: - SmartGameObjectAI(GameObject *g) : GameObjectAI(g), go(g) {} + SmartGameObjectAI(GameObject* g) : GameObjectAI(g), go(g) {} ~SmartGameObjectAI() {} void UpdateAI(const uint32 diff); @@ -248,7 +248,7 @@ public: uint32 GetDialogStatus(Player* /*player*/); void Destroyed(Player* player, uint32 eventId); void SetData(uint32 id, uint32 value); - void SetScript9(SmartScriptHolder &e, uint32 entry, Unit* invoker); + void SetScript9(SmartScriptHolder& e, uint32 entry, Unit* invoker); protected: GameObject* const go; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index 99c804d3d2c..cc244f77dc2 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -282,7 +282,7 @@ bool SmartAIMgr::IsTargetValid(SmartScriptHolder const& e) return true; } -bool SmartAIMgr::IsEventValid(SmartScriptHolder &e) +bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) { if (e.event.type >= SMART_EVENT_END) { diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 4ab9a738707..2292a343c21 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -1236,7 +1236,7 @@ class SmartAIMgr //event stores SmartAIEventMap mEventMap[SMART_SCRIPT_TYPE_MAX]; - bool IsEventValid(SmartScriptHolder &e); + bool IsEventValid(SmartScriptHolder& e); bool IsTargetValid(SmartScriptHolder const& e); /*inline bool IsTargetValid(SmartScriptHolder e, int32 target) |