diff options
author | Shauren <shauren.trinity@gmail.com> | 2020-09-04 13:38:24 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2020-09-04 13:38:24 +0200 |
commit | b23190393248455f04d3a06def030a1ec7efad1e (patch) | |
tree | 1ce3772314492dcdb985641269a3114813d4b4dc /src/server/game | |
parent | b20acfe701e6f5f995f2776f076d3c494c02e1aa (diff) |
Core/Misc: Port all the refactors sneaked in master to 3.3.5 include cleanup port
Diffstat (limited to 'src/server/game')
176 files changed, 915 insertions, 929 deletions
diff --git a/src/server/game/AI/CoreAI/CombatAI.cpp b/src/server/game/AI/CoreAI/CombatAI.cpp index 160b58a9742..b96a97d8734 100644 --- a/src/server/game/AI/CoreAI/CombatAI.cpp +++ b/src/server/game/AI/CoreAI/CombatAI.cpp @@ -248,7 +248,7 @@ TurretAI::TurretAI(Creature* c) : CreatureAI(c) me->m_SightDistance = me->m_CombatDistance; } -bool TurretAI::CanAIAttack(const Unit* /*who*/) const +bool TurretAI::CanAIAttack(Unit const* /*who*/) const { /// @todo use one function to replace it if (!me->IsWithinCombatRange(me->GetVictim(), me->m_CombatDistance) diff --git a/src/server/game/AI/CoreAI/GameObjectAI.h b/src/server/game/AI/CoreAI/GameObjectAI.h index 61fb2f350a1..1e15325eefb 100644 --- a/src/server/game/AI/CoreAI/GameObjectAI.h +++ b/src/server/game/AI/CoreAI/GameObjectAI.h @@ -46,7 +46,7 @@ class TC_GAME_API GameObjectAI virtual void SetGUID(uint64 /*guid*/, int32 /*id = 0 */) { } virtual uint64 GetGUID(int32 /*id = 0 */) const { return 0; } - static int32 Permissible(GameObject const* /*go*/); + static int32 Permissible(GameObject const* go); // Called when a player opens a gossip dialog with the gameobject. virtual bool GossipHello(Player* /*player*/) { return false; } @@ -82,7 +82,7 @@ class TC_GAME_API GameObjectAI virtual void OnLootStateChanged(uint32 /*state*/, Unit* /*unit*/) { } virtual void OnStateChanged(uint32 /*state*/) { } virtual void EventInform(uint32 /*eventId*/) { } - virtual void SpellHit(Unit* /*unit*/, const SpellInfo* /*spellInfo*/) { } + virtual void SpellHit(Unit* /*unit*/, SpellInfo const* /*spellInfo*/) { } }; class TC_GAME_API NullGameObjectAI : public GameObjectAI @@ -92,6 +92,6 @@ class TC_GAME_API NullGameObjectAI : public GameObjectAI void UpdateAI(uint32 /*diff*/) override { } - static int32 Permissible(GameObject const* /*go*/); + static int32 Permissible(GameObject const* go); }; #endif diff --git a/src/server/game/AI/CoreAI/UnitAI.h b/src/server/game/AI/CoreAI/UnitAI.h index a38bf60e632..cec43d12698 100644 --- a/src/server/game/AI/CoreAI/UnitAI.h +++ b/src/server/game/AI/CoreAI/UnitAI.h @@ -28,7 +28,7 @@ #define ENSURE_AI(a,b) (EnsureAI<a>(b)) template<class T, class U> -inline T* EnsureAI(U* ai) +T* EnsureAI(U* ai) { T* cast_ai = dynamic_cast<T*>(ai); ASSERT(cast_ai); @@ -74,7 +74,7 @@ struct TC_GAME_API DefaultTargetSelector // Target selector for spell casts checking range, auras and attributes /// @todo Add more checks from Spell::CheckCast -struct TC_GAME_API SpellTargetSelector : public std::unary_function<Unit*, bool> +struct TC_GAME_API SpellTargetSelector { public: SpellTargetSelector(Unit* caster, uint32 spellId); @@ -88,7 +88,7 @@ struct TC_GAME_API SpellTargetSelector : public std::unary_function<Unit*, bool> // Very simple target selector, will just skip main target // NOTE: When passing to UnitAI::SelectTarget remember to use 0 as position for random selection // because tank will not be in the temporary list -struct TC_GAME_API NonTankTargetSelector : public std::unary_function<Unit*, bool> +struct TC_GAME_API NonTankTargetSelector { public: NonTankTargetSelector(Unit* source, bool playerOnly = true) : _source(source), _playerOnly(playerOnly) { } @@ -119,11 +119,11 @@ public: FarthestTargetSelector(Unit const* unit, float dist, bool playerOnly, bool inLos) : _me(unit), _dist(dist), _playerOnly(playerOnly), _inLos(inLos) {} bool operator()(Unit const* target) const; -private: - const Unit* _me; - float _dist; - bool _playerOnly; - bool _inLos; + private: + Unit const* _me; + float _dist; + bool _playerOnly; + bool _inLos; }; class TC_GAME_API UnitAI @@ -315,7 +315,7 @@ class TC_GAME_API UnitAI virtual bool GossipSelect(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/) { return false; } // Called when a player selects a gossip with a code in the creature's gossip menu. - virtual bool GossipSelectCode(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/, const char* /*code*/) { return false; } + virtual bool GossipSelectCode(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/, char const* /*code*/) { return false; } // Called when a player accepts a quest from the creature. virtual void QuestAccept(Player* /*player*/, Quest const* /*quest*/) { } diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index 7e57465443b..bb44c5d572f 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -393,7 +393,7 @@ bool CreatureAI::CheckInRoom() } } -Creature* CreatureAI::DoSummon(uint32 entry, const Position& pos, uint32 despawnTime, TempSummonType summonType) +Creature* CreatureAI::DoSummon(uint32 entry, Position const& pos, uint32 despawnTime, TempSummonType summonType) { return me->SummonCreature(entry, pos, summonType, despawnTime); } diff --git a/src/server/game/AI/CreatureAIFactory.h b/src/server/game/AI/CreatureAIFactory.h index 92e757d835d..70de867e8e8 100644 --- a/src/server/game/AI/CreatureAIFactory.h +++ b/src/server/game/AI/CreatureAIFactory.h @@ -21,6 +21,9 @@ #include "ObjectRegistry.h" #include "FactoryHolder.h" +class Creature; +class CreatureAI; + typedef FactoryHolder<CreatureAI, Creature> CreatureAICreator; struct SelectableAI : public CreatureAICreator, public Permissible<Creature> diff --git a/src/server/game/AI/CreatureAIImpl.h b/src/server/game/AI/CreatureAIImpl.h index cbc7c5912a0..fa3b5662d99 100644 --- a/src/server/game/AI/CreatureAIImpl.h +++ b/src/server/game/AI/CreatureAIImpl.h @@ -93,8 +93,8 @@ AISpellInfoType* GetAISpellInfo(uint32 spellId, Difficulty difficulty); TC_GAME_API bool InstanceHasScript(WorldObject const* obj, char const* scriptName); -template<class AI, class T> -inline AI* GetInstanceAI(T* obj, char const* scriptName) +template <class AI, class T> +AI* GetInstanceAI(T* obj, char const* scriptName) { if (InstanceHasScript(obj, scriptName)) return new AI(obj); diff --git a/src/server/game/AI/CreatureAIRegistry.cpp b/src/server/game/AI/CreatureAIRegistry.cpp index 34cc64af22b..35ba2a56be6 100644 --- a/src/server/game/AI/CreatureAIRegistry.cpp +++ b/src/server/game/AI/CreatureAIRegistry.cpp @@ -15,19 +15,20 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "PassiveAI.h" -#include "ReactorAI.h" +#include "CreatureAIFactory.h" +#include "GameObjectAIFactory.h" + #include "CombatAI.h" #include "GuardAI.h" +#include "PassiveAI.h" #include "PetAI.h" +#include "ReactorAI.h" +#include "SmartAI.h" #include "TotemAI.h" -#include "RandomMovementGenerator.h" + #include "MovementGenerator.h" -#include "CreatureAIRegistry.h" +#include "RandomMovementGenerator.h" #include "WaypointMovementGenerator.h" -#include "CreatureAIFactory.h" -#include "GameObjectAIFactory.h" -#include "SmartAI.h" namespace AIRegistry { diff --git a/src/server/game/AI/PlayerAI/PlayerAI.h b/src/server/game/AI/PlayerAI/PlayerAI.h index 225b51c09f7..600713e9680 100644 --- a/src/server/game/AI/PlayerAI/PlayerAI.h +++ b/src/server/game/AI/PlayerAI/PlayerAI.h @@ -30,6 +30,7 @@ class TC_GAME_API PlayerAI : public UnitAI void OnCharmed(bool /*apply*/) override { } // charm AI application for players is handled by Unit::SetCharmedBy / Unit::RemoveCharmedBy Creature* GetCharmer() const; + // helper functions to determine player info uint16 GetSpec(Player const* who = nullptr) const; static bool IsPlayerHealer(Player const* who); diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index ee6d0770604..ae30dcca730 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -548,7 +548,7 @@ bool BossAI::CanAIAttack(Unit const* target) const return CheckBoundary(target); } -void BossAI::_DespawnAtEvade(Seconds delayToRespawn, Creature* who) +void BossAI::_DespawnAtEvade(Seconds delayToRespawn /*= 30s*/, Creature* who /*= nullptr*/) { if (delayToRespawn < Seconds(2)) { @@ -566,7 +566,7 @@ void BossAI::_DespawnAtEvade(Seconds delayToRespawn, Creature* who) return; } - who->DespawnOrUnsummon(0, Seconds(delayToRespawn)); + who->DespawnOrUnsummon(0, delayToRespawn); if (instance && who == me) instance->SetBossState(_bossId, FAIL); diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h index c255f97ae24..28d40b24856 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h @@ -19,7 +19,7 @@ #define SCRIPTEDCREATURE_H_ #include "CreatureAI.h" -#include "Creature.h" // convenience include for scripts, all uses of ScriptedCreature also need Creature (except ScriptedCreature itself doesn't need Creature) +#include "Creature.h" // convenience include for scripts, all uses of ScriptedCreature also need Creature (except ScriptedCreature itself doesn't need Creature) #include "DBCEnums.h" #include "TaskScheduler.h" @@ -90,7 +90,7 @@ public: void DespawnAll(); template <typename T> - void DespawnIf(T const &predicate) + void DespawnIf(T const& predicate) { storage_.remove_if(predicate); } @@ -364,7 +364,7 @@ class TC_GAME_API BossAI : public ScriptedAI void _EnterCombat(); void _JustDied(); void _JustReachedHome(); - void _DespawnAtEvade(Seconds delayToRespawn, Creature* who = nullptr); + void _DespawnAtEvade(Seconds delayToRespawn, Creature* who = nullptr); void _DespawnAtEvade(uint32 delayToRespawn = 30, Creature* who = nullptr) { _DespawnAtEvade(Seconds(delayToRespawn), who); } void TeleportCheaters(); diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp index b8b9fb065d4..79919e46397 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -109,11 +109,9 @@ void EscortAI::JustDied(Unit* /*killer*/) if (Group* group = player->GetGroup()) { for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next()) - { if (Player* member = groupRef->GetSource()) if (member->IsInMap(player)) member->FailQuest(_escortQuest->GetQuestId()); - } } else player->FailQuest(_escortQuest->GetQuestId()); @@ -170,11 +168,9 @@ bool EscortAI::IsPlayerOrGroupInRange() if (Group* group = player->GetGroup()) { for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next()) - { if (Player* member = groupRef->GetSource()) if (me->IsWithinDistInMap(member, GetMaxPlayerDistance())) return true; - } } else if (me->IsWithinDistInMap(player, GetMaxPlayerDistance())) return true; diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp index 5c6884dc026..30cec2a814d 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp @@ -270,7 +270,7 @@ void FollowerAI::MovementInform(uint32 motionType, uint32 pointId) } } -void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, const Quest* quest) +void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, Quest const* quest) { if (me->GetVictim()) { diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h index 0212d8e61d3..39c5da0e8ae 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h @@ -55,7 +55,7 @@ class TC_GAME_API FollowerAI : public ScriptedAI void UpdateAI(uint32) override; //the "internal" update, calls UpdateFollowerAI() virtual void UpdateFollowerAI(uint32); //used when it's needed to add code in update (abilities, scripted events, etc) - void StartFollow(Player* player, uint32 factionForFollower = 0, const Quest* quest = nullptr); + void StartFollow(Player* player, uint32 factionForFollower = 0, Quest const* quest = nullptr); void SetFollowPaused(bool bPaused); //if special event require follow mode to hold/resume during the follow void SetFollowComplete(bool bWithEndEvent = false); @@ -75,7 +75,7 @@ class TC_GAME_API FollowerAI : public ScriptedAI uint32 m_uiUpdateFollowTimer; uint32 m_uiFollowState; - const Quest* m_pQuestForFollow; //normally we have a quest + Quest const* m_pQuestForFollow; //normally we have a quest }; #endif diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 6a1e18f3fc8..3327a43cf43 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -494,7 +494,7 @@ void SmartAI::MoveInLineOfSight(Unit* who) CreatureAI::MoveInLineOfSight(who); } -bool SmartAI::CanAIAttack(const Unit* /*who*/) const +bool SmartAI::CanAIAttack(Unit const* /*who*/) const { return !(me->HasReactState(REACT_PASSIVE)); } @@ -635,12 +635,12 @@ void SmartAI::AttackStart(Unit* who) } } -void SmartAI::SpellHit(Unit* unit, const SpellInfo* spellInfo) +void SmartAI::SpellHit(Unit* unit, SpellInfo const* spellInfo) { GetScript()->ProcessEventsFor(SMART_EVENT_SPELLHIT, unit, 0, 0, false, spellInfo); } -void SmartAI::SpellHitTarget(Unit* target, const SpellInfo* spellInfo) +void SmartAI::SpellHitTarget(Unit* target, SpellInfo const* spellInfo) { GetScript()->ProcessEventsFor(SMART_EVENT_SPELLHIT_TARGET, target, 0, 0, false, spellInfo); } @@ -788,7 +788,7 @@ bool SmartAI::GossipSelect(Player* player, uint32 menuId, uint32 gossipListId) return _gossipReturn; } -bool SmartAI::GossipSelectCode(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/, const char* /*code*/) +bool SmartAI::GossipSelectCode(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/, char const* /*code*/) { return false; } @@ -967,7 +967,7 @@ bool SmartGameObjectAI::GossipSelect(Player* player, uint32 sender, uint32 actio } // Called when a player selects a gossip with a code in the gameobject's gossip menu. -bool SmartGameObjectAI::GossipSelectCode(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/, const char* /*code*/) +bool SmartGameObjectAI::GossipSelectCode(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/, char const* /*code*/) { return false; } @@ -1017,7 +1017,7 @@ void SmartGameObjectAI::EventInform(uint32 eventId) GetScript()->ProcessEventsFor(SMART_EVENT_GO_EVENT_INFORM, nullptr, eventId); } -void SmartGameObjectAI::SpellHit(Unit* unit, const SpellInfo* spellInfo) +void SmartGameObjectAI::SpellHit(Unit* unit, SpellInfo const* spellInfo) { GetScript()->ProcessEventsFor(SMART_EVENT_SPELLHIT, unit, 0, 0, false, spellInfo); } diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index 357020f80b2..4e9a9f976a6 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -102,10 +102,10 @@ class TC_GAME_API SmartAI : public CreatureAI void MoveInLineOfSight(Unit* who) override; // Called when hit by a spell - void SpellHit(Unit* unit, const SpellInfo* spellInfo) override; + void SpellHit(Unit* unit, SpellInfo const* spellInfo) override; // Called when spell hits a target - void SpellHitTarget(Unit* target, const SpellInfo* spellInfo) override; + void SpellHitTarget(Unit* target, SpellInfo const* spellInfo) override; // Called at any Damage from any attacker (before damage apply) void DamageTaken(Unit* doneBy, uint32& damage) override; @@ -144,7 +144,7 @@ class TC_GAME_API SmartAI : public CreatureAI void OnCharmed(bool apply) override; // Called when victim is in line of sight - bool CanAIAttack(const Unit* who) const override; + bool CanAIAttack(Unit const* who) const override; // Used in scripts to share variables void DoAction(int32 param = 0) override; @@ -176,7 +176,7 @@ class TC_GAME_API SmartAI : public CreatureAI bool GossipHello(Player* player) override; bool GossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override; - bool GossipSelectCode(Player* player, uint32 menuId, uint32 gossipListId, const char* code) override; + bool GossipSelectCode(Player* player, uint32 menuId, uint32 gossipListId, char const* code) override; void QuestAccept(Player* player, Quest const* quest) override; void QuestReward(Player* player, Quest const* quest, uint32 opt) override; void OnGameEvent(bool start, uint16 eventId) override; @@ -263,7 +263,7 @@ class TC_GAME_API SmartGameObjectAI : public GameObjectAI bool GossipHello(Player* player) override; bool OnReportUse(Player* player) override; bool GossipSelect(Player* player, uint32 menuId, uint32 gossipListId) override; - bool GossipSelectCode(Player* player, uint32 menuId, uint32 gossipListId, const char* code) override; + bool GossipSelectCode(Player* player, uint32 menuId, uint32 gossipListId, char const* code) override; void QuestAccept(Player* player, Quest const* quest) override; void QuestReward(Player* player, Quest const* quest, uint32 opt) override; void Destroyed(Player* player, uint32 eventId) override; @@ -272,7 +272,7 @@ class TC_GAME_API SmartGameObjectAI : public GameObjectAI void OnGameEvent(bool start, uint16 eventId) override; void OnLootStateChanged(uint32 state, Unit* unit) override; void EventInform(uint32 eventId) override; - void SpellHit(Unit* unit, const SpellInfo* spellInfo) override; + void SpellHit(Unit* unit, SpellInfo const* spellInfo) override; void SetGossipReturn(bool val) { _gossipReturn = val; } diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index d3388b1916e..ea07eeafcfb 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -172,6 +172,7 @@ void SmartScript::ResetBaseObject() go = nullptr; } } + if (!goOrigGUID.IsEmpty()) { if (GameObject* o = ObjectAccessor::GetGameObject(*lookupRoot, goOrigGUID)) @@ -185,7 +186,7 @@ void SmartScript::ResetBaseObject() meOrigGUID.Clear(); } -void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob, std::string const& varString) +void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint32 var1, bool bvar, SpellInfo const* spell, GameObject* gob, std::string const& varString) { for (SmartAIEventList::iterator i = mEvents.begin(); i != mEvents.end(); ++i) { @@ -199,7 +200,7 @@ void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint3 } } -void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob, std::string const& varString) +void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, uint32 var1, bool bvar, SpellInfo const* spell, GameObject* gob, std::string const& varString) { // calc random if (e.GetEventType() != SMART_EVENT_LINK && e.event.event_chance < 100 && e.event.event_chance) @@ -2351,7 +2352,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u } } -void SmartScript::ProcessTimedAction(SmartScriptHolder& e, uint32 const& min, uint32 const& max, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob, std::string const& varString) +void SmartScript::ProcessTimedAction(SmartScriptHolder& e, uint32 const& min, uint32 const& max, Unit* unit, uint32 var0, uint32 var1, bool bvar, SpellInfo const* spell, GameObject* gob, std::string const& varString) { // We may want to execute action rarely and because of this if condition is not fulfilled the action will be rechecked in a long time if (sConditionMgr->IsObjectMeetingSmartEventConditions(e.entryOrGuid, e.event_id, e.source_type, unit, GetBaseObject())) @@ -2829,7 +2830,7 @@ void SmartScript::GetWorldObjectsInDist(ObjectVector& targets, float dist) const Cell::VisitAllObjects(obj, searcher, dist); } -void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob, std::string const& varString) +void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, uint32 var1, bool bvar, SpellInfo const* spell, GameObject* gob, std::string const& varString) { if (!e.active && e.GetEventType() != SMART_EVENT_LINK) return; diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h index 64aa2716cc7..cb573d79809 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.h +++ b/src/server/game/AI/SmartScripts/SmartScript.h @@ -40,14 +40,14 @@ class TC_GAME_API SmartScript void GetScript(); void FillScript(SmartAIEventList e, WorldObject* obj, AreaTriggerEntry const* at, SceneTemplate const* scene); - void ProcessEventsFor(SMART_EVENT e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = nullptr, GameObject* gob = nullptr, std::string const& varString = ""); - void ProcessEvent(SmartScriptHolder& e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = nullptr, GameObject* gob = nullptr, std::string const& varString = ""); + void ProcessEventsFor(SMART_EVENT e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, SpellInfo const* spell = nullptr, GameObject* gob = nullptr, std::string const& varString = ""); + void ProcessEvent(SmartScriptHolder& e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, SpellInfo const* spell = nullptr, GameObject* gob = nullptr, std::string const& varString = ""); bool CheckTimer(SmartScriptHolder const& e) const; static void RecalcTimer(SmartScriptHolder& e, uint32 min, uint32 max); void UpdateTimer(SmartScriptHolder& e, uint32 const diff); static void InitTimer(SmartScriptHolder& e); - void ProcessAction(SmartScriptHolder& e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = nullptr, GameObject* gob = nullptr, std::string const& varString = ""); - void ProcessTimedAction(SmartScriptHolder& e, uint32 const& min, uint32 const& max, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = nullptr, GameObject* gob = nullptr, std::string const& varString = ""); + void ProcessAction(SmartScriptHolder& e, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, SpellInfo const* spell = nullptr, GameObject* gob = nullptr, std::string const& varString = ""); + void ProcessTimedAction(SmartScriptHolder& e, uint32 const& min, uint32 const& max, Unit* unit = nullptr, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, SpellInfo const* spell = nullptr, GameObject* gob = nullptr, std::string const& varString = ""); void GetTargets(ObjectVector& targets, SmartScriptHolder const& e, Unit* invoker = nullptr) const; void GetWorldObjectsInDist(ObjectVector& objects, float dist) const; void InstallTemplate(SmartScriptHolder const& e); @@ -55,7 +55,6 @@ class TC_GAME_API SmartScript void AddEvent(SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, uint32 event_param5, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 phaseMask = 0); void SetPathId(uint32 id) { mPathId = id; } uint32 GetPathId() const { return mPathId; } - WorldObject* GetBaseObject() const; WorldObject* GetBaseObjectOrUnit(Unit* unit); static bool IsUnit(WorldObject* obj); diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index 3f0962a20b8..2e120c1862d 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -16,8 +16,8 @@ */ #include "SmartScriptMgr.h" -#include "DB2Stores.h" #include "CreatureTextMgr.h" +#include "DB2Stores.h" #include "DatabaseEnv.h" #include "GameEventMgr.h" #include "InstanceScript.h" diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index f358ea81c90..26563797b1c 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -1630,31 +1630,22 @@ class TC_GAME_API SmartAIMgr bool IsEventValid(SmartScriptHolder& e); bool IsTargetValid(SmartScriptHolder const& e); + bool IsMinMaxValid(SmartScriptHolder const& e, uint32 min, uint32 max); - /*inline bool IsPercentValid(SmartScriptHolder e, int32 pct) - { - if (pct < -100 || pct > 100) - { - TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry %d SourceType %u Event %u Action %u has invalid Percent set (%d), skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), pct); - return false; - } - return true; - }*/ - - bool NotNULL(SmartScriptHolder const& e, uint32 data); - bool IsCreatureValid(SmartScriptHolder const& e, uint32 entry); - bool IsQuestValid(SmartScriptHolder const& e, uint32 entry); - bool IsGameObjectValid(SmartScriptHolder const& e, uint32 entry); - bool IsSpellValid(SmartScriptHolder const& e, uint32 entry); - bool IsItemValid(SmartScriptHolder const& e, uint32 entry); - bool IsTextEmoteValid(SmartScriptHolder const& e, uint32 entry); - bool IsEmoteValid(SmartScriptHolder const& e, uint32 entry); - bool IsAreaTriggerValid(SmartScriptHolder const& e, uint32 entry); - bool IsSoundValid(SmartScriptHolder const& e, uint32 entry); - bool IsAnimKitValid(SmartScriptHolder const& e, uint32 entry); - bool IsSpellVisualKitValid(SmartScriptHolder const& e, uint32 entry); - bool IsTextValid(SmartScriptHolder const& e, uint32 id); + static bool NotNULL(SmartScriptHolder const& e, uint32 data); + static bool IsCreatureValid(SmartScriptHolder const& e, uint32 entry); + static bool IsQuestValid(SmartScriptHolder const& e, uint32 entry); + static bool IsGameObjectValid(SmartScriptHolder const& e, uint32 entry); + static bool IsSpellValid(SmartScriptHolder const& e, uint32 entry); + static bool IsItemValid(SmartScriptHolder const& e, uint32 entry); + static bool IsTextEmoteValid(SmartScriptHolder const& e, uint32 entry); + static bool IsEmoteValid(SmartScriptHolder const& e, uint32 entry); + static bool IsAreaTriggerValid(SmartScriptHolder const& e, uint32 entry); + static bool IsSoundValid(SmartScriptHolder const& e, uint32 entry); + static bool IsAnimKitValid(SmartScriptHolder const& e, uint32 entry); + static bool IsSpellVisualKitValid(SmartScriptHolder const& e, uint32 entry); + static bool IsTextValid(SmartScriptHolder const& e, uint32 id); // Helpers void LoadHelperStores(); diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBot.h b/src/server/game/AuctionHouseBot/AuctionHouseBot.h index 3bf9caef9f8..0ce9c86a427 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBot.h +++ b/src/server/game/AuctionHouseBot/AuctionHouseBot.h @@ -214,8 +214,8 @@ public: static AuctionBotConfig* instance(); bool Initialize(); - const std::string& GetAHBotIncludes() const { return _AHBotIncludes; } - const std::string& GetAHBotExcludes() const { return _AHBotExcludes; } + std::string const& GetAHBotIncludes() const { return _AHBotIncludes; } + std::string const& GetAHBotExcludes() const { return _AHBotExcludes; } uint32 GetConfig(AuctionBotConfigUInt32Values index) const { return _configUint32Values[index]; } bool GetConfig(AuctionBotConfigBoolValues index) const { return _configBoolValues[index]; } diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp index bd6425f9dfd..a1dbb211070 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp @@ -317,7 +317,7 @@ void AuctionBotBuyer::BuyAndBidItems(BuyerConfiguration& config) bidPrice = auction->MinBid; } - const BuyerItemInfo* ahInfo = nullptr; + BuyerItemInfo const* ahInfo = nullptr; BuyerItemInfoMap::const_iterator sameItemItr = config.SameItemInfo.find(auction->Bucket->Key.ItemId); if (sameItemItr != config.SameItemInfo.end()) ahInfo = &sameItemItr->second; diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp index da14231ec3c..194c8f790be 100644 --- a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp +++ b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp @@ -109,7 +109,6 @@ bool AuctionBotSeller::Initialize() for (uint32 itemId = 0; itemId < sItemStore.GetNumRows(); ++itemId) { ItemTemplate const* prototype = sObjectMgr->GetItemTemplate(itemId); - if (!prototype) continue; diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index 4203af63d28..778e8132484 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -588,7 +588,7 @@ BfGraveyard* Battlefield::GetGraveyardById(uint32 id) const return nullptr; } -WorldSafeLocsEntry const* Battlefield::GetClosestGraveYard(Player* player) +WorldSafeLocsEntry const* Battlefield::GetClosestGraveyard(Player* player) { BfGraveyard* closestGY = nullptr; float maxdist = -1; @@ -762,7 +762,7 @@ void BfGraveyard::RelocateDeadPlayers() player->TeleportTo(closestGrave->Loc); else { - closestGrave = m_Bf->GetClosestGraveYard(player); + closestGrave = m_Bf->GetClosestGraveyard(player); if (closestGrave) player->TeleportTo(closestGrave->Loc); } diff --git a/src/server/game/Battlefield/Battlefield.h b/src/server/game/Battlefield/Battlefield.h index 4beab5bba95..80bb14ab40b 100644 --- a/src/server/game/Battlefield/Battlefield.h +++ b/src/server/game/Battlefield/Battlefield.h @@ -300,7 +300,7 @@ class TC_GAME_API Battlefield : public ZoneScript // Graveyard methods // Find which graveyard the player must be teleported to to be resurrected by spiritguide - WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); + WorldSafeLocsEntry const* GetClosestGraveyard(Player* player); virtual void AddPlayerToResurrectQueue(ObjectGuid npc_guid, ObjectGuid player_guid); void RemovePlayerFromResurrectQueue(ObjectGuid player_guid); diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index 22ff6ef0616..423edd6cf07 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -45,7 +45,7 @@ struct BfWGCoordGY }; // 7 in sql, 7 in header -BfWGCoordGY const WGGraveYard[BATTLEFIELD_WG_GRAVEYARD_MAX] = +BfWGCoordGY const WGGraveyard[BATTLEFIELD_WG_GRAVEYARD_MAX] = { { { 5104.750f, 2300.940f, 368.579f, 0.733038f }, 1329, BATTLEFIELD_WG_GOSSIPTEXT_GY_NE, TEAM_NEUTRAL }, { { 5099.120f, 3466.036f, 368.484f, 5.317802f }, 1330, BATTLEFIELD_WG_GOSSIPTEXT_GY_NW, TEAM_NEUTRAL }, @@ -436,7 +436,7 @@ bool BattlefieldWG::SetupBattlefield() m_saveTimer = 60000; - // Init GraveYards + // Init Graveyards SetGraveyardNumber(BATTLEFIELD_WG_GRAVEYARD_MAX); // Load from db @@ -468,12 +468,12 @@ bool BattlefieldWG::SetupBattlefield() BfGraveyardWG* graveyard = new BfGraveyardWG(this); // When between games, the graveyard is controlled by the defending team - if (WGGraveYard[i].StartControl == TEAM_NEUTRAL) - graveyard->Initialize(m_DefenderTeam, WGGraveYard[i].GraveyardID); + if (WGGraveyard[i].StartControl == TEAM_NEUTRAL) + graveyard->Initialize(m_DefenderTeam, WGGraveyard[i].GraveyardID); else - graveyard->Initialize(WGGraveYard[i].StartControl, WGGraveYard[i].GraveyardID); + graveyard->Initialize(WGGraveyard[i].StartControl, WGGraveyard[i].GraveyardID); - graveyard->SetTextId(WGGraveYard[i].TextID); + graveyard->SetTextId(WGGraveyard[i].TextID); m_GraveyardList[i] = graveyard; } diff --git a/src/server/game/Battlegrounds/ArenaTeam.cpp b/src/server/game/Battlegrounds/ArenaTeam.cpp index e544336d4b4..3a087bd1fdd 100644 --- a/src/server/game/Battlegrounds/ArenaTeam.cpp +++ b/src/server/game/Battlegrounds/ArenaTeam.cpp @@ -460,7 +460,7 @@ void ArenaTeam::BroadcastPacket(WorldPacket* packet) { for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr) if (Player* player = ObjectAccessor::FindConnectedPlayer(itr->Guid)) - player->GetSession()->SendPacket(packet); + player->SendDirectMessage(packet); } uint8 ArenaTeam::GetSlotByType(uint32 type) diff --git a/src/server/game/Battlegrounds/ArenaTeam.h b/src/server/game/Battlegrounds/ArenaTeam.h index 8cb9c398aa0..0c40635150e 100644 --- a/src/server/game/Battlegrounds/ArenaTeam.h +++ b/src/server/game/Battlegrounds/ArenaTeam.h @@ -127,7 +127,7 @@ class TC_GAME_API ArenaTeam static uint8 GetTypeBySlot(uint8 slot); ObjectGuid GetCaptain() const { return CaptainGuid; } std::string const& GetName() const { return TeamName; } - const ArenaTeamStats& GetStats() const { return Stats; } + ArenaTeamStats const& GetStats() const { return Stats; } uint32 GetRating() const { return Stats.Rating; } uint32 GetAverageMMR(Group* group) const; diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 5ae3f387853..1efed636f87 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -153,7 +153,7 @@ void Battleground::Update(uint32 diff) // [[ but if you use battleground object again (more battles possible to be played on 1 instance) // then this condition should be removed and code: // if (!GetInvitedCount(HORDE) && !GetInvitedCount(ALLIANCE)) - // this->AddToFreeBGObjectsQueue(); // not yet implemented + // AddToFreeBGObjectsQueue(); // not yet implemented // should be used instead of current // ]] // Battleground Template instance cannot be updated, because it would be deleted @@ -1365,7 +1365,7 @@ void Battleground::RelocateDeadPlayers(ObjectGuid guideGuid) continue; if (!closestGrave) - closestGrave = GetClosestGraveYard(player); + closestGrave = GetClosestGraveyard(player); if (closestGrave) player->TeleportTo(closestGrave->Loc); @@ -1825,9 +1825,9 @@ void Battleground::SetBgRaid(uint32 TeamID, Group* bg_raid) old_raid = bg_raid; } -WorldSafeLocsEntry const* Battleground::GetClosestGraveYard(Player* player) +WorldSafeLocsEntry const* Battleground::GetClosestGraveyard(Player* player) { - return sObjectMgr->GetClosestGraveYard(*player, player->GetTeam(), player); + return sObjectMgr->GetClosestGraveyard(*player, player->GetTeam(), player); } void Battleground::StartCriteriaTimer(CriteriaTimedTypes type, uint32 entry) diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index 7dface61839..43b798a734d 100644 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -444,7 +444,7 @@ class TC_GAME_API Battleground virtual void HandlePlayerResurrect(Player* /*player*/) { } // Death related - virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); + virtual WorldSafeLocsEntry const* GetClosestGraveyard(Player* player); virtual WorldSafeLocsEntry const* GetExploitTeleportLocation(Team /*team*/) { return nullptr; } // GetExploitTeleportLocation(TeamId) must be implemented in the battleground subclass. @@ -507,10 +507,10 @@ class TC_GAME_API Battleground void EndNow(); void PlayerAddedToBGCheckIfBGIsRunning(Player* player); - Player* _GetPlayer(ObjectGuid guid, bool offlineRemove, const char* context) const; - Player* _GetPlayer(BattlegroundPlayerMap::iterator itr, const char* context) { return _GetPlayer(itr->first, itr->second.OfflineRemoveTime != 0, context); } - Player* _GetPlayer(BattlegroundPlayerMap::const_iterator itr, const char* context) const { return _GetPlayer(itr->first, itr->second.OfflineRemoveTime != 0, context); } - Player* _GetPlayerForTeam(uint32 teamId, BattlegroundPlayerMap::const_iterator itr, const char* context) const; + Player* _GetPlayer(ObjectGuid guid, bool offlineRemove, char const* context) const; + Player* _GetPlayer(BattlegroundPlayerMap::iterator itr, char const* context) { return _GetPlayer(itr->first, itr->second.OfflineRemoveTime != 0, context); } + Player* _GetPlayer(BattlegroundPlayerMap::const_iterator itr, char const* context) const { return _GetPlayer(itr->first, itr->second.OfflineRemoveTime != 0, context); } + Player* _GetPlayerForTeam(uint32 teamId, BattlegroundPlayerMap::const_iterator itr, char const* context) const; /* Pre- and post-update hooks */ diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp index 6b264536549..6d110933b53 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp @@ -631,7 +631,7 @@ void BattlegroundAB::EndBattleground(uint32 winner) Battleground::EndBattleground(winner); } -WorldSafeLocsEntry const* BattlegroundAB::GetClosestGraveYard(Player* player) +WorldSafeLocsEntry const* BattlegroundAB::GetClosestGraveyard(Player* player) { TeamId teamIndex = GetTeamIndexByTeamId(player->GetTeam()); @@ -651,7 +651,7 @@ WorldSafeLocsEntry const* BattlegroundAB::GetClosestGraveYard(Player* player) float mindist = 999999.0f; for (uint8 i = 0; i < nodes.size(); ++i) { - WorldSafeLocsEntry const*entry = sObjectMgr->GetWorldSafeLoc(BG_AB_GraveyardIds[nodes[i]]); + WorldSafeLocsEntry const* entry = sObjectMgr->GetWorldSafeLoc(BG_AB_GraveyardIds[nodes[i]]); if (!entry) continue; float dist = (entry->Loc.GetPositionX() - plr_x) * (entry->Loc.GetPositionX() - plr_x) + (entry->Loc.GetPositionY() - plr_y) * (entry->Loc.GetPositionY() - plr_y); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h index c95d33ee82e..830d817b28b 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.h @@ -322,7 +322,7 @@ class BattlegroundAB : public Battleground bool SetupBattleground() override; void Reset() override; void EndBattleground(uint32 winner) override; - WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override; + WorldSafeLocsEntry const* GetClosestGraveyard(Player* player) override; WorldSafeLocsEntry const* GetExploitTeleportLocation(Team team) override; /* Scorekeeping */ diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index 7d4798c88df..f3684e7c037 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -395,7 +395,7 @@ void BattlegroundAV::PostUpdateImpl(uint32 diff) } } if (m_Mine_Timer <= 0) - m_Mine_Timer=AV_MINE_TICK_TIMER; //this is at the end, cause we need to update both mines + m_Mine_Timer = AV_MINE_TICK_TIMER; //this is at the end, cause we need to update both mines //looks for all timers of the nodes and destroy the building (for graveyards the building wont get destroyed, it goes just to the other team for (BG_AV_Nodes i = BG_AV_NODES_FIRSTAID_STATION; i < BG_AV_NODES_MAX; ++i) @@ -1099,7 +1099,7 @@ void BattlegroundAV::SendMineWorldStates(uint32 mine) UpdateWorldState(BG_AV_MineWorldStates[mine2][prevowner], 0); } -WorldSafeLocsEntry const* BattlegroundAV::GetClosestGraveYard(Player* player) +WorldSafeLocsEntry const* BattlegroundAV::GetClosestGraveyard(Player* player) { WorldSafeLocsEntry const* pGraveyard = nullptr; WorldSafeLocsEntry const* entry = nullptr; @@ -1498,7 +1498,7 @@ void BattlegroundAV::ResetBGSubclass() InitNode(i, HORDE, true); InitNode(BG_AV_NODES_SNOWFALL_GRAVE, AV_NEUTRAL_TEAM, false); //give snowfall neutral owner - m_Mine_Timer=AV_MINE_TICK_TIMER; + m_Mine_Timer = AV_MINE_TICK_TIMER; for (uint16 i = 0; i < AV_CPLACE_MAX+AV_STATICCPLACE_MAX; i++) if (!BgCreatures[i].IsEmpty()) DelCreature(i); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h index afcab05675d..6a145dc0f38 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.h @@ -1650,7 +1650,7 @@ class BattlegroundAV : public Battleground void EndBattleground(uint32 winner) override; - WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override; + WorldSafeLocsEntry const* GetClosestGraveyard(Player* player) override; WorldSafeLocsEntry const* GetExploitTeleportLocation(Team team) override; // Achievement: Av perfection and Everything counts @@ -1687,7 +1687,7 @@ class BattlegroundAV : public Battleground bool IsTower(BG_AV_Nodes node) { return m_Nodes[node].Tower; } /*mine*/ - void ChangeMineOwner(uint8 mine, uint32 team, bool initial=false); + void ChangeMineOwner(uint8 mine, uint32 team, bool initial = false); /*worldstates*/ void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates& packet) override; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h index d151548f21d..a54c54aad98 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundDS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundDS.h @@ -109,4 +109,5 @@ class BattlegroundDS : public Arena uint32 _pipeKnockBackTimer; uint8 _pipeKnockBackCount; }; + #endif diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index d782fb22c8c..e93c0b952bb 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -109,10 +109,10 @@ void BattlegroundEY::PostUpdateImpl(uint32 diff) /*I used this order of calls, because although we will check if one player is in gameobject's distance 2 times but we can count of players on current point in CheckSomeoneLeftPoint */ - this->CheckSomeoneJoinedPoint(); + CheckSomeoneJoinedPoint(); //check if player left point - this->CheckSomeoneLeftPoint(); - this->UpdatePointStatuses(); + CheckSomeoneLeftPoint(); + UpdatePointStatuses(); m_TowerCapCheckTimer = BG_EY_FPOINTS_TICK_TIME; } } @@ -791,10 +791,10 @@ void BattlegroundEY::EventTeamCapturedPoint(Player* player, uint32 Point) if (!BgCreatures[Point].IsEmpty()) DelCreature(Point); - WorldSafeLocsEntry const* sg = sObjectMgr->GetWorldSafeLoc(m_CapturingPointTypes[Point].GraveYardId); + WorldSafeLocsEntry const* sg = sObjectMgr->GetWorldSafeLoc(m_CapturingPointTypes[Point].GraveyardId); if (!sg || !AddSpiritGuide(Point, sg->Loc.GetPositionX(), sg->Loc.GetPositionY(), sg->Loc.GetPositionZ(), 3.124139f, GetTeamIndexByTeamId(Team))) TC_LOG_ERROR("bg.battleground", "BatteGroundEY: Failed to spawn spirit guide. point: %u, team: %u, graveyard_id: %u", - Point, Team, m_CapturingPointTypes[Point].GraveYardId); + Point, Team, m_CapturingPointTypes[Point].GraveyardId); // SpawnBGCreature(Point, RESPAWN_IMMEDIATELY); @@ -916,7 +916,7 @@ void BattlegroundEY::FillInitialWorldStates(WorldPackets::WorldState::InitWorldS } } -WorldSafeLocsEntry const* BattlegroundEY::GetClosestGraveYard(Player* player) +WorldSafeLocsEntry const* BattlegroundEY::GetClosestGraveyard(Player* player) { uint32 g_id = 0; @@ -953,9 +953,9 @@ WorldSafeLocsEntry const* BattlegroundEY::GetClosestGraveYard(Player* player) { if (m_PointOwnedByTeam[i] == player->GetTeam() && m_PointState[i] == EY_POINT_UNDER_CONTROL) { - entry = sObjectMgr->GetWorldSafeLoc(m_CapturingPointTypes[i].GraveYardId); + entry = sObjectMgr->GetWorldSafeLoc(m_CapturingPointTypes[i].GraveyardId); if (!entry) - TC_LOG_ERROR("bg.battleground", "BattlegroundEY: Graveyard %u could not be found.", m_CapturingPointTypes[i].GraveYardId); + TC_LOG_ERROR("bg.battleground", "BattlegroundEY: Graveyard %u could not be found.", m_CapturingPointTypes[i].GraveyardId); else { distance = (entry->Loc.GetPositionX() - plr_x) * (entry->Loc.GetPositionX() - plr_x) diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h index 37e3aed3837..71a3df30dc0 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h @@ -329,11 +329,11 @@ struct BattlegroundEYLosingPointStruct struct BattlegroundEYCapturingPointStruct { - BattlegroundEYCapturingPointStruct(uint32 _DespawnNeutralObjectType, uint32 _SpawnObjectTypeAlliance, uint32 _MessageIdAlliance, uint32 _SpawnObjectTypeHorde, uint32 _MessageIdHorde, uint32 _GraveYardId) + BattlegroundEYCapturingPointStruct(uint32 _DespawnNeutralObjectType, uint32 _SpawnObjectTypeAlliance, uint32 _MessageIdAlliance, uint32 _SpawnObjectTypeHorde, uint32 _MessageIdHorde, uint32 _GraveyardId) : DespawnNeutralObjectType(_DespawnNeutralObjectType), SpawnObjectTypeAlliance(_SpawnObjectTypeAlliance), MessageIdAlliance(_MessageIdAlliance), SpawnObjectTypeHorde(_SpawnObjectTypeHorde), MessageIdHorde(_MessageIdHorde), - GraveYardId(_GraveYardId) + GraveyardId(_GraveyardId) { } uint32 DespawnNeutralObjectType; @@ -341,7 +341,7 @@ struct BattlegroundEYCapturingPointStruct uint32 MessageIdAlliance; uint32 SpawnObjectTypeHorde; uint32 MessageIdHorde; - uint32 GraveYardId; + uint32 GraveyardId; }; const uint8 BG_EY_TickPoints[EY_POINTS_MAX] = {1, 2, 5, 10}; @@ -424,7 +424,7 @@ class BattlegroundEY : public Battleground void RemovePlayer(Player* player, ObjectGuid guid, uint32 team) override; void HandleAreaTrigger(Player* source, uint32 trigger, bool entered) override; void HandleKillPlayer(Player* player, Player* killer) override; - WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override; + WorldSafeLocsEntry const* GetClosestGraveyard(Player* player) override; WorldSafeLocsEntry const* GetExploitTeleportLocation(Team team) override; bool SetupBattleground() override; void Reset() override; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp index 15b64ffb1d5..925419f9be0 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp @@ -856,7 +856,7 @@ void BattlegroundIC::DestroyGate(Player* player, GameObject* go) SendBroadcastText(textId, msgType); } -WorldSafeLocsEntry const* BattlegroundIC::GetClosestGraveYard(Player* player) +WorldSafeLocsEntry const* BattlegroundIC::GetClosestGraveyard(Player* player) { TeamId teamIndex = GetTeamIndexByTeamId(player->GetTeam()); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h index 05b37f9c246..704f19f8781 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.h @@ -973,7 +973,7 @@ class BattlegroundIC : public Battleground void DestroyGate(Player* player, GameObject* go) override; - WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override; + WorldSafeLocsEntry const* GetClosestGraveyard(Player* player) override; WorldSafeLocsEntry const* GetExploitTeleportLocation(Team team) override; /* Scorekeeping */ diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp index 48366a84af7..d9d3af56f21 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp @@ -687,7 +687,7 @@ void BattlegroundSA::DestroyGate(Player* /*player*/, GameObject* /*go*/) { } -WorldSafeLocsEntry const* BattlegroundSA::GetClosestGraveYard(Player* player) +WorldSafeLocsEntry const* BattlegroundSA::GetClosestGraveyard(Player* player) { uint32 safeloc = 0; WorldSafeLocsEntry const* ret; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h index 3a4b157305f..475239dc459 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.h @@ -588,7 +588,7 @@ class BattlegroundSA : public Battleground /// Called when a player kill a unit in bg void HandleKillUnit(Creature* creature, Player* killer) override; /// Return the nearest graveyard where player can respawn - WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override; + WorldSafeLocsEntry const* GetClosestGraveyard(Player* player) override; /// Called when someone activates an event void ProcessEvent(WorldObject* /*obj*/, uint32 /*eventId*/, WorldObject* /*invoker*/ = nullptr) override; /// Called when a player click on flag (graveyard flag) diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp index 30298d78a0d..483e7ab1706 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp @@ -814,7 +814,7 @@ bool BattlegroundWS::UpdatePlayerScore(Player* player, uint32 type, uint32 value return true; } -WorldSafeLocsEntry const* BattlegroundWS::GetClosestGraveYard(Player* player) +WorldSafeLocsEntry const* BattlegroundWS::GetClosestGraveyard(Player* player) { //if status in progress, it returns main graveyards with spiritguides //else it will return the graveyard in the flagroom - this is especially good diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h index d40f185240d..35e9a18f0e0 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h @@ -245,7 +245,7 @@ class BattlegroundWS : public Battleground bool SetupBattleground() override; void Reset() override; void EndBattleground(uint32 winner) override; - WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override; + WorldSafeLocsEntry const* GetClosestGraveyard(Player* player) override; WorldSafeLocsEntry const* GetExploitTeleportLocation(Team team) override; void UpdateFlagState(uint32 team, uint32 value); diff --git a/src/server/game/Chat/Channels/Channel.h b/src/server/game/Chat/Channels/Channel.h index cbf56637285..4c3f074588e 100644 --- a/src/server/game/Chat/Channels/Channel.h +++ b/src/server/game/Chat/Channels/Channel.h @@ -24,6 +24,7 @@ #include <unordered_set> class Player; +struct AreaTableEntry; namespace WorldPackets { @@ -33,8 +34,6 @@ namespace WorldPackets } } -struct AreaTableEntry; - enum ChatNotify { CHAT_JOINED_NOTICE = 0x00, //+ "%s joined channel."; diff --git a/src/server/game/Chat/Channels/ChannelAppenders.h b/src/server/game/Chat/Channels/ChannelAppenders.h index 67666a8c727..eb7b9d70c4c 100644 --- a/src/server/game/Chat/Channels/ChannelAppenders.h +++ b/src/server/game/Chat/Channels/ChannelAppenders.h @@ -185,8 +185,8 @@ struct ChannelOwnerAppend { explicit ChannelOwnerAppend(Channel const* channel, ObjectGuid const& ownerGuid) : _channel(channel), _ownerGuid(ownerGuid) { - if (CharacterCacheEntry const* characterInfo = sCharacterCache->GetCharacterCacheByGuid(_ownerGuid)) - _ownerName = characterInfo->Name; + if (CharacterCacheEntry const* cInfo = sCharacterCache->GetCharacterCacheByGuid(_ownerGuid)) + _ownerName = cInfo->Name; } static uint8 const NotificationType = CHAT_CHANNEL_OWNER_NOTICE; diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 1e411d9d56c..03c75df9348 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -43,6 +43,7 @@ #include "World.h" #include "WorldSession.h" #include <random> +#include <sstream> char const* const ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX] = { @@ -1125,7 +1126,7 @@ void ConditionMgr::LoadConditions(bool isReload) } cond->ReferenceId = uint32(abs(iConditionTypeOrReference)); - const char* rowType = "reference template"; + char const* rowType = "reference template"; if (iSourceTypeOrReferenceId >= 0) rowType = "reference"; //check for useless data diff --git a/src/server/game/DataStores/M2Stores.cpp b/src/server/game/DataStores/M2Stores.cpp index a14f9ae8121..c5eb43fdf24 100644 --- a/src/server/game/DataStores/M2Stores.cpp +++ b/src/server/game/DataStores/M2Stores.cpp @@ -262,6 +262,7 @@ TC_GAME_API void LoadM2Cameras(std::string const& dataPath) if (!readCamera(cam, fileSize - m2start, header, cameraEntry)) TC_LOG_ERROR("server.loading", "Camera file %s is damaged. Camera references position beyond file end", filename.string().c_str()); } + TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " cinematic waypoint sets in %u ms", sFlyByCameraStore.size(), GetMSTimeDiffToNow(oldMSTime)); } diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index b224af5f9c7..08320def248 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -43,17 +43,17 @@ namespace lfg { -LFGDungeonData::LFGDungeonData() : id(0), name(""), map(0), type(0), expansion(0), group(0), minlevel(0), -maxlevel(0), difficulty(DIFFICULTY_NONE), seasonal(false), x(0.0f), y(0.0f), z(0.0f), o(0.0f), -requiredItemLevel(0) +LFGDungeonData::LFGDungeonData() : id(0), name(), map(0), type(0), expansion(0), group(0), minlevel(0), + maxlevel(0), difficulty(DIFFICULTY_NONE), seasonal(false), x(0.0f), y(0.0f), z(0.0f), o(0.0f), + requiredItemLevel(0) { } LFGDungeonData::LFGDungeonData(LFGDungeonsEntry const* dbc) : id(dbc->ID), name(dbc->Name[sWorld->GetDefaultDbcLocale()]), map(dbc->MapID), -type(uint8(dbc->TypeID)), expansion(uint8(dbc->ExpansionLevel)), group(uint8(dbc->GroupID)), -minlevel(uint8(dbc->MinLevel)), maxlevel(uint8(dbc->MaxLevel)), difficulty(Difficulty(dbc->DifficultyID)), -seasonal((dbc->Flags[0] & LFG_FLAG_SEASONAL) != 0), x(0.0f), y(0.0f), z(0.0f), o(0.0f), -requiredItemLevel(0) + type(uint8(dbc->TypeID)), expansion(uint8(dbc->ExpansionLevel)), group(uint8(dbc->GroupID)), + minlevel(uint8(dbc->MinLevel)), maxlevel(uint8(dbc->MaxLevel)), difficulty(Difficulty(dbc->DifficultyID)), + seasonal((dbc->Flags[0] & LFG_FLAG_SEASONAL) != 0), x(0.0f), y(0.0f), z(0.0f), o(0.0f), + requiredItemLevel(0) { } @@ -1417,7 +1417,7 @@ void LFGMgr::FinishDungeon(ObjectGuid gguid, const uint32 dungeonId, Map const* } uint32 rDungeonId = 0; - const LfgDungeonSet& dungeons = GetSelectedDungeons(guid); + LfgDungeonSet const& dungeons = GetSelectedDungeons(guid); if (!dungeons.empty()) rDungeonId = (*dungeons.begin()); diff --git a/src/server/game/DungeonFinding/LFGPlayerData.h b/src/server/game/DungeonFinding/LFGPlayerData.h index ba351ed738f..5c8ad907dfe 100644 --- a/src/server/game/DungeonFinding/LFGPlayerData.h +++ b/src/server/game/DungeonFinding/LFGPlayerData.h @@ -42,7 +42,7 @@ class TC_GAME_API LfgPlayerData // Queue void SetRoles(uint8 roles); - void SetSelectedDungeons(const LfgDungeonSet& dungeons); + void SetSelectedDungeons(LfgDungeonSet const& dungeons); // General WorldPackets::LFG::RideTicket const& GetTicket() const; diff --git a/src/server/game/DungeonFinding/LFGQueue.cpp b/src/server/game/DungeonFinding/LFGQueue.cpp index ac296295104..6e747e6d0b8 100644 --- a/src/server/game/DungeonFinding/LFGQueue.cpp +++ b/src/server/game/DungeonFinding/LFGQueue.cpp @@ -503,7 +503,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(GuidList check) else { ObjectGuid gguid = *check.begin(); - const LfgQueueData &queue = QueueDataStore[gguid]; + LfgQueueData const& queue = QueueDataStore[gguid]; proposalDungeons = queue.dungeons; proposalRoles = queue.roles; LFGMgr::CheckGroupRoles(proposalRoles); // assing new roles @@ -673,7 +673,7 @@ std::string LFGQueue::DumpCompatibleInfo(bool full /* = false */) const { o << " ("; bool first = true; - for (const auto& role : itr->second.roles) + for (auto const& role : itr->second.roles) { if (!first) o << "|"; diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 22b7fe930ce..95b329a6af7 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -67,6 +67,7 @@ bool VendorItemData::RemoveItem(uint32 item_id, uint8 type) { return vendorItem.item == item_id && vendorItem.Type == type; }); + bool found = newEnd != m_items.end(); m_items.erase(newEnd, m_items.end()); return found; @@ -812,7 +813,7 @@ void Creature::Update(uint32 diff) if (m_combatPulseTime == 0) { - Map::PlayerList const &players = GetMap()->GetPlayers(); + Map::PlayerList const& players = GetMap()->GetPlayers(); if (!players.isEmpty()) for (Map::PlayerList::const_iterator it = players.begin(); it != players.end(); ++it) { @@ -2190,7 +2191,7 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds const& forceRespawn void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/, Seconds const& forceRespawnTimer /*= 0*/) { - if (TempSummon* summon = this->ToTempSummon()) + if (TempSummon* summon = ToTempSummon()) summon->UnSummon(msTimeToDespawn); else ForcedDespawn(msTimeToDespawn, forceRespawnTimer); @@ -2456,7 +2457,7 @@ void Creature::CallForHelp(float radius) Cell::VisitGridObjects(this, worker, radius); } -bool Creature::CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction /*= true*/) const +bool Creature::CanAssistTo(Unit const* u, Unit const* enemy, bool checkfaction /*= true*/) const { if (IsInEvadeMode()) return false; @@ -2730,7 +2731,7 @@ void Creature::SetInCombatWithZone() return; } - Map::PlayerList const &PlList = map->GetPlayers(); + Map::PlayerList const& PlList = map->GetPlayers(); if (PlList.isEmpty()) return; @@ -3057,7 +3058,7 @@ float Creature::GetAggroRange(Unit const* target) const // Determines the aggro range for creatures (usually pets), used mainly for aggressive pet target selection. // Based on data from wowwiki due to lack of 3.3.5a data - if (target && this->IsPet()) + if (target && IsPet()) { uint32 targetLevel = 0; diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 5798ea814e0..853039a20e8 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -229,8 +229,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma void SetNoCallAssistance(bool val) { m_AlreadyCallAssistance = val; } void SetNoSearchAssistance(bool val) { m_AlreadySearchedAssistance = val; } bool HasSearchedAssistance() const { return m_AlreadySearchedAssistance; } - bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const; - bool _IsTargetAcceptable(const Unit* target) const; + bool CanAssistTo(Unit const* u, Unit const* enemy, bool checkfaction = true) const; + bool _IsTargetAcceptable(Unit const* target) const; MovementGeneratorType GetDefaultMovementType() const { return m_defaultMovementType; } void SetDefaultMovementType(MovementGeneratorType mgt) { m_defaultMovementType = mgt; } @@ -281,12 +281,12 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma bool CanNotReachTarget() const { return m_cannotReachTarget; } void SetHomePosition(float x, float y, float z, float o) { m_homePosition.Relocate(x, y, z, o); } - void SetHomePosition(const Position &pos) { m_homePosition.Relocate(pos); } + void SetHomePosition(Position const& pos) { m_homePosition.Relocate(pos); } void GetHomePosition(float& x, float& y, float& z, float& ori) const { m_homePosition.GetPosition(x, y, z, ori); } Position const& GetHomePosition() const { return m_homePosition; } void SetTransportHomePosition(float x, float y, float z, float o) { m_transportHomePosition.Relocate(x, y, z, o); } - void SetTransportHomePosition(const Position &pos) { m_transportHomePosition.Relocate(pos); } + void SetTransportHomePosition(Position const& pos) { m_transportHomePosition.Relocate(pos); } void GetTransportHomePosition(float& x, float& y, float& z, float& ori) const { m_transportHomePosition.GetPosition(x, y, z, ori); } Position const& GetTransportHomePosition() const { return m_transportHomePosition; } diff --git a/src/server/game/Entities/Creature/CreatureGroups.cpp b/src/server/game/Entities/Creature/CreatureGroups.cpp index c18740b673a..02b02ff27f8 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.cpp +++ b/src/server/game/Entities/Creature/CreatureGroups.cpp @@ -217,7 +217,7 @@ void CreatureGroup::FormationReset(bool dismiss) m_Formed = !dismiss; } -void CreatureGroup::LeaderMoveTo(Position destination, uint32 id /*= 0*/, uint32 moveType /*= 0*/, bool orientation /*= false*/) +void CreatureGroup::LeaderMoveTo(Position const& destination, uint32 id /*= 0*/, uint32 moveType /*= 0*/, bool orientation /*= false*/) { //! To do: This should probably get its own movement generator or use WaypointMovementGenerator. //! If the leader's path is known, member's path can be plotted as well using formation offsets. diff --git a/src/server/game/Entities/Creature/CreatureGroups.h b/src/server/game/Entities/Creature/CreatureGroups.h index 75c25d79c48..a5735ca3f88 100644 --- a/src/server/game/Entities/Creature/CreatureGroups.h +++ b/src/server/game/Entities/Creature/CreatureGroups.h @@ -19,7 +19,6 @@ #define _FORMATIONS_H #include "Define.h" -#include "Position.h" #include "ObjectGuid.h" #include <unordered_map> #include <map> @@ -36,6 +35,7 @@ enum GroupAIFlags class Creature; class CreatureGroup; class Unit; +struct Position; struct FormationInfo { @@ -89,7 +89,7 @@ class TC_GAME_API CreatureGroup void RemoveMember(Creature* member); void FormationReset(bool dismiss); - void LeaderMoveTo(Position destination, uint32 id = 0, uint32 moveType = 0, bool orientation = false); + void LeaderMoveTo(Position const& destination, uint32 id = 0, uint32 moveType = 0, bool orientation = false); void MemberEngagingTarget(Creature* member, Unit* target); bool CanLeaderStartMoving() const; }; diff --git a/src/server/game/Entities/Creature/TemporarySummon.h b/src/server/game/Entities/Creature/TemporarySummon.h index c91af442cef..b2837e951cd 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.h +++ b/src/server/game/Entities/Creature/TemporarySummon.h @@ -62,7 +62,7 @@ class TC_GAME_API TempSummon : public Creature void SetVisibleBySummonerOnly(bool visibleBySummonerOnly) { m_visibleBySummonerOnly = visibleBySummonerOnly; } bool IsVisibleBySummonerOnly() const { return m_visibleBySummonerOnly; } - const SummonPropertiesEntry* const m_Properties; + SummonPropertiesEntry const* const m_Properties; private: TempSummonType m_type; uint32 m_timer; diff --git a/src/server/game/Entities/DynamicObject/DynamicObject.h b/src/server/game/Entities/DynamicObject/DynamicObject.h index 4786dd763f3..b9ee877d95d 100644 --- a/src/server/game/Entities/DynamicObject/DynamicObject.h +++ b/src/server/game/Entities/DynamicObject/DynamicObject.h @@ -63,7 +63,7 @@ class TC_GAME_API DynamicObject : public WorldObject, public GridObject<DynamicO Unit* GetCaster() const { return _caster; } void BindToCaster(); void UnbindFromCaster(); - uint32 GetSpellId() const { return m_dynamicObjectData->SpellID; } + uint32 GetSpellId() const { return m_dynamicObjectData->SpellID; } SpellInfo const* GetSpellInfo() const; ObjectGuid GetCasterGUID() const { return m_dynamicObjectData->Caster; } float GetRadius() const { return m_dynamicObjectData->Radius; } diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 3fc26262ede..97c017ca13b 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -27,6 +27,7 @@ #include "GameObjectModel.h" #include "GameObjectPackets.h" #include "GameTime.h" +#include "GossipDef.h" #include "GridNotifiersImpl.h" #include "Group.h" #include "GroupMgr.h" @@ -43,7 +44,6 @@ #include "ScriptMgr.h" #include "SpellMgr.h" #include "Transport.h" -#include "GossipDef.h" #include "World.h" #include <G3D/Quat.h> #include <sstream> @@ -97,7 +97,7 @@ WorldPacket GameObjectTemplate::BuildQueryData(LocaleConstant loc) const bool QuaternionData::isUnit() const { - return fabs(x * x + y * y + z * z + w * w - 1.0f) < 1e-5; + return fabs(x * x + y * y + z * z + w * w - 1.0f) < 1e-5f; } QuaternionData QuaternionData::fromEulerAnglesZYX(float Z, float Y, float X) @@ -1018,8 +1018,7 @@ void GameObject::SaveToDB() void GameObject::SaveToDB(uint32 mapid, std::vector<Difficulty> const& spawnDifficulties) { - const GameObjectTemplate* goI = GetGOInfo(); - + GameObjectTemplate const* goI = GetGOInfo(); if (!goI) return; @@ -1427,7 +1426,7 @@ void GameObject::SetGoArtKit(uint8 kit) void GameObject::SetGoArtKit(uint8 artkit, GameObject* go, ObjectGuid::LowType lowguid) { - const GameObjectData* data = nullptr; + GameObjectData const* data = nullptr; if (go) { go->SetGoArtKit(artkit); diff --git a/src/server/game/Entities/Item/Container/Bag.cpp b/src/server/game/Entities/Item/Container/Bag.cpp index fa317105ce4..2b9628034f5 100644 --- a/src/server/game/Entities/Item/Container/Bag.cpp +++ b/src/server/game/Entities/Item/Container/Bag.cpp @@ -161,7 +161,7 @@ void Bag::StoreItem(uint8 slot, Item* pItem, bool /*update*/) { ASSERT(slot < MAX_BAG_SIZE); - if (pItem && pItem->GetGUID() != this->GetGUID()) + if (pItem && pItem->GetGUID() != GetGUID()) { m_bagslot[slot] = pItem; SetSlot(slot, pItem->GetGUID()); diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index 4ac35bbb68d..038534dba16 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -1139,7 +1139,7 @@ void AddItemToUpdateQueueOf(Item* item, Player* player) if (player->GetGUID() != item->GetOwnerGUID()) { - TC_LOG_DEBUG("entities.player.items", "Item::AddToUpdateQueueOf - Owner's guid (%s) and player's guid (%s) don't match!", + TC_LOG_DEBUG("entities.player.items", "AddItemToUpdateQueueOf - Owner's guid (%s) and player's guid (%s) don't match!", item->GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str()); return; } @@ -1160,7 +1160,7 @@ void RemoveItemFromUpdateQueueOf(Item* item, Player* player) if (player->GetGUID() != item->GetOwnerGUID()) { - TC_LOG_DEBUG("entities.player.items", "Item::RemoveFromUpdateQueueOf - Owner's guid (%s) and player's guid (%s) don't match!", + TC_LOG_DEBUG("entities.player.items", "RemoveItemFromUpdateQueueOf - Owner's guid (%s) and player's guid (%s) don't match!", item->GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str()); return; } @@ -1223,7 +1223,7 @@ void Item::SetCount(uint32 value) } } -bool Item::HasEnchantRequiredSkill(const Player* player) const +bool Item::HasEnchantRequiredSkill(Player const* player) const { // Check all enchants for required skill for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot) diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h index ddac293b715..9861459f114 100644 --- a/src/server/game/Entities/Item/Item.h +++ b/src/server/game/Entities/Item/Item.h @@ -167,6 +167,7 @@ class TC_GAME_API Item : public Object { friend void AddItemToUpdateQueueOf(Item* item, Player* player); friend void RemoveItemFromUpdateQueueOf(Item* item, Player* player); + public: static Item* CreateItem(uint32 itemEntry, uint32 count, ItemContext context, Player const* player = nullptr); Item* CloneItem(uint32 count, Player const* player = nullptr) const; @@ -250,7 +251,7 @@ class TC_GAME_API Item : public Object void SetInTrade(bool b = true) { mb_in_trade = b; } bool IsInTrade() const { return mb_in_trade; } - bool HasEnchantRequiredSkill(const Player* player) const; + bool HasEnchantRequiredSkill(Player const* player) const; uint32 GetEnchantRequiredLevel() const; bool IsFitToSpellRequirements(SpellInfo const* spellInfo) const; @@ -307,7 +308,6 @@ class TC_GAME_API Item : public Object // Update States ItemUpdateState GetState() const { return uState; } void SetState(ItemUpdateState state, Player* forplayer = nullptr); - void RemoveFromUpdateQueueOf(Player* player); bool IsInUpdateQueue() const { return uQueuePos != -1; } uint16 GetQueuePos() const { return uQueuePos; } void FSetState(ItemUpdateState state) // forced diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index dd2fb6486f5..53139520892 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -889,14 +889,14 @@ void WorldObject::setActive(bool on) if (on) { if (GetTypeId() == TYPEID_UNIT) - map->AddToActive(this->ToCreature()); + map->AddToActive(ToCreature()); else if (GetTypeId() == TYPEID_DYNAMICOBJECT) map->AddToActive((DynamicObject*)this); } else { if (GetTypeId() == TYPEID_UNIT) - map->RemoveFromActive(this->ToCreature()); + map->RemoveFromActive(ToCreature()); else if (GetTypeId() == TYPEID_DYNAMICOBJECT) map->RemoveFromActive((DynamicObject*)this); } @@ -973,7 +973,7 @@ InstanceScript* WorldObject::GetInstanceScript() const return map->IsDungeon() ? ((InstanceMap*)map)->GetInstanceScript() : nullptr; } -float WorldObject::GetDistanceZ(const WorldObject* obj) const +float WorldObject::GetDistanceZ(WorldObject const* obj) const { float dz = std::fabs(GetPositionZ() - obj->GetPositionZ()); float sizefactor = GetCombatReach() + obj->GetCombatReach(); @@ -1003,13 +1003,13 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool return thisOrTransport->IsInDist2d(objOrObjTransport, maxdist); } -float WorldObject::GetDistance(const WorldObject* obj) const +float WorldObject::GetDistance(WorldObject const* obj) const { float d = GetExactDist(obj) - GetCombatReach() - obj->GetCombatReach(); return d > 0.0f ? d : 0.0f; } -float WorldObject::GetDistance(const Position &pos) const +float WorldObject::GetDistance(Position const& pos) const { float d = GetExactDist(&pos) - GetCombatReach(); return d > 0.0f ? d : 0.0f; @@ -1021,7 +1021,7 @@ float WorldObject::GetDistance(float x, float y, float z) const return d > 0.0f ? d : 0.0f; } -float WorldObject::GetDistance2d(const WorldObject* obj) const +float WorldObject::GetDistance2d(WorldObject const* obj) const { float d = GetExactDist2d(obj) - GetCombatReach() - obj->GetCombatReach(); return d > 0.0f ? d : 0.0f; @@ -1033,14 +1033,14 @@ float WorldObject::GetDistance2d(float x, float y) const return d > 0.0f ? d : 0.0f; } -bool WorldObject::IsSelfOrInSameMap(const WorldObject* obj) const +bool WorldObject::IsSelfOrInSameMap(WorldObject const* obj) const { if (this == obj) return true; return IsInMap(obj); } -bool WorldObject::IsInMap(const WorldObject* obj) const +bool WorldObject::IsInMap(WorldObject const* obj) const { if (obj) return IsInWorld() && obj->IsInWorld() && (GetMap() == obj->GetMap()); @@ -1052,7 +1052,7 @@ bool WorldObject::IsWithinDist3d(float x, float y, float z, float dist) const return IsInDist(x, y, z, dist + GetCombatReach()); } -bool WorldObject::IsWithinDist3d(const Position* pos, float dist) const +bool WorldObject::IsWithinDist3d(Position const* pos, float dist) const { return IsInDist(pos, dist + GetCombatReach()); } @@ -1062,7 +1062,7 @@ bool WorldObject::IsWithinDist2d(float x, float y, float dist) const return IsInDist2d(x, y, dist + GetCombatReach()); } -bool WorldObject::IsWithinDist2d(const Position* pos, float dist) const +bool WorldObject::IsWithinDist2d(Position const* pos, float dist) const { return IsInDist2d(pos, dist + GetCombatReach()); } @@ -1102,7 +1102,7 @@ bool WorldObject::IsWithinLOS(float ox, float oy, float oz, LineOfSightChecks ch return true; } -bool WorldObject::IsWithinLOSInMap(const WorldObject* obj, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const +bool WorldObject::IsWithinLOSInMap(WorldObject const* obj, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const { if (!IsInMap(obj)) return false; @@ -1240,7 +1240,7 @@ bool WorldObject::isInBack(WorldObject const* target, float arc) const return !HasInArc(2 * float(M_PI) - arc, target); } -void WorldObject::GetRandomPoint(const Position &pos, float distance, float &rand_x, float &rand_y, float &rand_z) const +void WorldObject::GetRandomPoint(Position const& pos, float distance, float& rand_x, float& rand_y, float& rand_z) const { if (!distance) { @@ -1262,7 +1262,7 @@ void WorldObject::GetRandomPoint(const Position &pos, float distance, float &ran UpdateGroundPositionZ(rand_x, rand_y, rand_z); // update to LOS height if available } -Position WorldObject::GetRandomPoint(const Position &srcPos, float distance) const +Position WorldObject::GetRandomPoint(Position const& srcPos, float distance) const { float x, y, z; GetRandomPoint(srcPos, distance, x, y, z); @@ -1370,7 +1370,7 @@ float WorldObject::GetVisibilityRange() const return GetMap()->GetVisibilityRange(); } -float WorldObject::GetSightRange(const WorldObject* target) const +float WorldObject::GetSightRange(WorldObject const* target) const { if (ToUnit()) { @@ -1438,7 +1438,7 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo } WorldObject const* viewpoint = this; - if (Player const* player = this->ToPlayer()) + if (Player const* player = ToPlayer()) { viewpoint = player->GetViewpoint(); @@ -1499,7 +1499,7 @@ bool WorldObject::CanNeverSee(WorldObject const* obj) const bool WorldObject::CanDetect(WorldObject const* obj, bool ignoreStealth, bool checkAlert) const { - const WorldObject* seer = this; + WorldObject const* seer = this; // Pets don't have detection, they use the detection of their masters if (Unit const* thisUnit = ToUnit()) @@ -2058,7 +2058,7 @@ Position WorldObject::GetRandomNearPosition(float radius) return pos; } -void WorldObject::GetContactPoint(const WorldObject* obj, float &x, float &y, float &z, float distance2d /*= CONTACT_DISTANCE*/) const +void WorldObject::GetContactPoint(WorldObject const* obj, float& x, float& y, float& z, float distance2d /*= CONTACT_DISTANCE*/) const { // angle to face `obj` to `this` using distance includes size of `obj` GetNearPoint(obj, x, y, z, obj->GetCombatReach(), distance2d, GetAngle(obj)); @@ -2306,7 +2306,7 @@ struct WorldObjectChangeAccumulator if (guid.IsPlayer()) { - //Caster may be NULL if DynObj is in removelist + //Caster may be nullptr if DynObj is in removelist if (Player* caster = ObjectAccessor::FindPlayer(guid)) if (*caster->m_activePlayerData->FarsightObject == source->GetGUID()) BuildPacket(caster); diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 9ba475fce44..5fb09b5c64a 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -401,8 +401,8 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation void UpdateGroundPositionZ(float x, float y, float &z) const; void UpdateAllowedPositionZ(float x, float y, float &z) const; - void GetRandomPoint(Position const &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const; - Position GetRandomPoint(Position const &srcPos, float distance) const; + void GetRandomPoint(Position const& srcPos, float distance, float& rand_x, float& rand_y, float& rand_z) const; + Position GetRandomPoint(Position const& srcPos, float distance) const; uint32 GetInstanceId() const { return m_InstanceId; } @@ -433,7 +433,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation std::string GetNameForLocaleIdx(LocaleConstant /*locale*/) const override { return m_name; } float GetDistance(WorldObject const* obj) const; - float GetDistance(Position const &pos) const; + float GetDistance(Position const& pos) const; float GetDistance(float x, float y, float z) const; float GetDistance2d(WorldObject const* obj) const; float GetDistance2d(float x, float y) const; diff --git a/src/server/game/Entities/Object/ObjectPosSelector.cpp b/src/server/game/Entities/Object/ObjectPosSelector.cpp index 1d995cf3732..4bdae2dc636 100644 --- a/src/server/game/Entities/Object/ObjectPosSelector.cpp +++ b/src/server/game/Entities/Object/ObjectPosSelector.cpp @@ -41,7 +41,7 @@ ObjectPosSelector::UsedPosList::value_type const* ObjectPosSelector::nextUsedPos if (itr!=m_UsedPosLists[uptype].end()) ++itr; - if (itr==m_UsedPosLists[uptype].end()) + if (itr == m_UsedPosLists[uptype].end()) { if (!m_UsedPosLists[~uptype].empty()) return &*m_UsedPosLists[~uptype].rbegin(); diff --git a/src/server/game/Entities/Object/ObjectPosSelector.h b/src/server/game/Entities/Object/ObjectPosSelector.h index 9020aa680e8..42bb2dd0794 100644 --- a/src/server/game/Entities/Object/ObjectPosSelector.h +++ b/src/server/game/Entities/Object/ObjectPosSelector.h @@ -24,9 +24,9 @@ enum UsedPosType { USED_POS_PLUS, USED_POS_MINUS }; -inline UsedPosType operator ~(UsedPosType uptype) +inline UsedPosType operator~(UsedPosType uptype) { - return uptype==USED_POS_PLUS ? USED_POS_MINUS : USED_POS_PLUS; + return uptype == USED_POS_PLUS ? USED_POS_MINUS : USED_POS_PLUS; } struct TC_GAME_API ObjectPosSelector diff --git a/src/server/game/Entities/Object/Position.cpp b/src/server/game/Entities/Object/Position.cpp index a63a3da76d6..6afdb283c1b 100644 --- a/src/server/game/Entities/Object/Position.cpp +++ b/src/server/game/Entities/Object/Position.cpp @@ -23,7 +23,7 @@ #include <G3D/g3dmath.h> #include <sstream> -bool Position::operator==(Position const &a) const +bool Position::operator==(Position const& a) const { return (G3D::fuzzyEq(a.m_positionX, m_positionX) && G3D::fuzzyEq(a.m_positionY, m_positionY) && @@ -31,7 +31,7 @@ bool Position::operator==(Position const &a) const G3D::fuzzyEq(a.m_orientation, m_orientation)); } -void Position::RelocateOffset(const Position & offset) +void Position::RelocateOffset(Position const& offset) { m_positionX = GetPositionX() + (offset.GetPositionX() * std::cos(GetOrientation()) + offset.GetPositionY() * std::sin(GetOrientation() + float(M_PI))); m_positionY = GetPositionY() + (offset.GetPositionY() * std::cos(GetOrientation()) + offset.GetPositionX() * std::sin(GetOrientation())); @@ -64,7 +64,7 @@ float Position::GetExactDist(Position const* pos) const return std::sqrt(GetExactDistSq(pos)); } -void Position::GetPositionOffsetTo(const Position & endPos, Position & retOffset) const +void Position::GetPositionOffsetTo(Position const& endPos, Position& retOffset) const { float dx = endPos.GetPositionX() - GetPositionX(); float dy = endPos.GetPositionY() - GetPositionY(); @@ -120,7 +120,7 @@ void Position::GetSinCos(const float x, const float y, float &vsin, float &vcos) } } -bool Position::IsWithinBox(const Position& center, float xradius, float yradius, float zradius) const +bool Position::IsWithinBox(Position const& center, float xradius, float yradius, float zradius) const { // rotate the WorldObject position instead of rotating the whole cube, that way we can make a simplified // is-in-cube check and we have to calculate only one point instead of 4 @@ -154,7 +154,7 @@ bool Position::IsWithinDoubleVerticalCylinder(Position const* center, float radi return IsInDist2d(center, radius) && std::abs(verticalDelta) <= height; } -bool Position::HasInArc(float arc, const Position* obj, float border) const +bool Position::HasInArc(float arc, Position const* obj, float border) const { // always have self in arc if (obj == this) diff --git a/src/server/game/Entities/Object/Position.h b/src/server/game/Entities/Object/Position.h index 84342433aa0..9f2218397e9 100644 --- a/src/server/game/Entities/Object/Position.h +++ b/src/server/game/Entities/Object/Position.h @@ -35,18 +35,18 @@ struct TC_GAME_API Position struct XYZO; struct PackedXYZ; - template<class Tag> + template <class Tag> struct ConstStreamer { explicit ConstStreamer(Position const& pos) : Pos(&pos) { } Position const* Pos; }; - template<class Tag> + template <class Tag> struct Streamer { explicit Streamer(Position& pos) : Pos(&pos) { } - operator ConstStreamer<Tag>() { return ConstStreamer<Tag>(*Pos); } + operator ConstStreamer<Tag>() const { return ConstStreamer<Tag>(*Pos); } Position* Pos; }; @@ -58,9 +58,9 @@ private: float m_orientation; public: - bool operator==(Position const &a) const; + bool operator==(Position const& a) const; - inline bool operator!=(Position const &a) const + inline bool operator!=(Position const& a) const { return !(operator==(a)); } @@ -80,7 +80,7 @@ public: m_positionX = x; m_positionY = y; m_positionZ = z; SetOrientation(orientation); } - void Relocate(Position const &pos) + void Relocate(Position const& pos) { m_positionX = pos.m_positionX; m_positionY = pos.m_positionY; m_positionZ = pos.m_positionZ; SetOrientation(pos.m_orientation); } @@ -90,7 +90,7 @@ public: m_positionX = pos->m_positionX; m_positionY = pos->m_positionY; m_positionZ = pos->m_positionZ; SetOrientation(pos->m_orientation); } - void RelocateOffset(Position const &offset); + void RelocateOffset(Position const& offset); void SetOrientation(float orientation) { @@ -209,7 +209,7 @@ public: bool IsInDist(Position const& pos, float dist) const { return GetExactDistSq(pos) < dist * dist; } bool IsInDist(Position const* pos, float dist) const { return GetExactDistSq(pos) < dist * dist; } - bool IsWithinBox(const Position& center, float xradius, float yradius, float zradius) const; + bool IsWithinBox(Position const& center, float xradius, float yradius, float zradius) const; /* search using this relation: dist2d < radius && abs(dz) < height diff --git a/src/server/game/Entities/Object/Updates/UpdateData.cpp b/src/server/game/Entities/Object/Updates/UpdateData.cpp index 6ef8253c0d7..e437c28e064 100644 --- a/src/server/game/Entities/Object/Updates/UpdateData.cpp +++ b/src/server/game/Entities/Object/Updates/UpdateData.cpp @@ -37,7 +37,7 @@ void UpdateData::AddOutOfRangeGUID(ObjectGuid guid) m_outOfRangeGUIDs.insert(guid); } -void UpdateData::AddUpdateBlock(const ByteBuffer &block) +void UpdateData::AddUpdateBlock(ByteBuffer const& block) { m_data.append(block); ++m_blockCount; diff --git a/src/server/game/Entities/Object/Updates/UpdateData.h b/src/server/game/Entities/Object/Updates/UpdateData.h index fdc4bb42d7a..9b185ea14e2 100644 --- a/src/server/game/Entities/Object/Updates/UpdateData.h +++ b/src/server/game/Entities/Object/Updates/UpdateData.h @@ -46,7 +46,7 @@ class UpdateData void AddDestroyObject(ObjectGuid guid); void AddOutOfRangeGUID(GuidSet& guids); void AddOutOfRangeGUID(ObjectGuid guid); - void AddUpdateBlock(const ByteBuffer &block); + void AddUpdateBlock(ByteBuffer const& block); bool BuildPacket(WorldPacket* packet); bool HasData() const { return m_blockCount > 0 || !m_outOfRangeGUIDs.empty(); } void Clear(); diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 5c58ab5069f..7b60c7209eb 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -202,7 +202,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c return false; } - map->AddToMap(this->ToCreature()); + map->AddToMap(ToCreature()); return true; } @@ -315,7 +315,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c } owner->SetMinion(this, true); - map->AddToMap(this->ToCreature()); + map->AddToMap(ToCreature()); uint32 timediff = uint32(time(nullptr) - fields[13].GetUInt32()); _LoadAuras(timediff); @@ -1412,7 +1412,7 @@ bool Pet::learnSpell(uint32 spell_id) { WorldPackets::Pet::PetLearnedSpells packet; packet.Spells.push_back(spell_id); - GetOwner()->GetSession()->SendPacket(packet.Write()); + GetOwner()->SendDirectMessage(packet.Write()); GetOwner()->PetSpellInitialize(); } return true; @@ -1479,7 +1479,7 @@ bool Pet::unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab) { WorldPackets::Pet::PetUnlearnedSpells packet; packet.Spells.push_back(spell_id); - GetOwner()->GetSession()->SendPacket(packet.Write()); + GetOwner()->SendDirectMessage(packet.Write()); } return true; } diff --git a/src/server/game/Entities/Player/EquipementSet.h b/src/server/game/Entities/Player/EquipmentSet.h index 937446b35e2..ce9d0952e21 100644 --- a/src/server/game/Entities/Player/EquipementSet.h +++ b/src/server/game/Entities/Player/EquipmentSet.h @@ -15,8 +15,8 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef EquipementSet_h__ -#define EquipementSet_h__ +#ifndef EquipmentSet_h__ +#define EquipmentSet_h__ #include "Define.h" #include "ObjectGuid.h" @@ -31,7 +31,7 @@ enum EquipmentSetUpdateState EQUIPMENT_SET_DELETED = 3 }; -#define EQUIPEMENT_SET_SLOTS 19 +#define EQUIPMENT_SET_SLOTS 19 struct EquipmentSetInfo { @@ -51,8 +51,8 @@ struct EquipmentSetInfo int32 AssignedSpecIndex = -1; ///< Index of character specialization that this set is automatically equipped for std::string SetName; std::string SetIcon; - std::array<ObjectGuid, EQUIPEMENT_SET_SLOTS> Pieces; - std::array<int32, EQUIPEMENT_SET_SLOTS> Appearances; ///< ItemModifiedAppearanceID + std::array<ObjectGuid, EQUIPMENT_SET_SLOTS> Pieces; + std::array<int32, EQUIPMENT_SET_SLOTS> Appearances; ///< ItemModifiedAppearanceID std::array<int32, 2> Enchants; ///< SpellItemEnchantmentID } Data; @@ -64,4 +64,4 @@ struct EquipmentSetInfo typedef std::map<uint64, EquipmentSetInfo> EquipmentSetContainer; -#endif // EquipementSet_h__ +#endif // EquipmentSet_h__ diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 4d967243f15..c9525736629 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -72,8 +72,8 @@ #include "InstanceScript.h" #include "ItemPackets.h" #include "KillRewarder.h" -#include "LFGMgr.h" #include "Language.h" +#include "LFGMgr.h" #include "Log.h" #include "LootItemStorage.h" #include "LootMgr.h" @@ -127,6 +127,7 @@ #include "WorldSession.h" #include "WorldStatePackets.h" #include <G3D/g3dmath.h> +#include <sstream> #define ZONE_UPDATE_INTERVAL (1*IN_MILLISECONDS) @@ -362,7 +363,7 @@ Player::Player(WorldSession* session) : Unit(true), m_sceneMgr(this) Player::~Player() { // it must be unloaded already in PlayerLogout and accessed only for logged in player - //m_social = NULL; + //m_social = nullptr; // Note: buy back item already deleted from DB when player was saved for (uint8 i = 0; i < PLAYER_SLOTS_COUNT; ++i) @@ -686,13 +687,13 @@ void Player::SendMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 Curre return; } - GetSession()->SendPacket(WorldPackets::Misc::StartMirrorTimer(Type, CurrentValue, MaxValue, Regen, 0, false).Write()); + SendDirectMessage(WorldPackets::Misc::StartMirrorTimer(Type, CurrentValue, MaxValue, Regen, 0, false).Write()); } void Player::StopMirrorTimer(MirrorTimerType Type) { m_MirrorTimer[Type] = DISABLED_MIRROR_TIMER; - GetSession()->SendPacket(WorldPackets::Misc::StopMirrorTimer(Type).Write()); + SendDirectMessage(WorldPackets::Misc::StopMirrorTimer(Type).Write()); } bool Player::IsImmuneToEnvironmentalDamage() const @@ -817,14 +818,14 @@ void Player::HandleDrowning(uint32 time_diff) } else // If activated - do tick { - m_MirrorTimer[BREATH_TIMER]-=time_diff; + m_MirrorTimer[BREATH_TIMER] -= time_diff; // Timer limit - need deal damage if (m_MirrorTimer[BREATH_TIMER] < 0) { - m_MirrorTimer[BREATH_TIMER]+= 1*IN_MILLISECONDS; + m_MirrorTimer[BREATH_TIMER] += 1 * IN_MILLISECONDS; // Calculate and deal damage /// @todo Check this formula - uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel()-1); + uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel() - 1); EnvironmentalDamage(DAMAGE_DROWNING, damage); } else if (!(m_MirrorTimerFlagsLast & UNDERWATER_INWATER)) // Update time in client if need @@ -835,7 +836,7 @@ void Player::HandleDrowning(uint32 time_diff) { int32 UnderWaterTime = getMaxTimer(BREATH_TIMER); // Need breath regen - m_MirrorTimer[BREATH_TIMER]+=10*time_diff; + m_MirrorTimer[BREATH_TIMER] += 10 * time_diff; if (m_MirrorTimer[BREATH_TIMER] >= UnderWaterTime || !IsAlive()) StopMirrorTimer(BREATH_TIMER); else if (m_MirrorTimerFlagsLast & UNDERWATER_INWATER) @@ -853,14 +854,14 @@ void Player::HandleDrowning(uint32 time_diff) } else { - m_MirrorTimer[FATIGUE_TIMER]-=time_diff; + m_MirrorTimer[FATIGUE_TIMER] -= time_diff; // Timer limit - need deal damage or teleport ghost to graveyard if (m_MirrorTimer[FATIGUE_TIMER] < 0) { - m_MirrorTimer[FATIGUE_TIMER]+= 1*IN_MILLISECONDS; + m_MirrorTimer[FATIGUE_TIMER] += 1 * IN_MILLISECONDS; if (IsAlive()) // Calculate and deal damage { - uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel()-1); + uint32 damage = GetMaxHealth() / 5 + urand(0, getLevel() - 1); EnvironmentalDamage(DAMAGE_EXHAUSTED, damage); } else if (HasPlayerFlag(PLAYER_FLAGS_GHOST)) // Teleport ghost to graveyard @@ -873,7 +874,7 @@ void Player::HandleDrowning(uint32 time_diff) else if (m_MirrorTimer[FATIGUE_TIMER] != DISABLED_MIRROR_TIMER) // Regen timer { int32 DarkWaterTime = getMaxTimer(FATIGUE_TIMER); - m_MirrorTimer[FATIGUE_TIMER]+=10*time_diff; + m_MirrorTimer[FATIGUE_TIMER] += 10 * time_diff; if (m_MirrorTimer[FATIGUE_TIMER] >= DarkWaterTime || !IsAlive()) StopMirrorTimer(FATIGUE_TIMER); else if (m_MirrorTimerFlagsLast & UNDERWATER_INDARKWATER) @@ -890,7 +891,7 @@ void Player::HandleDrowning(uint32 time_diff) m_MirrorTimer[FIRE_TIMER] -= time_diff; if (m_MirrorTimer[FIRE_TIMER] < 0) { - m_MirrorTimer[FIRE_TIMER]+= 1*IN_MILLISECONDS; + m_MirrorTimer[FIRE_TIMER] += 1 * IN_MILLISECONDS; // Calculate and deal damage /// @todo Check this formula uint32 damage = urand(600, 700); @@ -907,13 +908,15 @@ void Player::HandleDrowning(uint32 time_diff) m_MirrorTimer[FIRE_TIMER] = DISABLED_MIRROR_TIMER; // Recheck timers flag - m_MirrorTimerFlags&=~UNDERWATER_EXIST_TIMERS; - for (uint8 i = 0; i< MAX_TIMERS; ++i) + m_MirrorTimerFlags &= ~UNDERWATER_EXIST_TIMERS; + for (uint8 i = 0; i < MAX_TIMERS; ++i) + { if (m_MirrorTimer[i] != DISABLED_MIRROR_TIMER) { - m_MirrorTimerFlags|=UNDERWATER_EXIST_TIMERS; + m_MirrorTimerFlags |= UNDERWATER_EXIST_TIMERS; break; } + } m_MirrorTimerFlagsLast = m_MirrorTimerFlags; } @@ -1577,7 +1580,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati transferPending.Ship->OriginMapID = GetMapId(); } - GetSession()->SendPacket(transferPending.Write()); + SendDirectMessage(transferPending.Write()); } // remove from old map now @@ -1608,7 +1611,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati return true; } -bool Player::TeleportTo(WorldLocation const &loc, uint32 options /*= 0*/) +bool Player::TeleportTo(WorldLocation const& loc, uint32 options /*= 0*/) { return TeleportTo(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetOrientation(), options); } @@ -2122,7 +2125,7 @@ void Player::SetInWater(bool apply) getHostileRefManager().updateThreatTables(); } -bool Player::IsInAreaTriggerRadius(const AreaTriggerEntry* trigger) const +bool Player::IsInAreaTriggerRadius(AreaTriggerEntry const* trigger) const { if (!trigger) return false; @@ -2277,7 +2280,7 @@ void Player::UninviteFromGroup() } } -void Player::RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method /* = GROUP_REMOVEMETHOD_DEFAULT*/, ObjectGuid kicker /* = ObjectGuid::Empty */, const char* reason /* = nullptr */) +void Player::RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method /* = GROUP_REMOVEMETHOD_DEFAULT*/, ObjectGuid kicker /* = ObjectGuid::Empty */, char const* reason /* = nullptr */) { if (!group) return; @@ -2336,7 +2339,7 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate) packet.Amount = xp; packet.GroupBonus = group_rate; packet.ReferAFriendBonusType = recruitAFriend ? 1 : 0; - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); uint32 curXP = m_activePlayerData->XP; uint32 nextLvlXP = m_activePlayerData->NextLevelXP; @@ -2392,7 +2395,7 @@ void Player::GiveLevel(uint8 level) packet.NumNewTalents = DB2Manager::GetNumTalentsAtLevel(level, Classes(getClass())) - DB2Manager::GetNumTalentsAtLevel(oldLevel, Classes(getClass())); packet.NumNewPvpTalentSlots = sDB2Manager.GetPvpTalentNumSlotsAtLevel(level, Classes(getClass())) - sDB2Manager.GetPvpTalentNumSlotsAtLevel(oldLevel, Classes(getClass())); - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::NextLevelXP), sObjectMgr->GetXPForLevel(level)); @@ -2698,7 +2701,7 @@ void Player::SendMailResult(uint32 mailId, MailResponseType mailAction, MailResp result.AttachID = item_guid; result.QtyInInventory = item_count; } - GetSession()->SendPacket(result.Write()); + SendDirectMessage(result.Write()); } void Player::SendNewMail() const @@ -2707,7 +2710,7 @@ void Player::SendNewMail() const WorldPackets::Mail::NotifyReceivedMail notify; notify.Delay = 0.0f; - GetSession()->SendPacket(notify.Write()); + SendDirectMessage(notify.Write()); } void Player::UpdateNextMailTimeAndUnreads() @@ -3200,7 +3203,7 @@ void Player::LearnSpell(uint32 spell_id, bool dependent, int32 fromSkill /*= 0*/ WorldPackets::Spells::LearnedSpells packet; packet.SpellID.push_back(spell_id); packet.SuppressMessaging = suppressMessaging; - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); } // learn all disabled higher ranks and required spells (recursive) @@ -3338,7 +3341,7 @@ void Player::RemoveSpell(uint32 spell_id, bool disabled /*= false*/, bool learn_ if (uint32 prev_id = sSpellMgr->GetPrevSpellInChain(spell_id)) { // if ranked non-stackable spell: need activate lesser rank and update dendence state - /// No need to check for spellInfo != NULL here because if cur_active is true, then that means that the spell was already in m_spells, and only valid spells can be pushed there. + /// No need to check for spellInfo != nullptr here because if cur_active is true, then that means that the spell was already in m_spells, and only valid spells can be pushed there. if (cur_active && spellInfo->IsRanked()) { // need manually update dependence state (learn spell ignore like attempts) @@ -3505,7 +3508,7 @@ bool Player::ResetTalents(bool noCost) if (Pet* pet = GetPet()) { if (pet->getPetType() == HUNTER_PET && !pet->GetCreatureTemplate()->IsTameable(CanTameExoticPets())) - RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true); + RemovePet(nullptr, PET_SAVE_NOT_IN_SLOT, true); } */ @@ -4267,7 +4270,7 @@ void Player::BuildPlayerRepop() { WorldPackets::Misc::PreRessurect packet; packet.PlayerGUID = GetGUID(); - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); // If the player has the Wisp racial then cast the Wisp aura on them if (HasSpell(20585)) @@ -4325,7 +4328,7 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) { WorldPackets::Misc::DeathReleaseLoc packet; packet.MapID = -1; - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); // speed change, land walk @@ -4753,13 +4756,13 @@ void Player::RepopAtGraveyard() // Special handle for battleground maps if (Battleground* bg = GetBattleground()) - ClosestGrave = bg->GetClosestGraveYard(this); + ClosestGrave = bg->GetClosestGraveyard(this); else { if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(GetZoneId())) - ClosestGrave = bf->GetClosestGraveYard(this); + ClosestGrave = bf->GetClosestGraveyard(this); else - ClosestGrave = sObjectMgr->GetClosestGraveYard(*this, GetTeam(), this); + ClosestGrave = sObjectMgr->GetClosestGraveyard(*this, GetTeam(), this); } // stop countdown until repop @@ -4775,7 +4778,7 @@ void Player::RepopAtGraveyard() WorldPackets::Misc::DeathReleaseLoc packet; packet.MapID = ClosestGrave->Loc.GetMapId(); packet.Loc = ClosestGrave->Loc; - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); } } else if (GetPositionZ() < GetMap()->GetMinHeight(GetPhaseShift(), GetPositionX(), GetPositionY())) @@ -6059,7 +6062,7 @@ bool Player::UpdatePosition(float x, float y, float z, float orientation, bool t void Player::SendMessageToSetInRange(WorldPacket const* data, float dist, bool self) const { if (self) - GetSession()->SendPacket(data); + SendDirectMessage(data); Trinity::MessageDistDeliverer notifier(this, data, dist); Cell::VisitWorldObjects(this, notifier, dist); @@ -6068,7 +6071,7 @@ void Player::SendMessageToSetInRange(WorldPacket const* data, float dist, bool s void Player::SendMessageToSetInRange(WorldPacket const* data, float dist, bool self, bool own_team_only) const { if (self) - GetSession()->SendPacket(data); + SendDirectMessage(data); Trinity::MessageDistDeliverer notifier(this, data, dist, own_team_only); Cell::VisitWorldObjects(this, notifier, dist); @@ -6077,7 +6080,7 @@ void Player::SendMessageToSetInRange(WorldPacket const* data, float dist, bool s void Player::SendMessageToSet(WorldPacket const* data, Player const* skipped_rcvr) const { if (skipped_rcvr != this) - GetSession()->SendPacket(data); + SendDirectMessage(data); // we use World::GetMaxVisibleDistance() because i cannot see why not use a distance // update: replaced by GetMap()->GetVisibilityDistance() @@ -6556,7 +6559,7 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto data.Target = victim_guid; data.Rank = victim_rank; - GetSession()->SendPacket(data.Write()); + SendDirectMessage(data.Write()); AddHonorXP(honor); @@ -6763,7 +6766,7 @@ void Player::SendNewCurrency(uint32 id) const packet.Data.push_back(record); - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); } void Player::SendCurrencies() const @@ -6790,7 +6793,7 @@ void Player::SendCurrencies() const packet.Data.push_back(record); } - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); } void Player::SendPvpRewards() const @@ -6956,7 +6959,7 @@ void Player::ModifyCurrency(uint32 id, int32 count, bool printLog/* = true*/, bo packet.Flags = itr->second.Flags; packet.QuantityChange = count; - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); } } @@ -7261,7 +7264,7 @@ void Player::CheckDuelDistance(time_t currTime) { duel->outOfBound = currTime; - GetSession()->SendPacket(WorldPackets::Duel::DuelOutOfBounds().Write()); + SendDirectMessage(WorldPackets::Duel::DuelOutOfBounds().Write()); } } else @@ -7270,7 +7273,7 @@ void Player::CheckDuelDistance(time_t currTime) { duel->outOfBound = 0; - GetSession()->SendPacket(WorldPackets::Duel::DuelInBounds().Write()); + SendDirectMessage(WorldPackets::Duel::DuelInBounds().Write()); } else if (currTime >= (duel->outOfBound+10)) DuelComplete(DUEL_FLED); @@ -7301,10 +7304,10 @@ void Player::DuelComplete(DuelCompleteType type) WorldPackets::Duel::DuelComplete duelCompleted; duelCompleted.Started = type != DUEL_INTERRUPTED; WorldPacket const* duelCompletedPacket = duelCompleted.Write(); - GetSession()->SendPacket(duelCompletedPacket); + SendDirectMessage(duelCompletedPacket); if (duel->opponent->GetSession()) - duel->opponent->GetSession()->SendPacket(duelCompletedPacket); + duel->opponent->SendDirectMessage(duelCompletedPacket); if (type != DUEL_INTERRUPTED) { @@ -9015,7 +9018,7 @@ void Player::SendNotifyLootItemRemoved(ObjectGuid lootObj, uint8 lootSlot) const packet.Owner = GetLootWorldObjectGUID(lootObj); packet.LootObj = lootObj; packet.LootListID = lootSlot + 1; - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); } void Player::SendUpdateWorldState(uint32 variable, uint32 value, bool hidden /*= false*/) const @@ -9646,7 +9649,7 @@ void Player::SendInitWorldStates(uint32 zoneid, uint32 areaid) break; } - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); SendBGWeekendWorldStates(); SendBattlefieldWorldStates(); } @@ -9694,7 +9697,7 @@ void Player::SendBattlefieldWorldStates() const void Player::SetBindPoint(ObjectGuid guid) const { WorldPackets::Misc::BinderConfirm packet(guid); - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); } void Player::SendRespecWipeConfirm(ObjectGuid const& guid, uint32 cost) const @@ -9703,7 +9706,7 @@ void Player::SendRespecWipeConfirm(ObjectGuid const& guid, uint32 cost) const respecWipeConfirm.RespecMaster = guid; respecWipeConfirm.Cost = cost; respecWipeConfirm.RespecType = SPEC_RESET_TALENTS; - GetSession()->SendPacket(respecWipeConfirm.Write()); + SendDirectMessage(respecWipeConfirm.Write()); } /*********************************************************/ @@ -12316,7 +12319,7 @@ Item* Player::EquipItem(uint16 pos, Item* pItem, bool update) spellCooldown.Caster = GetGUID(); spellCooldown.Flags = SPELL_COOLDOWN_FLAG_INCLUDE_GCD; spellCooldown.SpellCooldowns.emplace_back(cooldownSpell, 0); - GetSession()->SendPacket(spellCooldown.Write()); + SendDirectMessage(spellCooldown.Write()); } } } @@ -13856,7 +13859,7 @@ void Player::SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 packet.VendorGUID = creature ? creature->GetGUID() : ObjectGuid::Empty; packet.Muid = item; packet.Reason = msg; - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); } void Player::SendSellError(SellResult msg, Creature* creature, ObjectGuid guid) const @@ -13865,7 +13868,7 @@ void Player::SendSellError(SellResult msg, Creature* creature, ObjectGuid guid) sellResponse.VendorGUID = (creature ? creature->GetGUID() : ObjectGuid::Empty); sellResponse.ItemGUID = guid; sellResponse.Reason = msg; - GetSession()->SendPacket(sellResponse.Write()); + SendDirectMessage(sellResponse.Write()); } bool Player::IsUseEquipedWeapon(bool mainhand) const @@ -13989,7 +13992,7 @@ void Player::UpdateItemDuration(uint32 time, bool realtimeonly) void Player::UpdateEnchantTime(uint32 time) { - for (EnchantDurationList::iterator itr = m_enchantDuration.begin(), next; itr != m_enchantDuration.end(); itr=next) + for (EnchantDurationList::iterator itr = m_enchantDuration.begin(), next; itr != m_enchantDuration.end(); itr = next) { ASSERT(itr->item); next = itr; @@ -14575,7 +14578,7 @@ void Player::SendNewItem(Item* item, uint32 quantity, bool pushed, bool created, if (broadcast && GetGroup()) GetGroup()->BroadcastPacket(packet.Write(), true); else - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); } /*********************************************************/ @@ -15998,7 +16001,7 @@ bool Player::SatisfyQuestLog(bool msg) const if (msg) { WorldPackets::Quest::QuestLogFull data; - GetSession()->SendPacket(data.Write()); + SendDirectMessage(data.Write()); } return false; } @@ -17438,7 +17441,7 @@ void Player::SendQuestComplete(Quest const* quest) const { WorldPackets::Quest::QuestUpdateComplete data; data.QuestID = quest->GetQuestId(); - GetSession()->SendPacket(data.Write()); + SendDirectMessage(data.Write()); } } @@ -17479,7 +17482,7 @@ void Player::SendQuestReward(Quest const* quest, Creature const* questGiver, uin packet.HideChatMessage = hideChatMessage; - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); } void Player::SendQuestFailed(uint32 questID, InventoryResult reason) const @@ -17489,7 +17492,7 @@ void Player::SendQuestFailed(uint32 questID, InventoryResult reason) const WorldPackets::Quest::QuestGiverQuestFailed questGiverQuestFailed; questGiverQuestFailed.QuestID = questID; questGiverQuestFailed.Reason = reason; // failed reason (valid reasons: 4, 16, 50, 17, other values show default message) - GetSession()->SendPacket(questGiverQuestFailed.Write()); + SendDirectMessage(questGiverQuestFailed.Write()); } } @@ -17499,7 +17502,7 @@ void Player::SendQuestTimerFailed(uint32 questID) const { WorldPackets::Quest::QuestUpdateFailedTimer questUpdateFailedTimer; questUpdateFailedTimer.QuestID = questID; - GetSession()->SendPacket(questUpdateFailedTimer.Write()); + SendDirectMessage(questUpdateFailedTimer.Write()); } } @@ -17511,7 +17514,7 @@ void Player::SendCanTakeQuestResponse(QuestFailedReason reason, bool sendErrorMe questGiverInvalidQuest.SendErrorMessage = sendErrorMessage; questGiverInvalidQuest.ReasonText = reasonText; - GetSession()->SendPacket(questGiverInvalidQuest.Write()); + SendDirectMessage(questGiverInvalidQuest.Write()); } void Player::SendQuestConfirmAccept(Quest const* quest, Player* receiver) const @@ -17532,7 +17535,7 @@ void Player::SendQuestConfirmAccept(Quest const* quest, Player* receiver) const packet.QuestID = questID; packet.InitiatedBy = GetGUID(); - receiver->GetSession()->SendPacket(packet.Write()); + receiver->SendDirectMessage(packet.Write()); } void Player::SendPushToPartyResponse(Player const* player, QuestPushReason reason) const @@ -17555,7 +17558,7 @@ void Player::SendQuestUpdateAddCredit(Quest const* quest, ObjectGuid guid, Quest packet.Count = count; packet.Required = obj.Amount; packet.ObjectiveType = obj.Type; - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); } void Player::SendQuestUpdateAddCreditSimple(QuestObjective const& obj) const @@ -17572,7 +17575,7 @@ void Player::SendQuestUpdateAddPlayer(Quest const* quest, uint16 newCount) const WorldPackets::Quest::QuestUpdateAddPvPCredit questUpdateAddPvpCredit; questUpdateAddPvpCredit.QuestID = quest->GetQuestId(); questUpdateAddPvpCredit.Count = newCount; - GetSession()->SendPacket(questUpdateAddPvpCredit.Write()); + SendDirectMessage(questUpdateAddPvpCredit.Write()); } void Player::SendQuestGiverStatusMultiple() @@ -17602,7 +17605,7 @@ void Player::SendQuestGiverStatusMultiple() } } - GetSession()->SendPacket(response.Write()); + SendDirectMessage(response.Write()); } bool Player::HasPvPForcingQuest() const @@ -17710,8 +17713,7 @@ void Player::_LoadEquipmentSets(PreparedQueryResult result) continue; _equipmentSets[eqSet.Data.Guid] = eqSet; - } - while (result->NextRow()); + } while (result->NextRow()); } void Player::_LoadTransmogOutfits(PreparedQueryResult result) @@ -18644,7 +18646,7 @@ bool Player::isAllowedToLoot(const Creature* creature) const if (HasPendingBind()) return false; - const Loot* loot = &creature->loot; + Loot const* loot = &creature->loot; if (loot->isLooted()) // nothing to loot or everything looted. return false; if (!loot->hasItemForAll() && !loot->hasItemFor(this)) // no loot in creature for this player @@ -19964,12 +19966,12 @@ InstancePlayerBind* Player::BindToInstance(InstanceSave* save, bool permanent, B void Player::BindToInstance() { InstanceSave* mapSave = sInstanceSaveMgr->GetInstanceSave(_pendingBindId); - if (!mapSave) //it seems sometimes mapSave is NULL, but I did not check why + if (!mapSave) //it seems sometimes mapSave is nullptr, but I did not check why return; WorldPackets::Instance::InstanceSaveCreated data; data.Gm = IsGameMaster(); - GetSession()->SendPacket(data.Write()); + SendDirectMessage(data.Write()); if (!IsGameMaster()) { BindToInstance(mapSave, true, EXTEND_STATE_KEEP); @@ -20021,7 +20023,7 @@ void Player::SendRaidInfo() } } - GetSession()->SendPacket(instanceInfo.Write()); + SendDirectMessage(instanceInfo.Write()); } bool Player::Satisfy(AccessRequirement const* ar, uint32 target_map, bool report) @@ -21457,28 +21459,28 @@ void Player::SetUInt32ValueInArray(Tokenizer& Tokenizer, uint16 index, uint32 va void Player::SendAttackSwingDeadTarget() const { - GetSession()->SendPacket(WorldPackets::Combat::AttackSwingError(WorldPackets::Combat::AttackSwingError::DeadTarget).Write()); + SendDirectMessage(WorldPackets::Combat::AttackSwingError(WorldPackets::Combat::AttackSwingError::DeadTarget).Write()); } void Player::SendAttackSwingCantAttack() const { - GetSession()->SendPacket(WorldPackets::Combat::AttackSwingError(WorldPackets::Combat::AttackSwingError::CantAttack).Write()); + SendDirectMessage(WorldPackets::Combat::AttackSwingError(WorldPackets::Combat::AttackSwingError::CantAttack).Write()); } void Player::SendAttackSwingNotInRange() const { - GetSession()->SendPacket(WorldPackets::Combat::AttackSwingError(WorldPackets::Combat::AttackSwingError::NotInRange).Write()); + SendDirectMessage(WorldPackets::Combat::AttackSwingError(WorldPackets::Combat::AttackSwingError::NotInRange).Write()); } void Player::SendAttackSwingBadFacingAttack() const { - GetSession()->SendPacket(WorldPackets::Combat::AttackSwingError(WorldPackets::Combat::AttackSwingError::BadFacing).Write()); + SendDirectMessage(WorldPackets::Combat::AttackSwingError(WorldPackets::Combat::AttackSwingError::BadFacing).Write()); } void Player::SendAttackSwingCancelAttack() const { WorldPackets::Combat::CancelCombat packet; - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); } void Player::SendAutoRepeatCancel(Unit* target) @@ -21490,14 +21492,14 @@ void Player::SendAutoRepeatCancel(Unit* target) void Player::SendExplorationExperience(uint32 Area, uint32 Experience) const { - GetSession()->SendPacket(WorldPackets::Misc::ExplorationExperience(Experience, Area).Write()); + SendDirectMessage(WorldPackets::Misc::ExplorationExperience(Experience, Area).Write()); } void Player::SendDungeonDifficulty(int32 forcedDifficulty /*= -1*/) const { WorldPackets::Misc::DungeonDifficultySet dungeonDifficultySet; dungeonDifficultySet.DifficultyID = forcedDifficulty == -1 ? GetDungeonDifficultyID() : forcedDifficulty; - GetSession()->SendPacket(dungeonDifficultySet.Write()); + SendDirectMessage(dungeonDifficultySet.Write()); } void Player::SendRaidDifficulty(bool legacy, int32 forcedDifficulty /*= -1*/) const @@ -21505,13 +21507,13 @@ void Player::SendRaidDifficulty(bool legacy, int32 forcedDifficulty /*= -1*/) co WorldPackets::Misc::RaidDifficultySet raidDifficultySet; raidDifficultySet.DifficultyID = forcedDifficulty == -1 ? (legacy ? GetLegacyRaidDifficultyID() : GetRaidDifficultyID()) : forcedDifficulty; raidDifficultySet.Legacy = legacy; - GetSession()->SendPacket(raidDifficultySet.Write()); + SendDirectMessage(raidDifficultySet.Write()); } void Player::SendResetFailedNotify(uint32 /*mapid*/) const { WorldPackets::Instance::ResetFailedNotify data; - GetSession()->SendPacket(data.Write()); + SendDirectMessage(data.Write()); } /// Reset all solo instances and optionally send a message on success for each @@ -21536,7 +21538,7 @@ void Player::ResetInstances(uint8 method, bool isRaid, bool isLegacy) for (auto itr = difficultyItr->second.begin(); itr != difficultyItr->second.end();) { InstanceSave* p = itr->second.save; - const MapEntry* entry = sMapStore.LookupEntry(itr->first); + MapEntry const* entry = sMapStore.LookupEntry(itr->first); if (!entry || entry->IsRaid() != isRaid || !p->CanReset()) { ++itr; @@ -21578,7 +21580,7 @@ void Player::SendResetInstanceSuccess(uint32 MapId) const { WorldPackets::Instance::InstanceReset data; data.MapID = MapId; - GetSession()->SendPacket(data.Write()); + SendDirectMessage(data.Write()); } void Player::SendResetInstanceFailed(ResetFailedReason reason, uint32 mapID) const @@ -21592,7 +21594,7 @@ void Player::SendResetInstanceFailed(ResetFailedReason reason, uint32 mapID) con WorldPackets::Instance::InstanceResetFailed data; data.MapID = mapID; data.ResetFailedReason = reason; - GetSession()->SendPacket(data.Write()); + SendDirectMessage(data.Write()); } /*********************************************************/ @@ -21773,7 +21775,7 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent) if (pet->isControlled()) { WorldPackets::Pet::PetSpells petSpellsPacket; - GetSession()->SendPacket(petSpellsPacket.Write()); + SendDirectMessage(petSpellsPacket.Write()); if (GetGroup()) SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET); @@ -21955,7 +21957,7 @@ bool Player::RemoveMItem(ObjectGuid::LowType id) void Player::SendOnCancelExpectedVehicleRideAura() const { - GetSession()->SendPacket(WorldPackets::Vehicle::OnCancelExpectedRideVehicleAura().Write()); + SendDirectMessage(WorldPackets::Vehicle::OnCancelExpectedRideVehicleAura().Write()); } void Player::PetSpellInitialize() @@ -21994,7 +21996,7 @@ void Player::PetSpellInitialize() // Cooldowns pet->GetSpellHistory()->WritePacket(&petSpellsPacket); - GetSession()->SendPacket(petSpellsPacket.Write()); + SendDirectMessage(petSpellsPacket.Write()); } void Player::PossessSpellInitialize() @@ -22020,7 +22022,7 @@ void Player::PossessSpellInitialize() // Cooldowns charm->GetSpellHistory()->WritePacket(&petSpellsPacket); - GetSession()->SendPacket(petSpellsPacket.Write()); + SendDirectMessage(petSpellsPacket.Write()); } void Player::VehicleSpellInitialize() @@ -22064,7 +22066,7 @@ void Player::VehicleSpellInitialize() // Cooldowns vehicle->GetSpellHistory()->WritePacket(&petSpells); - GetSession()->SendPacket(petSpells.Write()); + SendDirectMessage(petSpells.Write()); } void Player::CharmSpellInitialize() @@ -22104,13 +22106,13 @@ void Player::CharmSpellInitialize() if (charm->GetTypeId() != TYPEID_PLAYER) charm->GetSpellHistory()->WritePacket(&petSpells); - GetSession()->SendPacket(petSpells.Write()); + SendDirectMessage(petSpells.Write()); } void Player::SendRemoveControlBar() const { WorldPackets::Pet::PetSpells packet; - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); } bool Player::IsAffectedBySpellmod(SpellInfo const* spellInfo, SpellModifier* mod, Spell* spell) @@ -22754,7 +22756,7 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c packet.Muid = vendorslot + 1; packet.NewQuantity = crItem->maxcount > 0 ? new_count : 0xFFFFFFFF; packet.QuantityBought = count; - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); SendNewItem(it, count, true, false, false); @@ -23481,7 +23483,7 @@ void Player::SetBattlegroundEntryPoint() // If map is dungeon find linked graveyard if (GetMap()->IsDungeon()) { - if (WorldSafeLocsEntry const* entry = sObjectMgr->GetClosestGraveYard(*this, GetTeam(), this)) + if (WorldSafeLocsEntry const* entry = sObjectMgr->GetClosestGraveyard(*this, GetTeam(), this)) m_bgData.joinPos.WorldRelocate(entry->Loc.GetMapId(), entry->Loc.GetPositionX(), entry->Loc.GetPositionY(), entry->Loc.GetPositionZ()); else TC_LOG_ERROR("entities.player", "Player::SetBattlegroundEntryPoint: Dungeon (MapID: %u) has no linked graveyard, setting home location as entry point.", GetMapId()); @@ -23633,7 +23635,7 @@ bool Player::IsAlwaysDetectableFor(WorldObject const* seer) const if (Unit::IsAlwaysDetectableFor(seer)) return true; - if (const Player* seerPlayer = seer->ToPlayer()) + if (Player const* seerPlayer = seer->ToPlayer()) if (IsGroupVisibleFor(seerPlayer)) return !(seerPlayer->duel && seerPlayer->duel->startTime != 0 && seerPlayer->duel->opponent == this); @@ -23776,7 +23778,7 @@ void Player::UpdateTriggerVisibility() return; udata.BuildPacket(&packet); - GetSession()->SendPacket(&packet); + SendDirectMessage(&packet); } void Player::SendInitialVisiblePackets(Unit* target) const @@ -24202,7 +24204,7 @@ void Player::SendTransferAborted(uint32 mapid, TransferAbortReason reason, uint8 transferAborted.MapID = mapid; transferAborted.Arg = arg; transferAborted.TransfertAbort = reason; - GetSession()->SendPacket(transferAborted.Write()); + SendDirectMessage(transferAborted.Write()); } void Player::SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time, bool welcome) const @@ -24229,7 +24231,7 @@ void Player::SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint3 else raidInstanceMessage.Locked = false; raidInstanceMessage.Extended = false; - GetSession()->SendPacket(raidInstanceMessage.Write()); + SendDirectMessage(raidInstanceMessage.Write()); } void Player::ApplyEquipCooldown(Item* pItem) @@ -24267,7 +24269,7 @@ void Player::ApplyEquipCooldown(Item* pItem) data.ItemGuid = pItem->GetGUID(); data.SpellID = effectData->SpellID; data.Cooldown = 30 * IN_MILLISECONDS; // Always 30secs? - GetSession()->SendPacket(data.Write()); + SendDirectMessage(data.Write()); } } @@ -24549,7 +24551,7 @@ void Player::SendAurasForTarget(Unit* target) const update.Auras.push_back(auraInfo); } - GetSession()->SendPacket(update.Write()); + SendDirectMessage(update.Write()); } void Player::SetDailyQuestStatus(uint32 quest_id) @@ -24954,7 +24956,7 @@ void Player::UpdateForQuestWorldObjects() } } udata.BuildPacket(&packet); - GetSession()->SendPacket(&packet); + SendDirectMessage(&packet); } bool Player::HasSummonPending() const @@ -24982,7 +24984,7 @@ void Player::SendSummonRequestFrom(Unit* summoner) summonRequest.SummonerGUID = summoner->GetGUID(); summonRequest.SummonerVirtualRealmAddress = GetVirtualRealmAddress(); summonRequest.AreaID = summoner->GetZoneId(); - GetSession()->SendPacket(summonRequest.Write()); + SendDirectMessage(summonRequest.Write()); } void Player::SummonIfPossible(bool agree) @@ -25235,7 +25237,7 @@ bool Player::GetsRecruitAFriendBonus(bool forXP) bool recruitAFriend = false; if (getLevel() <= sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL) || !forXP) { - if (Group* group = this->GetGroup()) + if (Group* group = GetGroup()) { for (GroupReference* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next()) { @@ -25309,7 +25311,7 @@ bool Player::IsAtGroupRewardDistance(WorldObject const* pRewardSource) const if (!pRewardSource || !IsInMap(pRewardSource)) return false; - const WorldObject* player = GetCorpse(); + WorldObject const* player = GetCorpse(); if (!player || IsAlive()) player = this; @@ -25324,7 +25326,7 @@ bool Player::IsAtRecruitAFriendDistance(WorldObject const* pOther) const if (!pOther || !IsInMap(pOther)) return false; - const WorldObject* player = GetCorpse(); + WorldObject const* player = GetCorpse(); if (!player || IsAlive()) player = this; @@ -25374,7 +25376,7 @@ void Player::SetClientControl(Unit* target, bool allowMove) WorldPackets::Movement::ControlUpdate data; data.Guid = target->GetGUID(); data.On = allowMove; - GetSession()->SendPacket(data.Write()); + SendDirectMessage(data.Write()); if (this != target) SetViewpoint(target, allowMove); @@ -25510,7 +25512,7 @@ void Player::SendCorpseReclaimDelay(uint32 delay) const { WorldPackets::Misc::CorpseReclaimDelay packet; packet.Remaining = delay; - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); } Player* Player::GetNextRandomRaidMember(float radius) @@ -25793,7 +25795,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply) SetSeer(this); //WorldPacket data(SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, 0); - //GetSession()->SendPacket(&data); + //SendDirectMessage(&data); } } @@ -25931,7 +25933,7 @@ void Player::SetTitle(CharTitlesEntry const* title, bool lost) WorldPackets::Character::TitleEarned packet(lost ? SMSG_TITLE_LOST : SMSG_TITLE_EARNED); packet.Index = title->MaskID; - GetSession()->SendPacket(packet.Write()); + SendDirectMessage(packet.Write()); } uint8 Player::GetRunesState() const @@ -25999,7 +26001,7 @@ void Player::ResyncRunes() const for (uint32 i = 0; i < maxRunes; ++i) data.Runes.Cooldowns.push_back(uint8((baseCd - float(GetRuneCooldown(i))) / baseCd * 255)); - GetSession()->SendPacket(data.Write()); + SendDirectMessage(data.Write()); } void Player::InitRunes() @@ -27087,7 +27089,7 @@ void Player::ResetMap() // after decrement+unlink, ++m_mapRefIter will continue correctly // when the first element of the list is being removed // nocheck_prev will return the padding element of the RefManager - // instead of NULL in the case of prev + // instead of nullptr in the case of prev GetMap()->UpdateIteratorBack(this); Unit::ResetMap(); GetMapRef().unlink(); @@ -27251,7 +27253,7 @@ void Player::ActivateTalentGroup(ChrSpecializationEntry const* spec) if (GetPet()) GetPet()->RemoveAllAurasOnDeath();*/ - //RemoveAllAuras(GetGUID(), NULL, false, true); // removes too many auras + //RemoveAllAuras(GetGUID(), nullptr, false, true); // removes too many auras //ExitVehicle(); // should be impossible to switch specs from inside a vehicle.. // Let client clear his current Actions @@ -27536,7 +27538,7 @@ void Player::SendRefundInfo(Item* item) setItemPurchaseData.Contents.Currencies[i].CurrencyID = iece->CurrencyID[i]; } - GetSession()->SendPacket(setItemPurchaseData.Write()); + SendDirectMessage(setItemPurchaseData.Write()); } bool Player::AddItem(uint32 itemId, uint32 count) @@ -27587,7 +27589,7 @@ void Player::SendItemRefundResult(Item* item, ItemExtendedCostEntry const* iece, } } - GetSession()->SendPacket(itemPurchaseRefundResult.Write()); + SendDirectMessage(itemPurchaseRefundResult.Write()); } void Player::RefundItem(Item* item) @@ -28276,7 +28278,7 @@ void Player::SendSupercededSpell(uint32 oldSpell, uint32 newSpell) const WorldPackets::Spells::SupercededSpells supercededSpells; supercededSpells.SpellID.push_back(newSpell); supercededSpells.Superceded.push_back(oldSpell); - GetSession()->SendPacket(supercededSpells.Write()); + SendDirectMessage(supercededSpells.Write()); } Difficulty Player::GetDifficultyID(MapEntry const* mapEntry) const @@ -28582,7 +28584,7 @@ void Player::SendRaidGroupOnlyMessage(RaidGroupReason reason, int32 delay) const raidGroupOnly.Delay = delay; raidGroupOnly.Reason = reason; - GetSession()->SendPacket(raidGroupOnly.Write()); + SendDirectMessage(raidGroupOnly.Write()); } uint32 Player::DoRandomRoll(uint32 minimum, uint32 maximum) diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 6f8005ca42a..3b69f04b319 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -22,7 +22,7 @@ #include "CUFProfile.h" #include "DatabaseEnvFwd.h" #include "DBCEnums.h" -#include "EquipementSet.h" +#include "EquipmentSet.h" #include "GroupReference.h" #include "ItemDefines.h" #include "ItemEnchantmentMgr.h" @@ -1013,7 +1013,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> void SetObjectScale(float scale) override; bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0); - bool TeleportTo(WorldLocation const &loc, uint32 options = 0); + bool TeleportTo(WorldLocation const& loc, uint32 options = 0); bool TeleportToBGEntryPoint(); bool HasSummonPending() const; @@ -1030,7 +1030,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> bool IsInWater() const override { return m_isInWater; } bool IsUnderWater() const override; - bool IsInAreaTriggerRadius(const AreaTriggerEntry* trigger) const; + bool IsInAreaTriggerRadius(AreaTriggerEntry const* trigger) const; void SendInitialPacketsBeforeAddToMap(); void SendInitialPacketsAfterAddToMap(); @@ -1695,7 +1695,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> PvPInfo pvpInfo; void UpdatePvPState(bool onlyFFA = false); void SetPvP(bool state) override; - void UpdatePvP(bool state, bool override=false); + void UpdatePvP(bool state, bool override = false); void UpdateZone(uint32 newZone, uint32 newArea); void UpdateArea(uint32 newArea); void UpdateZoneDependentAuras(uint32 zone_id); // zones @@ -1720,7 +1720,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> bool IsInSameGroupWith(Player const* p) const; bool IsInSameRaidWith(Player const* p) const; void UninviteFromGroup(); - static void RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker = ObjectGuid::Empty, const char* reason = nullptr); + static void RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker = ObjectGuid::Empty, char const* reason = nullptr); void RemoveFromGroup(RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT) { RemoveFromGroup(GetGroup(), GetGUID(), method); } void SendUpdateToOutOfRangeGroupMembers(); @@ -1863,7 +1863,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> void SendResetFailedNotify(uint32 mapid) const; bool UpdatePosition(float x, float y, float z, float orientation, bool teleport = false) override; - bool UpdatePosition(const Position &pos, bool teleport = false) override { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); } + bool UpdatePosition(Position const& pos, bool teleport = false) override { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); } void ProcessTerrainStatusUpdate(ZLiquidStatus status, Optional<LiquidData> const& liquidData) override; void SendMessageToSet(WorldPacket const* data, bool self) const override { SendMessageToSetInRange(data, GetVisibilityRange(), self); } @@ -2314,7 +2314,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> void SetMap(Map* map) override; void ResetMap() override; - bool isAllowedToLoot(const Creature* creature) const; + bool isAllowedToLoot(Creature const* creature) const; DeclinedName const* GetDeclinedNames() const { return m_declinedname; } uint8 GetRunesState() const; diff --git a/src/server/game/Entities/Player/PlayerTaxi.h b/src/server/game/Entities/Player/PlayerTaxi.h index 1f8850d5578..fd962967f8b 100644 --- a/src/server/game/Entities/Player/PlayerTaxi.h +++ b/src/server/game/Entities/Player/PlayerTaxi.h @@ -15,14 +15,14 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef __PLAYERTAXI_H__ -#define __PLAYERTAXI_H__ +#ifndef PlayerTaxi_h__ +#define PlayerTaxi_h__ #include "DBCEnums.h" #include "Define.h" #include <deque> #include <iosfwd> -#include <vector> +#include <string> struct FactionTemplateEntry; namespace WorldPackets @@ -69,7 +69,6 @@ class TC_GAME_API PlayerTaxi void ClearTaxiDestinations() { m_TaxiDestinations.clear(); } void AddTaxiDestination(uint32 dest) { m_TaxiDestinations.push_back(dest); } - void SetTaxiDestination(std::vector<uint32>& nodes) { m_TaxiDestinations.clear(); m_TaxiDestinations.insert(m_TaxiDestinations.begin(), nodes.begin(), nodes.end()); } uint32 GetTaxiSource() const { return m_TaxiDestinations.empty() ? 0 : m_TaxiDestinations.front(); } uint32 GetTaxiDestination() const { return m_TaxiDestinations.size() < 2 ? 0 : m_TaxiDestinations[1]; } uint32 GetCurrentTaxiPath() const; @@ -93,4 +92,4 @@ class TC_GAME_API PlayerTaxi std::ostringstream& operator <<(std::ostringstream& ss, PlayerTaxi const& taxi); -#endif +#endif // PlayerTaxi_h__ diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index ac86632924b..7da7282d6f9 100644 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -20,7 +20,6 @@ #include "Item.h" #include "Player.h" #include "Pet.h" -#include "Creature.h" #include "GameTables.h" #include "ObjectMgr.h" #include "SharedDefines.h" diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 2ea4ee71237..9aeb1397b6f 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -79,6 +79,7 @@ #include "World.h" #include "WorldPacket.h" #include "WorldSession.h" +#include <sstream> #include <cmath> float baseMoveSpeed[MAX_MOVE_TYPE] = @@ -107,6 +108,13 @@ float playerBaseMoveSpeed[MAX_MOVE_TYPE] = 3.14f // MOVE_PITCH_RATE }; +DispelableAura::DispelableAura(Aura* aura, int32 dispelChance, uint8 dispelCharges) : + _aura(aura), _chance(dispelChance), _charges(dispelCharges) +{ +} + +DispelableAura::~DispelableAura() = default; + bool DispelableAura::RollDispel() const { return roll_chance_i(_chance); @@ -292,7 +300,7 @@ Unit::Unit(bool isWorldObject) : m_ControlledByPlayer(false), movespline(new Movement::MoveSpline()), i_AI(nullptr), i_disabledAI(nullptr), m_AutoRepeatFirstCast(false), m_procDeep(0), m_removedAurasCount(0), i_motionMaster(new MotionMaster(this)), m_regenTimer(0), m_ThreatManager(this), - m_vehicle(nullptr), m_vehicleKit(nullptr), m_unitTypeMask(UNIT_MASK_NONE), + m_vehicle(nullptr), m_vehicleKit(nullptr), m_unitTypeMask(UNIT_MASK_NONE), m_Diminishing(), m_HostileRefManager(this), _aiAnimKitId(0), _movementAnimKitId(0), _meleeAnimKitId(0), _spellHistory(new SpellHistory(this)) { @@ -578,7 +586,7 @@ void Unit::resetAttackTimer(WeaponAttackType type) m_attackTimer[type] = uint32(GetBaseAttackTime(type) * m_modAttackSpeedPct[type]); } -bool Unit::IsWithinCombatRange(const Unit* obj, float dist2compare) const +bool Unit::IsWithinCombatRange(Unit const* obj, float dist2compare) const { if (!obj || !IsInMap(obj) || !IsInPhase(obj)) return false; @@ -625,7 +633,7 @@ bool Unit::IsWithinBoundaryRadius(const Unit* obj) const return IsInDist(obj, objBoundaryRadius); } -void Unit::GetRandomContactPoint(const Unit* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax) const +void Unit::GetRandomContactPoint(Unit const* obj, float &x, float &y, float &z, float distance2dMin, float distance2dMax) const { float combat_reach = GetCombatReach(); if (combat_reach < 0.1f) // sometimes bugged for players @@ -935,7 +943,7 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam ASSERT(he && he->duel); - if (duel_wasMounted) // In this case victim==mount + if (duel_wasMounted) // In this case victim == mount victim->SetHealth(1); else he->SetHealth(1); @@ -1569,6 +1577,7 @@ bool Unit::IsDamageReducedByArmor(SpellSchoolMask schoolMask, SpellInfo const* s if (spellInfo->HasAttribute(SPELL_ATTR0_CU_IGNORE_ARMOR)) return false; + // bleeding effects are not reduced by armor if (effIndex != -1) { // bleeding effects are not reduced by armor @@ -2898,7 +2907,7 @@ void Unit::_UpdateSpells(uint32 time) void Unit::_UpdateAutoRepeatSpell() { - const SpellInfo* autoRepeatSpellInfo = m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo; + SpellInfo const* autoRepeatSpellInfo = m_currentSpells[CURRENT_AUTOREPEAT_SPELL]->m_spellInfo; // check "realtime" interrupts // don't cancel spells which are affected by a SPELL_AURA_CAST_WHILE_WALKING effect @@ -9333,8 +9342,8 @@ void Unit::ApplyDiminishingAura(DiminishingGroup group, bool apply) void Unit::ClearDiminishings() { - for (uint32 i = 0; i < DIMINISHING_MAX; ++i) - m_Diminishing[i].Clear(); + for (DiminishingReturn& dim : m_Diminishing) + dim.Clear(); } float Unit::GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const @@ -10682,13 +10691,13 @@ void Unit::SendPetAIReaction(ObjectGuid guid) owner->ToPlayer()->SendDirectMessage(packet.Write()); } +///----------End of Pet responses methods---------- + void Unit::PropagateSpeedChange() { GetMotionMaster()->PropagateSpeedChange(); } -///----------End of Pet responses methods---------- - void Unit::StopMoving() { ClearUnitState(UNIT_STATE_MOVING); @@ -10748,7 +10757,7 @@ void Unit::SetStandState(UnitStandStateType state, uint32 animKitID /* = 0*/) if (GetTypeId() == TYPEID_PLAYER) { WorldPackets::Misc::StandStateUpdate packet(state, animKitID); - ToPlayer()->GetSession()->SendPacket(packet.Write()); + ToPlayer()->SendDirectMessage(packet.Write()); } } @@ -12143,7 +12152,7 @@ void Unit::RemoveVehicleKit(bool onRemoveFromWorld /*= false*/) RemoveNpcFlag(NPCFlags(UNIT_NPC_FLAG_SPELLCLICK | UNIT_NPC_FLAG_PLAYER_VEHICLE)); } -bool Unit::IsOnVehicle(const Unit* vehicle) const +bool Unit::IsOnVehicle(Unit const* vehicle) const { return m_vehicle && m_vehicle == vehicle->GetVehicleKit(); } @@ -13397,7 +13406,7 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel return (relocated || turn); } -bool Unit::UpdatePosition(const Position &pos, bool teleport) +bool Unit::UpdatePosition(Position const& pos, bool teleport) { return UpdatePosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teleport); } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 82297d25d92..9c5cdc8fb6a 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -23,13 +23,13 @@ #include "FollowerReference.h" #include "FollowerRefManager.h" #include "HostileRefManager.h" +#include "OptionalFwd.h" #include "SpellAuraDefines.h" #include "ThreatManager.h" #include "Timer.h" #include "UnitDefines.h" #include "Util.h" #include <boost/container/flat_set.hpp> -#include <algorithm> #include <array> #include <map> @@ -235,8 +235,8 @@ typedef std::list<Unit*> UnitList; class DispelableAura { public: - DispelableAura(Aura* aura, int32 dispelChance, uint8 dispelCharges) : - _aura(aura), _chance(dispelChance), _charges(dispelCharges) { } + DispelableAura(Aura* aura, int32 dispelChance, uint8 dispelCharges); + ~DispelableAura(); Aura* GetAura() const { return _aura; } bool RollDispel() const; @@ -973,7 +973,7 @@ class TC_GAME_API Unit : public WorldObject void SetCombatReach(float combatReach) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::CombatReach), combatReach); } float GetBoundingRadius() const { return m_unitData->BoundingRadius; } void SetBoundingRadius(float boundingRadius) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::BoundingRadius), boundingRadius); } - bool IsWithinCombatRange(const Unit* obj, float dist2compare) const; + bool IsWithinCombatRange(Unit const* obj, float dist2compare) const; bool IsWithinMeleeRange(Unit const* obj) const; float GetMeleeRange(Unit const* target) const; virtual SpellSchoolMask GetMeleeDamageSchoolMask() const; @@ -1334,7 +1334,7 @@ class TC_GAME_API Unit : public WorldObject void CastCustomSpell(Unit* victim, uint32 spellId, int32 const* bp0, int32 const* bp1, int32 const* bp2, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty); void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim, bool triggered, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty); void CastCustomSpell(uint32 spellId, SpellValueMod mod, int32 value, Unit* victim = nullptr, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty); - void CastCustomSpell(uint32 spellId, CustomSpellValues const &value, Unit* victim = nullptr, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty); + void CastCustomSpell(uint32 spellId, CustomSpellValues const& value, Unit* victim = nullptr, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = nullptr, AuraEffect const* triggeredByAura = nullptr, ObjectGuid originalCaster = ObjectGuid::Empty); Aura* AddAura(uint32 spellId, Unit* target); Aura* AddAura(SpellInfo const* spellInfo, uint32 effMask, Unit* target); void SetAuraStack(uint32 spellId, Unit* target, uint32 stack); @@ -1364,7 +1364,7 @@ class TC_GAME_API Unit : public WorldObject void SendTeleportPacket(Position const& pos); virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport = false); // returns true if unit's position really changed - virtual bool UpdatePosition(const Position &pos, bool teleport = false); + virtual bool UpdatePosition(Position const& pos, bool teleport = false); void UpdateOrientation(float orientation); void UpdateHeight(float newZ); @@ -1905,7 +1905,7 @@ class TC_GAME_API Unit : public WorldObject void removeFollower(FollowerReference* /*pRef*/) { /* nothing to do yet */ } MotionMaster* GetMotionMaster() { return i_motionMaster; } - const MotionMaster* GetMotionMaster() const { return i_motionMaster; } + MotionMaster const* GetMotionMaster() const { return i_motionMaster; } bool IsStopped() const { return !(HasUnitState(UNIT_STATE_MOVING)); } void StopMoving(); @@ -1966,7 +1966,7 @@ class TC_GAME_API Unit : public WorldObject Vehicle* GetVehicleKit()const { return m_vehicleKit; } Vehicle* GetVehicle() const { return m_vehicle; } void SetVehicle(Vehicle* vehicle) { m_vehicle = vehicle; } - bool IsOnVehicle(const Unit* vehicle) const; + bool IsOnVehicle(Unit const* vehicle) const; Unit* GetVehicleBase() const; Creature* GetVehicleCreatureBase() const; ObjectGuid GetTransGUID() const override; diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index 64443d58e90..16f7d6ab619 100644 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -467,7 +467,7 @@ void GameEventMgr::LoadFromDB() // 0 1 2 3 4 QueryResult result = WorldDatabase.Query("SELECT creature.guid, creature.id, game_event_model_equip.eventEntry, game_event_model_equip.modelid, game_event_model_equip.equipment_id " - "FROM creature JOIN game_event_model_equip ON creature.guid=game_event_model_equip.guid"); + "FROM creature JOIN game_event_model_equip ON creature.guid = game_event_model_equip.guid"); if (!result) TC_LOG_INFO("server.loading", ">> Loaded 0 model/equipment changes in game events. DB table `game_event_model_equip` is empty."); diff --git a/src/server/game/Globals/ObjectAccessor.h b/src/server/game/Globals/ObjectAccessor.h index 3e5ca4c1ef3..089da4e0f20 100644 --- a/src/server/game/Globals/ObjectAccessor.h +++ b/src/server/game/Globals/ObjectAccessor.h @@ -47,6 +47,7 @@ class TC_GAME_API HashMapHolder HashMapHolder() { } public: + typedef std::unordered_map<ObjectGuid, T*> MapType; static void Insert(T* o); diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 90dde6d7f78..2e4e837c10e 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -1597,7 +1597,7 @@ void ObjectMgr::LoadLinkedRespawn() { case CREATURE_TO_CREATURE: { - const CreatureData* slave = GetCreatureData(guidLow); + CreatureData const* slave = GetCreatureData(guidLow); if (!slave) { TC_LOG_ERROR("sql.sql", "LinkedRespawn: Creature (guid) '" UI64FMTD "' not found in creature table", guidLow); @@ -1605,7 +1605,7 @@ void ObjectMgr::LoadLinkedRespawn() break; } - const CreatureData* master = GetCreatureData(linkedGuidLow); + CreatureData const* master = GetCreatureData(linkedGuidLow); if (!master) { TC_LOG_ERROR("sql.sql", "LinkedRespawn: Creature (linkedGuid) '" UI64FMTD "' not found in creature table", linkedGuidLow); @@ -1635,7 +1635,7 @@ void ObjectMgr::LoadLinkedRespawn() } case CREATURE_TO_GO: { - const CreatureData* slave = GetCreatureData(guidLow); + CreatureData const* slave = GetCreatureData(guidLow); if (!slave) { TC_LOG_ERROR("sql.sql", "LinkedRespawn: Creature (guid) '" UI64FMTD "' not found in creature table", guidLow); @@ -1719,7 +1719,7 @@ void ObjectMgr::LoadLinkedRespawn() break; } - const CreatureData* master = GetCreatureData(linkedGuidLow); + CreatureData const* master = GetCreatureData(linkedGuidLow); if (!master) { TC_LOG_ERROR("sql.sql", "LinkedRespawn: Creature (linkedGuid) '" UI64FMTD "' not found in creature table", linkedGuidLow); @@ -6417,7 +6417,7 @@ void ObjectMgr::LoadGraveyardZones() { uint32 oldMSTime = getMSTime(); - GraveYardStore.clear(); // needed for reload case + GraveyardStore.clear(); // needed for reload case // 0 1 2 QueryResult result = WorldDatabase.Query("SELECT ID, GhostZone, Faction FROM graveyard_zone"); @@ -6460,14 +6460,14 @@ void ObjectMgr::LoadGraveyardZones() continue; } - if (!AddGraveYardLink(safeLocId, zoneId, team, false)) + if (!AddGraveyardLink(safeLocId, zoneId, team, false)) TC_LOG_ERROR("sql.sql", "Table `graveyard_zone` has a duplicate record for Graveyard (ID: %u) and Zone (ID: %u), skipped.", safeLocId, zoneId); } while (result->NextRow()); TC_LOG_INFO("server.loading", ">> Loaded %u graveyard-zone links in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } -WorldSafeLocsEntry const* ObjectMgr::GetDefaultGraveYard(uint32 team) const +WorldSafeLocsEntry const* ObjectMgr::GetDefaultGraveyard(uint32 team) const { enum DefaultGraveyard { @@ -6482,7 +6482,7 @@ WorldSafeLocsEntry const* ObjectMgr::GetDefaultGraveYard(uint32 team) const else return nullptr; } -WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(WorldLocation const& location, uint32 team, WorldObject* conditionObject) const +WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveyard(WorldLocation const& location, uint32 team, WorldObject* conditionObject) const { float x, y, z; location.GetPosition(x, y, z); @@ -6496,7 +6496,7 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(WorldLocation const& lo if (z > -500) { TC_LOG_ERROR("misc", "ZoneId not found for map %u coords (%f, %f, %f)", MapId, x, y, z); - return GetDefaultGraveYard(team); + return GetDefaultGraveyard(team); } } @@ -6507,7 +6507,7 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(WorldLocation const& lo // then check faction // if mapId != graveyard.mapId (ghost in instance) and search any graveyard associated // then check faction - GraveYardMapBounds range = GraveYardStore.equal_range(zoneId); + GraveyardMapBounds range = GraveyardStore.equal_range(zoneId); MapEntry const* map = sMapStore.LookupEntry(MapId); // not need to check validity of map object; MapId _MUST_ be valid here @@ -6515,7 +6515,7 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(WorldLocation const& lo { if (zoneId != 0) // zone == 0 can't be fixed, used by bliz for bugged zones TC_LOG_ERROR("sql.sql", "Table `game_graveyard_zone` incomplete: Zone %u Team %u does not have a linked graveyard.", zoneId, team); - return GetDefaultGraveYard(team); + return GetDefaultGraveyard(team); } // at corpse map @@ -6537,7 +6537,7 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(WorldLocation const& lo for (; range.first != range.second; ++range.first) { - GraveYardData const& data = range.first->second; + GraveyardData const& data = range.first->second; WorldSafeLocsEntry const* entry = ASSERT_NOTNULL(GetWorldSafeLoc(data.safeLocId)); @@ -6619,12 +6619,12 @@ WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(WorldLocation const& lo return entryFar; } -GraveYardData const* ObjectMgr::FindGraveYardData(uint32 id, uint32 zoneId) const +GraveyardData const* ObjectMgr::FindGraveyardData(uint32 id, uint32 zoneId) const { - GraveYardMapBounds range = GraveYardStore.equal_range(zoneId); + GraveyardMapBounds range = GraveyardStore.equal_range(zoneId); for (; range.first != range.second; ++range.first) { - GraveYardData const& data = range.first->second; + GraveyardData const& data = range.first->second; if (data.safeLocId == id) return &data; } @@ -6687,17 +6687,17 @@ AccessRequirement const* ObjectMgr::GetAccessRequirement(uint32 mapid, Difficult return nullptr; } -bool ObjectMgr::AddGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool persist /*= true*/) +bool ObjectMgr::AddGraveyardLink(uint32 id, uint32 zoneId, uint32 team, bool persist /*= true*/) { - if (FindGraveYardData(id, zoneId)) + if (FindGraveyardData(id, zoneId)) return false; // add link to loaded data - GraveYardData data; + GraveyardData data; data.safeLocId = id; data.team = team; - GraveYardStore.insert(GraveYardContainer::value_type(zoneId, data)); + GraveyardStore.insert(GraveyardContainer::value_type(zoneId, data)); // add link to DB if (persist) @@ -6714,9 +6714,9 @@ bool ObjectMgr::AddGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool per return true; } -void ObjectMgr::RemoveGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool persist /*= false*/) +void ObjectMgr::RemoveGraveyardLink(uint32 id, uint32 zoneId, uint32 team, bool persist /*= false*/) { - GraveYardMapBoundsNonConst range = GraveYardStore.equal_range(zoneId); + GraveyardMapBoundsNonConst range = GraveyardStore.equal_range(zoneId); if (range.first == range.second) { //TC_LOG_ERROR("sql.sql", "Table `graveyard_zone` incomplete: Zone %u Team %u does not have a linked graveyard.", zoneId, team); @@ -6728,7 +6728,7 @@ void ObjectMgr::RemoveGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool for (; range.first != range.second; ++range.first) { - GraveYardData & data = range.first->second; + GraveyardData & data = range.first->second; // skip not matching safezone id if (data.safeLocId != id) @@ -6748,7 +6748,7 @@ void ObjectMgr::RemoveGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool return; // remove from links - GraveYardStore.erase(range.first); + GraveyardStore.erase(range.first); // remove link from DB if (persist) @@ -6932,13 +6932,13 @@ AreaTriggerStruct const* ObjectMgr::GetGoBackTrigger(uint32 Map) const { bool useParentDbValue = false; uint32 parentId = 0; - const MapEntry* mapEntry = sMapStore.LookupEntry(Map); + MapEntry const* mapEntry = sMapStore.LookupEntry(Map); if (!mapEntry || mapEntry->CorpseMapID < 0) return nullptr; if (mapEntry->IsDungeon()) { - const InstanceTemplate* iTemplate = sObjectMgr->GetInstanceTemplate(Map); + InstanceTemplate const* iTemplate = sObjectMgr->GetInstanceTemplate(Map); if (!iTemplate) return nullptr; diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 43778ad4298..ce1cd5d6ea0 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -138,14 +138,14 @@ enum ScriptCommands enum ChatType { - CHAT_TYPE_SAY = 0, - CHAT_TYPE_YELL = 1, - CHAT_TYPE_TEXT_EMOTE = 2, - CHAT_TYPE_BOSS_EMOTE = 3, - CHAT_TYPE_WHISPER = 4, - CHAT_TYPE_BOSS_WHISPER = 5, - CHAT_TYPE_ZONE_YELL = 6, - CHAT_TYPE_END = 255 + CHAT_TYPE_SAY = 0, + CHAT_TYPE_YELL = 1, + CHAT_TYPE_TEXT_EMOTE = 2, + CHAT_TYPE_BOSS_EMOTE = 3, + CHAT_TYPE_WHISPER = 4, + CHAT_TYPE_BOSS_WHISPER = 5, + CHAT_TYPE_ZONE_YELL = 6, + CHAT_TYPE_END = 255 }; typedef std::map<uint32, PageText> PageTextContainer; @@ -567,55 +567,51 @@ struct PlayerCreateInfoItem { PlayerCreateInfoItem(uint32 id, uint32 amount) : item_id(id), item_amount(amount) { } - uint32 item_id; - uint32 item_amount; + uint32 item_id = 0; + uint32 item_amount = 0; }; -typedef std::list<PlayerCreateInfoItem> PlayerCreateInfoItems; +typedef std::vector<PlayerCreateInfoItem> PlayerCreateInfoItems; struct PlayerLevelInfo { - PlayerLevelInfo() { for (uint8 i = 0; i < MAX_STATS; ++i) stats[i] = 0; } - - uint16 stats[MAX_STATS]; + uint16 stats[MAX_STATS] = { }; }; -typedef std::list<uint32> PlayerCreateInfoSpells; +typedef std::vector<uint32> PlayerCreateInfoSpells; struct PlayerCreateInfoAction { - PlayerCreateInfoAction() : button(0), type(0), action(0) { } PlayerCreateInfoAction(uint8 _button, uint32 _action, uint8 _type) : button(_button), type(_type), action(_action) { } - uint8 button; - uint8 type; - uint32 action; + uint8 button = 0; + uint8 type = 0; + uint32 action = 0; }; -typedef std::list<PlayerCreateInfoAction> PlayerCreateInfoActions; +typedef std::vector<PlayerCreateInfoAction> PlayerCreateInfoActions; -typedef std::list<SkillRaceClassInfoEntry const*> PlayerCreateInfoSkills; +typedef std::vector<SkillRaceClassInfoEntry const*> PlayerCreateInfoSkills; +// existence checked by displayId != 0 struct PlayerInfo { - // existence checked by displayId != 0 - PlayerInfo() : mapId(0), areaId(0), positionX(0.0f), positionY(0.0f), positionZ(0.0f), orientation(0.0f), displayId_m(0), displayId_f(0), levelInfo(nullptr) { } - - uint32 mapId; - uint32 areaId; - float positionX; - float positionY; - float positionZ; - float orientation; - uint32 displayId_m; - uint32 displayId_f; + uint32 mapId = 0; + uint32 areaId = 0; + float positionX = 0.0f; + float positionY = 0.0f; + float positionZ = 0.0f; + float orientation = 0.0f; + uint32 displayId_m = 0; + uint32 displayId_f = 0; PlayerCreateInfoItems item; PlayerCreateInfoSpells customSpells; PlayerCreateInfoSpells castSpells; PlayerCreateInfoActions action; PlayerCreateInfoSkills skills; - PlayerLevelInfo* levelInfo; //[level-1] 0..MaxPlayerLevel-1 + //[level-1] 0..MaxPlayerLevel-1 + PlayerLevelInfo* levelInfo = nullptr; }; struct PetLevelInfo @@ -774,15 +770,15 @@ struct WorldSafeLocsEntry WorldLocation Loc; }; -struct GraveYardData +struct GraveyardData { uint32 safeLocId; uint32 team; }; -typedef std::multimap<uint32, GraveYardData> GraveYardContainer; -typedef std::pair<GraveYardContainer::const_iterator, GraveYardContainer::const_iterator> GraveYardMapBounds; -typedef std::pair<GraveYardContainer::iterator, GraveYardContainer::iterator> GraveYardMapBoundsNonConst; +typedef std::multimap<uint32, GraveyardData> GraveyardContainer; +typedef std::pair<GraveyardContainer::const_iterator, GraveyardContainer::const_iterator> GraveyardMapBounds; +typedef std::pair<GraveyardContainer::iterator, GraveyardContainer::iterator> GraveyardMapBoundsNonConst; typedef std::unordered_map<uint32, VendorItemData> CacheVendorItemContainer; @@ -1116,12 +1112,12 @@ class TC_GAME_API ObjectMgr QuestGreeting const* GetQuestGreeting(TypeID type, uint32 id) const; QuestGreetingLocale const* GetQuestGreetingLocale(TypeID type, uint32 id) const; - WorldSafeLocsEntry const* GetDefaultGraveYard(uint32 team) const; - WorldSafeLocsEntry const* GetClosestGraveYard(WorldLocation const& location, uint32 team, WorldObject* conditionObject) const; - bool AddGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool persist = true); - void RemoveGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool persist = false); + WorldSafeLocsEntry const* GetDefaultGraveyard(uint32 team) const; + WorldSafeLocsEntry const* GetClosestGraveyard(WorldLocation const& location, uint32 team, WorldObject* conditionObject) const; + bool AddGraveyardLink(uint32 id, uint32 zoneId, uint32 team, bool persist = true); + void RemoveGraveyardLink(uint32 id, uint32 zoneId, uint32 team, bool persist = false); void LoadGraveyardZones(); - GraveYardData const* FindGraveYardData(uint32 id, uint32 zone) const; + GraveyardData const* FindGraveyardData(uint32 id, uint32 zone) const; void LoadWorldSafeLocs(); WorldSafeLocsEntry const* GetWorldSafeLoc(uint32 id) const; Trinity::IteratorPair<std::unordered_map<uint32, WorldSafeLocsEntry>::const_iterator> GetWorldSafeLocs() const; @@ -1609,7 +1605,7 @@ class TC_GAME_API ObjectMgr } // for wintergrasp only - GraveYardContainer GraveYardStore; + GraveyardContainer GraveyardStore; static void AddLocaleString(std::string&& value, LocaleConstant localeConstant, std::vector<std::string>& data); static inline void GetLocaleString(std::vector<std::string> const& data, LocaleConstant localeConstant, std::string& value) @@ -1794,10 +1790,10 @@ class TC_GAME_API ObjectMgr CreatureTemplateContainer _creatureTemplateStore; CreatureModelContainer _creatureModelStore; CreatureAddonContainer _creatureAddonStore; + CreatureTemplateAddonContainer _creatureTemplateAddonStore; GameObjectAddonContainer _gameObjectAddonStore; GameObjectQuestItemMap _gameObjectQuestItemStore; CreatureQuestItemMap _creatureQuestItemStore; - CreatureTemplateAddonContainer _creatureTemplateAddonStore; EquipmentInfoContainer _equipmentInfoStore; LinkedRespawnContainer _linkedRespawnStore; CreatureLocaleContainer _creatureLocaleStore; diff --git a/src/server/game/Grids/Cells/Cell.h b/src/server/game/Grids/Cells/Cell.h index 0cd4f042aa8..cf1337350aa 100644 --- a/src/server/game/Grids/Cells/Cell.h +++ b/src/server/game/Grids/Cells/Cell.h @@ -58,13 +58,13 @@ struct Cell y = data.Part.grid_y * MAX_NUMBER_OF_CELLS + data.Part.cell_y; } - bool DiffCell(const Cell &cell) const + bool DiffCell(Cell const& cell) const { return(data.Part.cell_x != cell.data.Part.cell_x || data.Part.cell_y != cell.data.Part.cell_y); } - bool DiffGrid(const Cell &cell) const + bool DiffGrid(Cell const& cell) const { return(data.Part.grid_x != cell.data.Part.grid_x || data.Part.grid_y != cell.data.Part.grid_y); diff --git a/src/server/game/Grids/Dynamic/TypeContainerVisitor.h b/src/server/game/Grids/Dynamic/TypeContainerVisitor.h index ee903337c55..cfe3c68edf3 100644 --- a/src/server/game/Grids/Dynamic/TypeContainerVisitor.h +++ b/src/server/game/Grids/Dynamic/TypeContainerVisitor.h @@ -86,12 +86,12 @@ class TypeContainerVisitor public: TypeContainerVisitor(VISITOR &v) : i_visitor(v) { } - void Visit(TYPE_CONTAINER &c) + void Visit(TYPE_CONTAINER& c) { VisitorHelper(i_visitor, c); } - void Visit(const TYPE_CONTAINER &c) const + void Visit(TYPE_CONTAINER const& c) const { VisitorHelper(i_visitor, c); } diff --git a/src/server/game/Grids/GridRefManager.h b/src/server/game/Grids/GridRefManager.h index 9e38238a114..fa2939b4ca7 100644 --- a/src/server/game/Grids/GridRefManager.h +++ b/src/server/game/Grids/GridRefManager.h @@ -33,6 +33,6 @@ class GridRefManager : public RefManager<GridRefManager<OBJECT>, OBJECT> GridReference<OBJECT>* getLast() { return (GridReference<OBJECT>*)RefManager<GridRefManager<OBJECT>, OBJECT>::getLast(); } iterator begin() { return iterator(getFirst()); } - iterator end() { return iterator(NULL); } + iterator end() { return iterator(nullptr); } }; #endif diff --git a/src/server/game/Grids/NGrid.h b/src/server/game/Grids/NGrid.h index 587cda84111..fa0862dc896 100644 --- a/src/server/game/Grids/NGrid.h +++ b/src/server/game/Grids/NGrid.h @@ -32,14 +32,14 @@ class TC_GAME_API GridInfo { public: GridInfo(); - GridInfo(time_t expiry, bool unload = true ); - const TimeTracker& getTimeTracker() const { return i_timer; } + GridInfo(time_t expiry, bool unload = true); + TimeTracker const& getTimeTracker() const { return i_timer; } bool getUnloadLock() const { return i_unloadActiveLockCount || i_unloadExplicitLock; } void setUnloadExplicitLock(bool on) { i_unloadExplicitLock = on; } void incUnloadActiveLock() { ++i_unloadActiveLockCount; } void decUnloadActiveLock() { if (i_unloadActiveLockCount) --i_unloadActiveLockCount; } - void setTimer(const TimeTracker& pTimer) { i_timer = pTimer; } + void setTimer(TimeTracker const& pTimer) { i_timer = pTimer; } void ResetTimeTracker(time_t interval) { i_timer.Reset(interval); } void UpdateTimeTracker(time_t diff) { i_timer.Update(diff); } PeriodicTimer& getRelocationTimer() { return vis_Update; } @@ -102,7 +102,7 @@ class NGrid void setGridObjectDataLoaded(bool pLoaded) { i_GridObjectDataLoaded = pLoaded; } GridInfo* getGridInfoRef() { return &i_GridInfo; } - const TimeTracker& getTimeTracker() const { return i_GridInfo.getTimeTracker(); } + TimeTracker const& getTimeTracker() const { return i_GridInfo.getTimeTracker(); } bool getUnloadLock() const { return i_GridInfo.getUnloadLock(); } void setUnloadExplicitLock(bool on) { i_GridInfo.setUnloadExplicitLock(on); } void incUnloadActiveLock() { i_GridInfo.incUnloadActiveLock(); } diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.cpp b/src/server/game/Grids/Notifiers/GridNotifiers.cpp index c5f00519626..4e1db87c417 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.cpp +++ b/src/server/game/Grids/Notifiers/GridNotifiers.cpp @@ -79,7 +79,7 @@ void VisibleNotifier::SendToSelf() WorldPacket packet; i_data.BuildPacket(&packet); - i_player.GetSession()->SendPacket(&packet); + i_player.SendDirectMessage(&packet); for (std::set<Unit*>::const_iterator it = i_visibleNow.begin(); it != i_visibleNow.end(); ++it) i_player.SendInitialVisiblePackets(*it); diff --git a/src/server/game/Grids/Notifiers/GridNotifiers.h b/src/server/game/Grids/Notifiers/GridNotifiers.h index 85c0fab72d0..f8e3cc5cb0b 100644 --- a/src/server/game/Grids/Notifiers/GridNotifiers.h +++ b/src/server/game/Grids/Notifiers/GridNotifiers.h @@ -1415,7 +1415,7 @@ namespace Trinity class AllGameObjectsWithEntryInRange { public: - AllGameObjectsWithEntryInRange(const WorldObject* object, uint32 entry, float maxRange) : m_pObject(object), m_uiEntry(entry), m_fRange(maxRange) { } + AllGameObjectsWithEntryInRange(WorldObject const* object, uint32 entry, float maxRange) : m_pObject(object), m_uiEntry(entry), m_fRange(maxRange) { } bool operator()(GameObject* go) const { @@ -1434,7 +1434,7 @@ namespace Trinity class AllCreaturesOfEntryInRange { public: - AllCreaturesOfEntryInRange(const WorldObject* object, uint32 entry, float maxRange) : m_pObject(object), m_uiEntry(entry), m_fRange(maxRange) { } + AllCreaturesOfEntryInRange(WorldObject const* object, uint32 entry, float maxRange) : m_pObject(object), m_uiEntry(entry), m_fRange(maxRange) { } bool operator()(Unit* unit) const { @@ -1490,7 +1490,7 @@ namespace Trinity class AllWorldObjectsInRange { public: - AllWorldObjectsInRange(const WorldObject* object, float maxRange) : m_pObject(object), m_fRange(maxRange) { } + AllWorldObjectsInRange(WorldObject const* object, float maxRange) : m_pObject(object), m_fRange(maxRange) { } bool operator()(WorldObject* go) const { diff --git a/src/server/game/Grids/ObjectGridLoader.h b/src/server/game/Grids/ObjectGridLoader.h index a39d8c90157..a0638d1069a 100644 --- a/src/server/game/Grids/ObjectGridLoader.h +++ b/src/server/game/Grids/ObjectGridLoader.h @@ -31,7 +31,7 @@ class TC_GAME_API ObjectGridLoader friend class ObjectWorldLoader; public: - ObjectGridLoader(NGridType &grid, Map* map, const Cell &cell) + ObjectGridLoader(NGridType& grid, Map* map, Cell const& cell) : i_cell(cell), i_grid(grid), i_map(map), i_gameObjects(0), i_creatures(0), i_corpses (0) { } diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 10d09b63c11..22e9b84252e 100644 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -19,7 +19,6 @@ #include "Battleground.h" #include "BattlegroundMgr.h" #include "CharacterCache.h" -#include "Common.h" #include "DatabaseEnv.h" #include "DB2Stores.h" #include "Formulas.h" @@ -38,7 +37,6 @@ #include "Pet.h" #include "Player.h" #include "Random.h" -#include "SpellAuras.h" #include "UpdateData.h" #include "Util.h" #include "World.h" @@ -351,7 +349,7 @@ void Group::RemoveInvite(Player* player) void Group::RemoveAllInvites() { - for (InvitesList::iterator itr=m_invitees.begin(); itr != m_invitees.end(); ++itr) + for (InvitesList::iterator itr = m_invitees.begin(); itr != m_invitees.end(); ++itr) if (*itr) (*itr)->SetGroupInvite(nullptr); @@ -528,7 +526,7 @@ bool Group::AddMember(Player* player) return true; } -bool Group::RemoveMember(ObjectGuid guid, const RemoveMethod& method /*= GROUP_REMOVEMETHOD_DEFAULT*/, ObjectGuid kicker /*= 0*/, const char* reason /*= nullptr*/) +bool Group::RemoveMember(ObjectGuid guid, RemoveMethod method /*= GROUP_REMOVEMETHOD_DEFAULT*/, ObjectGuid kicker /*= 0*/, const char* reason /*= nullptr*/) { BroadcastGroupUpdate(); @@ -890,7 +888,7 @@ void Group::SendLootRoll(ObjectGuid playerGuid, int32 rollNumber, uint8 rollType continue; if (itr->second != NOT_VALID) - p->GetSession()->SendPacket(lootRoll.GetRawPacket()); + p->SendDirectMessage(lootRoll.GetRawPacket()); } } @@ -912,7 +910,7 @@ void Group::SendLootRollWon(ObjectGuid winnerGuid, int32 rollNumber, uint8 rollT continue; if (itr->second != NOT_VALID) - p->GetSession()->SendPacket(lootRollWon.GetRawPacket()); + p->SendDirectMessage(lootRollWon.GetRawPacket()); } } @@ -930,7 +928,7 @@ void Group::SendLootAllPassed(Roll const& roll) const continue; if (itr->second != NOT_VALID) - player->GetSession()->SendPacket(lootAllPassed.GetRawPacket()); + player->SendDirectMessage(lootAllPassed.GetRawPacket()); } } @@ -948,7 +946,7 @@ void Group::SendLootRollsComplete(Roll const& roll) const continue; if (itr->second != NOT_VALID) - player->GetSession()->SendPacket(lootRollsComplete.GetRawPacket()); + player->SendDirectMessage(lootRollsComplete.GetRawPacket()); } } @@ -1149,7 +1147,7 @@ void Group::MasterLoot(Loot* loot, WorldObject* pLootedObject) { Player* looter = itr->GetSource(); if (looter->IsAtGroupRewardDistance(pLootedObject)) - looter->GetSession()->SendPacket(masterLootCandidateList.GetRawPacket()); + looter->SendDirectMessage(masterLootCandidateList.GetRawPacket()); } } @@ -1231,7 +1229,7 @@ void Group::CountTheRoll(Rolls::iterator rollI, Map* allowedMap) ObjectGuid maxguid = ObjectGuid::Empty; Player* player = nullptr; - for (Roll::PlayerVote::const_iterator itr=roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr) + for (Roll::PlayerVote::const_iterator itr = roll->playerVote.begin(); itr != roll->playerVote.end(); ++itr) { if (itr->second != NEED) continue; @@ -1527,7 +1525,7 @@ void Group::SendUpdateToPlayer(ObjectGuid playerGUID, MemberSlot* slot) partyUpdate.LfgInfos->MyKickVoteCount = 0; } - player->GetSession()->SendPacket(partyUpdate.Write()); + player->SendDirectMessage(partyUpdate.Write()); } void Group::SendUpdateDestroyGroupToPlayer(Player* player) const @@ -1539,7 +1537,7 @@ void Group::SendUpdateDestroyGroupToPlayer(Player* player) const partyUpdate.PartyGUID = m_guid; partyUpdate.MyIndex = -1; partyUpdate.SequenceNum = player->NextGroupUpdateSequenceNumber(m_groupCategory); - player->GetSession()->SendPacket(partyUpdate.Write()); + player->SendDirectMessage(partyUpdate.Write()); } void Group::UpdatePlayerOutOfRange(Player* player) @@ -1555,7 +1553,7 @@ void Group::UpdatePlayerOutOfRange(Player* player) { member = itr->GetSource(); if (member && member != player && (!member->IsInMap(player) || !member->IsWithinDist(player, member->GetSightRange(), false))) - member->GetSession()->SendPacket(packet.Write()); + member->SendDirectMessage(packet.Write()); } } @@ -1567,10 +1565,8 @@ void Group::BroadcastAddonMessagePacket(WorldPacket const* packet, const std::st if (!player || (!ignore.IsEmpty() && player->GetGUID() == ignore) || (ignorePlayersInBGRaid && player->GetGroup() != this)) continue; - if (WorldSession* session = player->GetSession()) - if (session && (group == -1 || itr->getSubGroup() == group)) - if (session->IsAddonRegistered(prefix)) - session->SendPacket(packet); + if (player->GetSession()->IsAddonRegistered(prefix) && (group == -1 || itr->getSubGroup() == group)) + player->SendDirectMessage(packet); } } @@ -1582,8 +1578,8 @@ void Group::BroadcastPacket(WorldPacket const* packet, bool ignorePlayersInBGRai if (!player || (!ignoredPlayer.IsEmpty() && player->GetGUID() == ignoredPlayer) || (ignorePlayersInBGRaid && player->GetGroup() != this)) continue; - if (player->GetSession() && (group == -1 || itr->getSubGroup() == group)) - player->GetSession()->SendPacket(packet); + if (group == -1 || itr->getSubGroup() == group) + player->SendDirectMessage(packet); } } @@ -2028,7 +2024,7 @@ void Group::ResetInstances(uint8 method, bool isRaid, bool isLegacy, Player* Sen for (auto itr = difficultyItr->second.begin(); itr != difficultyItr->second.end();) { InstanceSave* instanceSave = itr->second.save; - const MapEntry* entry = sMapStore.LookupEntry(itr->first); + MapEntry const* entry = sMapStore.LookupEntry(itr->first); if (!entry || entry->IsRaid() != isRaid || (!instanceSave->CanReset() && method != INSTANCE_RESET_GROUP_DISBAND)) { ++itr; diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h index 41f47f0f3e5..712b62537c4 100644 --- a/src/server/game/Groups/Group.h +++ b/src/server/game/Groups/Group.h @@ -252,7 +252,7 @@ class TC_GAME_API Group void RemoveAllInvites(); bool AddLeaderInvite(Player* player); bool AddMember(Player* player); - bool RemoveMember(ObjectGuid guid, const RemoveMethod &method = GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker = ObjectGuid::Empty, const char* reason = nullptr); + bool RemoveMember(ObjectGuid guid, RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker = ObjectGuid::Empty, const char* reason = nullptr); void ChangeLeader(ObjectGuid guid, int8 partyIndex = 0); static void ConvertLeaderInstancesToGroup(Player* player, Group* group, bool switchLeader); void SetLootMethod(LootMethod method); diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 0171aeb007a..e4c8c640833 100644 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -358,12 +358,12 @@ void Guild::RankInfo::SetBankTabSlotsAndRights(GuildBankRightsAndSlots rightsAnd } } +// BankTab Guild::BankTab::BankTab(ObjectGuid::LowType guildId, uint8 tabId) : m_guildId(guildId), m_tabId(tabId) { memset(m_items, 0, GUILD_BANK_MAX_SLOTS * sizeof(Item*)); } -// BankTab void Guild::BankTab::LoadFromDB(Field* fields) { m_name = fields[2].GetString(); @@ -508,6 +508,7 @@ void Guild::BankTab::SendText(Guild const* guild, WorldSession* session) const } } +// Member Guild::Member::Member(ObjectGuid::LowType guildId, ObjectGuid guid, uint8 rankId) : m_guildId(guildId), m_guid(guid), @@ -529,7 +530,6 @@ Guild::Member::Member(ObjectGuid::LowType guildId, ObjectGuid guid, uint8 rankId memset(m_bankWithdraw, 0, (GUILD_BANK_MAX_TABS) * sizeof(uint32)); } -// Member void Guild::Member::SetStats(Player* player) { m_name = player->GetName(); @@ -757,6 +757,7 @@ void EmblemInfo::SaveToDB(ObjectGuid::LowType guildId) const CharacterDatabase.Execute(stmt); } +// MoveItemData Guild::MoveItemData::MoveItemData(Guild* guild, Player* player, uint8 container, uint8 slotId) : m_pGuild(guild), m_pPlayer(player), m_container(container), m_slotId(slotId), m_pItem(nullptr), m_pClonedItem(nullptr) { @@ -766,7 +767,6 @@ Guild::MoveItemData::~MoveItemData() { } -// MoveItemData bool Guild::MoveItemData::CheckItem(uint32& splitedAmount) { ASSERT(m_pItem); @@ -1496,7 +1496,7 @@ void Guild::HandleSetInfo(WorldSession* session, std::string const& info) } } -void Guild::HandleSetEmblem(WorldSession* session, const EmblemInfo& emblemInfo) +void Guild::HandleSetEmblem(WorldSession* session, EmblemInfo const& emblemInfo) { Player* player = session->GetPlayer(); if (!_IsLeader(player)) @@ -1599,7 +1599,7 @@ void Guild::HandleSetMemberNote(WorldSession* session, std::string const& note, } } -void Guild::HandleSetRankInfo(WorldSession* session, uint8 rankId, std::string const& name, uint32 rights, uint32 moneyPerDay, const GuildBankRightsAndSlotsVec& rightsAndSlots) +void Guild::HandleSetRankInfo(WorldSession* session, uint8 rankId, std::string const& name, uint32 rights, uint32 moneyPerDay, GuildBankRightsAndSlotsVec const& rightsAndSlots) { // Only leader can modify ranks if (!_IsLeader(session->GetPlayer())) @@ -1730,7 +1730,7 @@ void Guild::HandleInviteMember(WorldSession* session, std::string const& name) invite.OldGuildVirtualRealmAddress = GetVirtualRealmAddress(); } - pInvitee->GetSession()->SendPacket(invite.Write()); + pInvitee->SendDirectMessage(invite.Write()); TC_LOG_DEBUG("guild", "SMSG_GUILD_INVITE [%s]", pInvitee->GetName().c_str()); } @@ -2592,7 +2592,7 @@ void Guild::BroadcastToGuild(WorldSession* session, bool officerOnly, std::strin if (Player* player = itr->second->FindConnectedPlayer()) if (player->GetSession() && _HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) && !player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUID())) - player->GetSession()->SendPacket(data); + player->SendDirectMessage(data); } } @@ -2608,7 +2608,7 @@ void Guild::BroadcastAddonToGuild(WorldSession* session, bool officerOnly, std:: if (player->GetSession() && _HasRankRight(player, officerOnly ? GR_RIGHT_OFFCHATLISTEN : GR_RIGHT_GCHATLISTEN) && !player->GetSocial()->HasIgnore(session->GetPlayer()->GetGUID()) && player->GetSession()->IsAddonRegistered(prefix)) - player->GetSession()->SendPacket(data); + player->SendDirectMessage(data); } } @@ -2617,14 +2617,14 @@ void Guild::BroadcastPacketToRank(WorldPacket const* packet, uint8 rankId) const for (auto itr = m_members.begin(); itr != m_members.end(); ++itr) if (itr->second->IsRank(rankId)) if (Player* player = itr->second->FindConnectedPlayer()) - player->GetSession()->SendPacket(packet); + player->SendDirectMessage(packet); } void Guild::BroadcastPacket(WorldPacket const* packet) const { for (auto itr = m_members.begin(); itr != m_members.end(); ++itr) if (Player* player = itr->second->FindPlayer()) - player->GetSession()->SendPacket(packet); + player->SendDirectMessage(packet); } void Guild::BroadcastPacketIfTrackingAchievement(WorldPacket const* packet, uint32 criteriaId) const @@ -2976,7 +2976,7 @@ bool Guild::_IsLeader(Player* player) const { if (player->GetGUID() == m_leaderGuid) return true; - if (const Member* member = GetMember(player->GetGUID())) + if (Member const* member = GetMember(player->GetGUID())) return member->IsRank(GR_GUILDMASTER); return false; } @@ -3049,21 +3049,21 @@ void Guild::_SetRankBankTabRightsAndSlots(uint8 rankId, GuildBankRightsAndSlots inline std::string Guild::_GetRankName(uint8 rankId) const { - if (const RankInfo* rankInfo = GetRankInfo(rankId)) + if (RankInfo const* rankInfo = GetRankInfo(rankId)) return rankInfo->GetName(); return "<unknown>"; } inline uint32 Guild::_GetRankRights(uint8 rankId) const { - if (const RankInfo* rankInfo = GetRankInfo(rankId)) + if (RankInfo const* rankInfo = GetRankInfo(rankId)) return rankInfo->GetRights(); return 0; } inline uint32 Guild::_GetRankBankMoneyPerDay(uint8 rankId) const { - if (const RankInfo* rankInfo = GetRankInfo(rankId)) + if (RankInfo const* rankInfo = GetRankInfo(rankId)) return rankInfo->GetBankMoneyPerDay(); return 0; } @@ -3071,14 +3071,14 @@ inline uint32 Guild::_GetRankBankMoneyPerDay(uint8 rankId) const inline int32 Guild::_GetRankBankTabSlotsPerDay(uint8 rankId, uint8 tabId) const { if (tabId < _GetPurchasedTabsSize()) - if (const RankInfo* rankInfo = GetRankInfo(rankId)) + if (RankInfo const* rankInfo = GetRankInfo(rankId)) return rankInfo->GetBankTabSlotsPerDay(tabId); return 0; } inline int8 Guild::_GetRankBankTabRights(uint8 rankId, uint8 tabId) const { - if (const RankInfo* rankInfo = GetRankInfo(rankId)) + if (RankInfo const* rankInfo = GetRankInfo(rankId)) return rankInfo->GetBankTabRights(tabId); return 0; } @@ -3126,7 +3126,7 @@ inline void Guild::_UpdateMemberWithdrawSlots(CharacterDatabaseTransaction& tran inline bool Guild::_MemberHasTabRights(ObjectGuid guid, uint8 tabId, int32 rights) const { - if (const Member* member = GetMember(guid)) + if (Member const* member = GetMember(guid)) { // Leader always has full rights if (member->IsRank(GR_GUILDMASTER) || m_leaderGuid == guid) @@ -3170,7 +3170,7 @@ void Guild::_LogBankEvent(CharacterDatabaseTransaction& trans, GuildBankEventLog inline Item* Guild::_GetItem(uint8 tabId, uint8 slotId) const { - if (const BankTab* tab = GetBankTab(tabId)) + if (BankTab const* tab = GetBankTab(tabId)) return tab->GetItem(slotId); return nullptr; } diff --git a/src/server/game/Guilds/Guild.h b/src/server/game/Guilds/Guild.h index c9112518656..20e6196d66e 100644 --- a/src/server/game/Guilds/Guild.h +++ b/src/server/game/Guilds/Guild.h @@ -738,7 +738,7 @@ class TC_GAME_API Guild void HandleGetAchievementMembers(WorldSession* session, uint32 achievementId) const; void HandleSetMOTD(WorldSession* session, std::string const& motd); void HandleSetInfo(WorldSession* session, std::string const& info); - void HandleSetEmblem(WorldSession* session, const EmblemInfo& emblemInfo); + void HandleSetEmblem(WorldSession* session, EmblemInfo const& emblemInfo); void HandleSetNewGuildMaster(WorldSession* session, std::string const& name, bool isSelfPromote); void HandleSetBankTabInfo(WorldSession* session, uint8 tabId, std::string const& name, std::string const& icon); void HandleSetMemberNote(WorldSession* session, std::string const& note, ObjectGuid guid, bool isPublic); diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp index 95454d49f90..49d35cd452f 100644 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -32,7 +32,6 @@ #include "Player.h" #include "Util.h" #include "World.h" -#include "WorldPacket.h" #include <sstream> void WorldSession::HandleAuctionBrowseQuery(WorldPackets::AuctionHouse::AuctionBrowseQuery& browseQuery) diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp index fdd96a8369d..0ac44ad961e 100644 --- a/src/server/game/Handlers/BattleGroundHandler.cpp +++ b/src/server/game/Handlers/BattleGroundHandler.cpp @@ -168,7 +168,6 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPackets::Battleground::Batt BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId); GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, nullptr, bgTypeId, bracketEntry, 0, false, isPremade, 0, 0); - uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId()); uint32 queueSlot = _player->AddBattlegroundQueueId(bgQueueTypeId); diff --git a/src/server/game/Handlers/BattlefieldHandler.cpp b/src/server/game/Handlers/BattlefieldHandler.cpp index a969451c335..82fd6a65ef1 100644 --- a/src/server/game/Handlers/BattlefieldHandler.cpp +++ b/src/server/game/Handlers/BattlefieldHandler.cpp @@ -15,17 +15,11 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "ObjectAccessor.h" -#include "ObjectMgr.h" -#include "Opcodes.h" -#include "Player.h" -#include "WorldPacket.h" #include "WorldSession.h" -#include "Object.h" - #include "Battlefield.h" #include "BattlefieldMgr.h" #include "BattlefieldPackets.h" +#include "Player.h" /** * @fn void WorldSession::SendBfInvitePlayerToWar(uint64 queueId, uint32 zoneId, uint32 acceptTime) diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index f35566d0b10..0a54c0c7d53 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -58,7 +58,6 @@ #include "Realm.h" #include "ReputationMgr.h" #include "ScriptMgr.h" -#include "SharedDefines.h" #include "SocialMgr.h" #include "SystemPackets.h" #include "Util.h" diff --git a/src/server/game/Handlers/GroupHandler.cpp b/src/server/game/Handlers/GroupHandler.cpp index 51fbcd05ab3..d5ca7ec9b04 100644 --- a/src/server/game/Handlers/GroupHandler.cpp +++ b/src/server/game/Handlers/GroupHandler.cpp @@ -15,6 +15,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "WorldSession.h" #include "Common.h" #include "DatabaseEnv.h" #include "Group.h" @@ -29,7 +30,6 @@ #include "Util.h" #include "World.h" #include "WorldPacket.h" -#include "WorldSession.h" class Aura; @@ -132,7 +132,7 @@ void WorldSession::HandlePartyInviteOpcode(WorldPackets::Party::PartyInviteClien // tell the player that they were invited but it failed as they were already in a group WorldPackets::Party::PartyInvite partyInvite; partyInvite.Initialize(invitingPlayer, packet.ProposedRoles, false); - invitedPlayer->GetSession()->SendPacket(partyInvite.Write()); + invitedPlayer->SendDirectMessage(partyInvite.Write()); } return; @@ -185,7 +185,7 @@ void WorldSession::HandlePartyInviteOpcode(WorldPackets::Party::PartyInviteClien WorldPackets::Party::PartyInvite partyInvite; partyInvite.Initialize(invitingPlayer, packet.ProposedRoles, true); - invitedPlayer->GetSession()->SendPacket(partyInvite.Write()); + invitedPlayer->SendDirectMessage(partyInvite.Write()); SendPartyResult(PARTY_OP_INVITE, invitedPlayer->GetName(), ERR_PARTY_RESULT_OK); } @@ -253,7 +253,7 @@ void WorldSession::HandlePartyInviteResponseOpcode(WorldPackets::Party::PartyInv // report WorldPackets::Party::GroupDecline decline(GetPlayer()->GetName()); - leader->GetSession()->SendPacket(decline.Write()); + leader->SendDirectMessage(decline.Write()); } } diff --git a/src/server/game/Handlers/GuildHandler.cpp b/src/server/game/Handlers/GuildHandler.cpp index ad08a616293..ccfcf2222af 100644 --- a/src/server/game/Handlers/GuildHandler.cpp +++ b/src/server/game/Handlers/GuildHandler.cpp @@ -23,10 +23,8 @@ #include "GuildPackets.h" #include "Log.h" #include "ObjectMgr.h" -#include "Opcodes.h" #include "Player.h" #include "World.h" -#include "WorldPacket.h" void WorldSession::HandleGuildQueryOpcode(WorldPackets::Guild::QueryGuildInfo& query) { diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index 9eff5fce9b2..b6d32905be5 100644 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -15,7 +15,7 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "WorldPacket.h" +#include "WorldSession.h" #include "BattlePetMgr.h" #include "Common.h" #include "Creature.h" @@ -30,7 +30,6 @@ #include "Player.h" #include "SpellMgr.h" #include "World.h" -#include "WorldSession.h" void WorldSession::HandleSplitItemOpcode(WorldPackets::Item::SplitItem& splitItem) { @@ -903,7 +902,7 @@ void WorldSession::HandleWrapItem(WorldPackets::Item::WrapItem& packet) { // after save it will be impossible to remove the item from the queue RemoveItemFromUpdateQueueOf(item, _player); - item->SaveToDB(trans); // item gave inventory record unchanged and can be save standalone + item->SaveToDB(trans); // item gave inventory record unchanged and can be save standalone } CharacterDatabase.CommitTransaction(trans); diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index ad09333c588..01ff03ce2c1 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -358,7 +358,7 @@ void WorldSession::HandleRequestCemeteryList(WorldPackets::Misc::RequestCemetery uint32 team = _player->GetTeam(); std::vector<uint32> graveyardIds; - auto range = sObjectMgr->GraveYardStore.equal_range(zoneId); + auto range = sObjectMgr->GraveyardStore.equal_range(zoneId); for (auto it = range.first; it != range.second && graveyardIds.size() < 16; ++it) // client max { diff --git a/src/server/game/Handlers/NPCHandler.cpp b/src/server/game/Handlers/NPCHandler.cpp index f4df5db9fd6..4ef08588c07 100644 --- a/src/server/game/Handlers/NPCHandler.cpp +++ b/src/server/game/Handlers/NPCHandler.cpp @@ -299,7 +299,7 @@ void WorldSession::SendSpiritResurrect() WorldLocation corpseLocation = _player->GetCorpseLocation(); if (_player->HasCorpse()) { - corpseGrave = sObjectMgr->GetClosestGraveYard(corpseLocation, _player->GetTeam(), _player); + corpseGrave = sObjectMgr->GetClosestGraveyard(corpseLocation, _player->GetTeam(), _player); } // now can spawn bones @@ -308,7 +308,7 @@ void WorldSession::SendSpiritResurrect() // teleport to nearest from corpse graveyard, if different from nearest to player ghost if (corpseGrave) { - WorldSafeLocsEntry const* ghostGrave = sObjectMgr->GetClosestGraveYard(*_player, _player->GetTeam(), _player); + WorldSafeLocsEntry const* ghostGrave = sObjectMgr->GetClosestGraveyard(*_player, _player->GetTeam(), _player); if (corpseGrave != ghostGrave) _player->TeleportTo(corpseGrave->Loc); diff --git a/src/server/game/Handlers/PetHandler.cpp b/src/server/game/Handlers/PetHandler.cpp index 7c5be8d4a81..4db06b61727 100644 --- a/src/server/game/Handlers/PetHandler.cpp +++ b/src/server/game/Handlers/PetHandler.cpp @@ -440,7 +440,7 @@ void WorldSession::SendQueryPetNameResponse(ObjectGuid guid) } } - _player->GetSession()->SendPacket(response.Write()); + _player->SendDirectMessage(response.Write()); } bool WorldSession::CheckStableMaster(ObjectGuid guid) @@ -692,6 +692,7 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPackets::Spells::PetCastSpell& spell->m_targets = targets; SpellCastResult result = spell->CheckPetCast(nullptr); + if (result == SPELL_CAST_OK) { if (Creature* creature = caster->ToCreature()) diff --git a/src/server/game/Handlers/PetitionsHandler.cpp b/src/server/game/Handlers/PetitionsHandler.cpp index 8fe9e626f74..294f12c36df 100644 --- a/src/server/game/Handlers/PetitionsHandler.cpp +++ b/src/server/game/Handlers/PetitionsHandler.cpp @@ -276,7 +276,7 @@ void WorldSession::HandleSignPetition(WorldPackets::Petition::SignPetition& pack // update for owner if online if (Player* owner = ObjectAccessor::FindConnectedPlayer(ownerGuid)) - owner->GetSession()->SendPacket(signResult.GetRawPacket()); + owner->SendDirectMessage(signResult.GetRawPacket()); return; } @@ -298,7 +298,7 @@ void WorldSession::HandleSignPetition(WorldPackets::Petition::SignPetition& pack // update for owner if online if (Player* owner = ObjectAccessor::FindConnectedPlayer(ownerGuid)) - owner->GetSession()->SendPacket(signResult.GetRawPacket()); + owner->SendDirectMessage(signResult.GetRawPacket()); } void WorldSession::HandleDeclinePetition(WorldPackets::Petition::DeclinePetition& packet) @@ -316,7 +316,7 @@ void WorldSession::HandleDeclinePetition(WorldPackets::Petition::DeclinePetition { WorldPackets::Petition::PetitionDeclined packet; packet.Decliner = _player->GetGUID(); - owner->GetSession()->SendPacket(packet.Write()); + owner->SendDirectMessage(packet.Write()); } */ } diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp index 7df727bfec1..090a1d1e87f 100644 --- a/src/server/game/Handlers/QueryHandler.cpp +++ b/src/server/game/Handlers/QueryHandler.cpp @@ -30,7 +30,6 @@ #include "QueryPackets.h" #include "Realm.h" #include "World.h" -#include "WorldPacket.h" void WorldSession::SendNameQueryOpcode(ObjectGuid guid) { diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp index 9f2044dab59..1963e618157 100644 --- a/src/server/game/Handlers/QuestHandler.cpp +++ b/src/server/game/Handlers/QuestHandler.cpp @@ -35,7 +35,6 @@ #include "ScriptMgr.h" #include "UnitAI.h" #include "World.h" -#include "WorldPacket.h" void WorldSession::HandleQuestgiverStatusQueryOpcode(WorldPackets::Quest::QuestGiverStatusQuery& packet) { diff --git a/src/server/game/Handlers/SpellHandler.cpp b/src/server/game/Handlers/SpellHandler.cpp index 5be7223cb81..5ff33e97bf3 100644 --- a/src/server/game/Handlers/SpellHandler.cpp +++ b/src/server/game/Handlers/SpellHandler.cpp @@ -477,7 +477,7 @@ void WorldSession::HandleTotemDestroyed(WorldPackets::Totem::TotemDestroyed& tot if (!_player->m_SummonSlot[slotId]) return; - Creature* totem = ObjectAccessor::GetCreature(*GetPlayer(), _player->m_SummonSlot[slotId]); + Creature* totem = ObjectAccessor::GetCreature(*_player, _player->m_SummonSlot[slotId]); if (totem && totem->IsTotem() && totem->GetGUID() == totemDestroyed.TotemGUID) totem->ToTotem()->UnSummon(); } diff --git a/src/server/game/Handlers/TaxiHandler.cpp b/src/server/game/Handlers/TaxiHandler.cpp index c34270c3836..52d5521a733 100644 --- a/src/server/game/Handlers/TaxiHandler.cpp +++ b/src/server/game/Handlers/TaxiHandler.cpp @@ -48,7 +48,7 @@ void WorldSession::SendTaxiStatus(ObjectGuid guid) Creature* unit = ObjectAccessor::GetCreature(*player, guid); if (!unit || unit->IsHostileTo(player) || !unit->HasNpcFlag(UNIT_NPC_FLAG_FLIGHTMASTER)) { - TC_LOG_DEBUG("network", "WorldSession::SendTaxiStatus - %s not found.", guid.ToString().c_str()); + TC_LOG_DEBUG("network", "WorldSession::SendTaxiStatus - %s not found or you can't interact with him.", guid.ToString().c_str()); return; } diff --git a/src/server/game/Handlers/TicketHandler.cpp b/src/server/game/Handlers/TicketHandler.cpp index e784f09cd07..ef1332dc4a2 100644 --- a/src/server/game/Handlers/TicketHandler.cpp +++ b/src/server/game/Handlers/TicketHandler.cpp @@ -15,16 +15,14 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "WorldSession.h" #include "Common.h" #include "DatabaseEnv.h" #include "ObjectMgr.h" -#include "Opcodes.h" #include "Player.h" #include "SupportMgr.h" #include "TicketPackets.h" #include "Util.h" -#include "WorldPacket.h" -#include "WorldSession.h" void WorldSession::HandleGMTicketGetCaseStatusOpcode(WorldPackets::Ticket::GMTicketGetCaseStatus& /*packet*/) { diff --git a/src/server/game/Handlers/TradeHandler.cpp b/src/server/game/Handlers/TradeHandler.cpp index 833edbc6f4b..c53c68ce681 100644 --- a/src/server/game/Handlers/TradeHandler.cpp +++ b/src/server/game/Handlers/TradeHandler.cpp @@ -198,7 +198,7 @@ static void setAcceptTradeMode(TradeData* myTrade, TradeData* hisTrade, Item* *m if (Item* item = myTrade->GetItem(TradeSlots(i))) { TC_LOG_DEBUG("network", "player trade %s bag: %u slot: %u", item->GetGUID().ToString().c_str(), item->GetBagSlot(), item->GetSlot()); - //Can return NULL + //Can return nullptr myItems[i] = item; myItems[i]->SetInTrade(); } @@ -242,8 +242,8 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPackets::Trade::AcceptTrade& acc if (!his_trade) return; - Item* myItems[TRADE_SLOT_TRADED_COUNT] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }; - Item* hisItems[TRADE_SLOT_TRADED_COUNT] = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }; + Item* myItems[TRADE_SLOT_TRADED_COUNT] = { }; + Item* hisItems[TRADE_SLOT_TRADED_COUNT] = { }; // set before checks for propertly undo at problems (it already set in to client) my_trade->SetAccepted(true); diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index 0028b9f38a8..f7fa4c3ce2a 100644 --- a/src/server/game/Instances/InstanceSaveMgr.cpp +++ b/src/server/game/Instances/InstanceSaveMgr.cpp @@ -78,7 +78,7 @@ InstanceSave* InstanceSaveManager::AddInstanceSave(uint32 mapId, uint32 instance if (InstanceSave* old_save = GetInstanceSave(instanceId)) return old_save; - const MapEntry* entry = sMapStore.LookupEntry(mapId); + MapEntry const* entry = sMapStore.LookupEntry(mapId); if (!entry) { TC_LOG_ERROR("misc", "InstanceSaveManager::AddInstanceSave: wrong mapid = %d, instanceid = %d!", mapId, instanceId); @@ -233,7 +233,7 @@ void InstanceSave::SaveToDB() time_t InstanceSave::GetResetTimeForDB() { // only save the reset time for normal instances - const MapEntry* entry = sMapStore.LookupEntry(GetMapId()); + MapEntry const* entry = sMapStore.LookupEntry(GetMapId()); if (!entry || entry->IsRaid() || GetDifficultyID() == DIFFICULTY_HEROIC) return 0; else diff --git a/src/server/game/Instances/InstanceSaveMgr.h b/src/server/game/Instances/InstanceSaveMgr.h index f3bf10c81dd..ad8160612c5 100644 --- a/src/server/game/Instances/InstanceSaveMgr.h +++ b/src/server/game/Instances/InstanceSaveMgr.h @@ -177,7 +177,7 @@ class TC_GAME_API InstanceSaveManager InstResetEvent() : type(0), difficulty(DIFFICULTY_NORMAL), mapid(0), instanceId(0) { } InstResetEvent(uint8 t, uint32 _mapid, Difficulty d, uint32 _instanceid) : type(t), difficulty(d), mapid(_mapid), instanceId(_instanceid) { } - bool operator == (const InstResetEvent& e) const { return e.instanceId == instanceId; } + bool operator==(InstResetEvent const& e) const { return e.instanceId == instanceId; } }; typedef std::multimap<time_t /*resetTime*/, InstResetEvent> ResetTimeQueue; diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp index 5caac91a946..ae969379cf5 100644 --- a/src/server/game/Instances/InstanceScript.cpp +++ b/src/server/game/Instances/InstanceScript.cpp @@ -29,7 +29,6 @@ #include "Log.h" #include "Map.h" #include "ObjectMgr.h" -#include "Opcodes.h" #include "Pet.h" #include "PhasingHandler.h" #include "Player.h" @@ -141,14 +140,14 @@ void InstanceScript::SetHeaders(std::string const& dataHeaders) headers.push_back(header); } -void InstanceScript::LoadBossBoundaries(const BossBoundaryData& data) +void InstanceScript::LoadBossBoundaries(BossBoundaryData const& data) { for (BossBoundaryEntry const& entry : data) if (entry.BossId < bosses.size()) bosses[entry.BossId].boundary.push_back(entry.Boundary); } -void InstanceScript::LoadMinionData(const MinionData* data) +void InstanceScript::LoadMinionData(MinionData const* data) { while (data->entry) { @@ -160,7 +159,7 @@ void InstanceScript::LoadMinionData(const MinionData* data) TC_LOG_DEBUG("scripts", "InstanceScript::LoadMinionData: " UI64FMTD " minions loaded.", uint64(minions.size())); } -void InstanceScript::LoadDoorData(const DoorData* data) +void InstanceScript::LoadDoorData(DoorData const* data) { while (data->entry) { @@ -619,7 +618,7 @@ void InstanceScript::DoSendNotifyToInstance(char const* format, ...) // Update Achievement Criteria for all players in instance void InstanceScript::DoUpdateCriteria(CriteriaTypes type, uint32 miscValue1 /*= 0*/, uint32 miscValue2 /*= 0*/, Unit* unit /*= nullptr*/) { - Map::PlayerList const &PlayerList = instance->GetPlayers(); + Map::PlayerList const& PlayerList = instance->GetPlayers(); if (!PlayerList.isEmpty()) for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) @@ -630,7 +629,7 @@ void InstanceScript::DoUpdateCriteria(CriteriaTypes type, uint32 miscValue1 /*= // Start timed achievement for all players in instance void InstanceScript::DoStartCriteriaTimer(CriteriaTimedTypes type, uint32 entry) { - Map::PlayerList const &PlayerList = instance->GetPlayers(); + Map::PlayerList const& PlayerList = instance->GetPlayers(); if (!PlayerList.isEmpty()) for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) @@ -641,7 +640,7 @@ void InstanceScript::DoStartCriteriaTimer(CriteriaTimedTypes type, uint32 entry) // Stop timed achievement for all players in instance void InstanceScript::DoStopCriteriaTimer(CriteriaTimedTypes type, uint32 entry) { - Map::PlayerList const &PlayerList = instance->GetPlayers(); + Map::PlayerList const& PlayerList = instance->GetPlayers(); if (!PlayerList.isEmpty()) for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) @@ -670,7 +669,7 @@ void InstanceScript::DoRemoveAurasDueToSpellOnPlayers(uint32 spell) // Cast spell on all players in instance void InstanceScript::DoCastSpellOnPlayers(uint32 spell) { - Map::PlayerList const &PlayerList = instance->GetPlayers(); + Map::PlayerList const& PlayerList = instance->GetPlayers(); if (!PlayerList.isEmpty()) for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i) diff --git a/src/server/game/Instances/InstanceScript.h b/src/server/game/Instances/InstanceScript.h index 823996f2481..996eab16c20 100644 --- a/src/server/game/Instances/InstanceScript.h +++ b/src/server/game/Instances/InstanceScript.h @@ -20,10 +20,10 @@ #include "ZoneScript.h" #include "Common.h" +#include <iosfwd> #include <map> #include <memory> #include <set> -#include <sstream> #define OUT_SAVE_INST_DATA TC_LOG_DEBUG("scripts", "Saving Instance Data for Instance %s (Map %d, Instance Id %d)", instance->GetMapName(), instance->GetId(), instance->GetInstanceId()) #define OUT_SAVE_INST_DATA_COMPLETE TC_LOG_DEBUG("scripts", "Saving Instance Data for Instance %s (Map %d, Instance Id %d) completed.", instance->GetMapName(), instance->GetId(), instance->GetInstanceId()) @@ -233,7 +233,7 @@ class TC_GAME_API InstanceScript : public ZoneScript void DoCastSpellOnPlayers(uint32 spell); // Return wether server allow two side groups or not - bool ServerAllowsTwoSideGroups(); + static bool ServerAllowsTwoSideGroups(); virtual bool SetBossState(uint32 id, EncounterState state); EncounterState GetBossState(uint32 id) const { return id < bosses.size() ? bosses[id].state : TO_BE_DECIDED; } diff --git a/src/server/game/Loot/LootItemStorage.h b/src/server/game/Loot/LootItemStorage.h index 7855559ce1e..3b242154865 100644 --- a/src/server/game/Loot/LootItemStorage.h +++ b/src/server/game/Loot/LootItemStorage.h @@ -18,8 +18,8 @@ #ifndef __LOOTITEMSTORAGE_H #define __LOOTITEMSTORAGE_H -#include "DatabaseEnvFwd.h" #include "Define.h" +#include "DatabaseEnvFwd.h" #include "DBCEnums.h" #include "ItemEnchantmentMgr.h" diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp index 4bb5e07fc90..672fc3a13c4 100644 --- a/src/server/game/Loot/LootMgr.cpp +++ b/src/server/game/Loot/LootMgr.cpp @@ -103,14 +103,14 @@ class LootTemplate::LootGroup // A set of loot def LootStoreItem const* Roll(Loot& loot, uint16 lootMode) const; // Rolls an item from the group, returns NULL if all miss their chances // This class must never be copied - storing pointers - LootGroup(LootGroup const&); - LootGroup& operator=(LootGroup const&); + LootGroup(LootGroup const&) = delete; + LootGroup& operator=(LootGroup const&) = delete; }; //Remove all data and free all memory void LootStore::Clear() { - for (LootTemplateMap::const_iterator itr=m_LootTemplates.begin(); itr != m_LootTemplates.end(); ++itr) + for (LootTemplateMap::const_iterator itr = m_LootTemplates.begin(); itr != m_LootTemplates.end(); ++itr) delete itr->second; m_LootTemplates.clear(); } @@ -271,7 +271,7 @@ void LootStore::ReportNonExistingId(uint32 lootId) const TC_LOG_ERROR("sql.sql", "Table '%s' Entry %d does not exist", GetName(), lootId); } -void LootStore::ReportNonExistingId(uint32 lootId, const char* ownerType, uint32 ownerId) const +void LootStore::ReportNonExistingId(uint32 lootId, char const* ownerType, uint32 ownerId) const { TC_LOG_ERROR("sql.sql", "Table '%s' Entry %d does not exist but it is used by %s %d", GetName(), lootId, ownerType, ownerId); } @@ -538,7 +538,7 @@ void LootTemplate::AddEntry(LootStoreItem* item) Entries.push_back(item); } -void LootTemplate::CopyConditions(const ConditionContainer& conditions) +void LootTemplate::CopyConditions(ConditionContainer const& conditions) { for (LootStoreItemList::iterator i = Entries.begin(); i != Entries.end(); ++i) (*i)->conditions.clear(); @@ -1108,7 +1108,7 @@ void LoadLootTemplates_Spell() { // not report about not trainable spells (optionally supported by DB) // ignore 61756 (Northrend Inscription Research (FAST QA VERSION) for example - if (!spellInfo->HasAttribute(SPELL_ATTR0_NOT_SHAPESHIFT) || (spellInfo->HasAttribute(SPELL_ATTR0_TRADESPELL))) + if (!spellInfo->HasAttribute(SPELL_ATTR0_NOT_SHAPESHIFT) || spellInfo->HasAttribute(SPELL_ATTR0_TRADESPELL)) LootTemplates_Spell.ReportNonExistingId(spellInfo->Id, "Spell", spellInfo->Id); } else diff --git a/src/server/game/Loot/LootMgr.h b/src/server/game/Loot/LootMgr.h index 0fa7b86198c..c531d085b37 100644 --- a/src/server/game/Loot/LootMgr.h +++ b/src/server/game/Loot/LootMgr.h @@ -75,7 +75,7 @@ class TC_GAME_API LootStore void CheckLootRefs(LootIdSet* ref_set = nullptr) const; // check existence reference and remove it from ref_set void ReportUnusedIds(LootIdSet const& ids_set) const; void ReportNonExistingId(uint32 lootId) const; - void ReportNonExistingId(uint32 lootId, const char* ownerType, uint32 ownerId) const; + void ReportNonExistingId(uint32 lootId, char const* ownerType, uint32 ownerId) const; bool HaveLootFor(uint32 loot_id) const { return m_LootTemplates.find(loot_id) != m_LootTemplates.end(); } bool HaveQuestLootFor(uint32 loot_id) const; @@ -111,7 +111,7 @@ class TC_GAME_API LootTemplate void AddEntry(LootStoreItem* item); // Rolls for every item in the template and adds the rolled items the the loot void Process(Loot& loot, bool rate, uint16 lootMode, uint8 groupId = 0) const; - void CopyConditions(const ConditionContainer& conditions); + void CopyConditions(ConditionContainer const& conditions); void CopyConditions(LootItem* li) const; // True if template includes at least 1 quest drop entry diff --git a/src/server/game/Mails/Mail.h b/src/server/game/Mails/Mail.h index 6c86a51d484..dc9ea2828df 100644 --- a/src/server/game/Mails/Mail.h +++ b/src/server/game/Mails/Mail.h @@ -19,8 +19,8 @@ #define TRINITY_MAIL_H #include "Common.h" +#include "DatabaseEnvFwd.h" #include "ObjectGuid.h" -#include "Transaction.h" #include <map> struct CalendarEvent; diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index ea1040a4e9b..b96fb726d50 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -553,7 +553,7 @@ void Map::DeleteFromWorld(Transport* transport) delete transport; } -void Map::EnsureGridCreated(const GridCoord &p) +void Map::EnsureGridCreated(GridCoord const& p) { std::lock_guard<std::mutex> lock(_gridLock); EnsureGridCreated_i(p); @@ -561,7 +561,7 @@ void Map::EnsureGridCreated(const GridCoord &p) //Create NGrid so the object can be added to it //But object data is not loaded here -void Map::EnsureGridCreated_i(const GridCoord &p) +void Map::EnsureGridCreated_i(GridCoord const& p) { if (!getNGrid(p.x_coord, p.y_coord)) { @@ -600,7 +600,7 @@ void Map::EnsureGridCreated_i(const GridCoord &p) } //Load NGrid and make it active -void Map::EnsureGridLoadedForActiveObject(const Cell &cell, WorldObject* object) +void Map::EnsureGridLoadedForActiveObject(Cell const& cell, WorldObject* object) { EnsureGridLoaded(cell); NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); @@ -616,7 +616,7 @@ void Map::EnsureGridLoadedForActiveObject(const Cell &cell, WorldObject* object) } //Create NGrid and load the object data in it -bool Map::EnsureGridLoaded(const Cell &cell) +bool Map::EnsureGridLoaded(Cell const& cell) { EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY())); NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); @@ -804,7 +804,7 @@ bool Map::AddToMap(Transport* obj) return true; } -bool Map::IsGridLoaded(const GridCoord &p) const +bool Map::IsGridLoaded(GridCoord const& p) const { return (getNGrid(p.x_coord, p.y_coord) && isGridObjectDataLoaded(p.x_coord, p.y_coord)); } @@ -2051,7 +2051,7 @@ GridMap::~GridMap() unloadData(); } -GridMap::LoadResult GridMap::loadData(const char* filename) +GridMap::LoadResult GridMap::loadData(char const* filename) { // Unload old data if exist unloadData(); @@ -3183,7 +3183,7 @@ void Map::SendInitSelf(Player* player) WorldPacket packet; data.BuildPacket(&packet); - player->GetSession()->SendPacket(&packet); + player->SendDirectMessage(&packet); } void Map::SendInitTransports(Player* player) @@ -3201,7 +3201,7 @@ void Map::SendInitTransports(Player* player) WorldPacket packet; transData.BuildPacket(&packet); - player->GetSession()->SendPacket(&packet); + player->SendDirectMessage(&packet); } void Map::SendRemoveTransports(Player* player) @@ -3219,7 +3219,7 @@ void Map::SendRemoveTransports(Player* player) WorldPacket packet; transData.BuildPacket(&packet); - player->GetSession()->SendPacket(&packet); + player->SendDirectMessage(&packet); } void Map::SendUpdateTransportVisibility(Player* player) @@ -3275,7 +3275,7 @@ void Map::SendObjectUpdates() for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) { iter->second.BuildPacket(&packet); - iter->first->GetSession()->SendPacket(&packet); + iter->first->SendDirectMessage(&packet); packet.clear(); // clean the string } } @@ -3890,7 +3890,7 @@ uint32 Map::GetPlayersCountExceptGMs() const void Map::SendToPlayers(WorldPacket const* data) const { for (MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) - itr->GetSource()->GetSession()->SendPacket(data); + itr->GetSource()->SendDirectMessage(data); } bool Map::ActiveObjectsNearGrid(NGridType const& ngrid) const @@ -4158,7 +4158,7 @@ bool InstanceMap::AddPlayerToMap(Player* player, bool initPlayer /*= true*/) pendingRaidLock.CompletedMask = i_data ? i_data->GetCompletedEncounterMask() : 0; pendingRaidLock.Extending = false; pendingRaidLock.WarningOnly = false; // events it throws: 1 : INSTANCE_LOCK_WARNING 0 : INSTANCE_LOCK_STOP / INSTANCE_LOCK_START - player->GetSession()->SendPacket(pendingRaidLock.Write()); + player->SendDirectMessage(pendingRaidLock.Write()); player->SetPendingBind(mapSave->GetInstanceId(), 60000); } } @@ -4364,7 +4364,7 @@ void InstanceMap::PermBindAllPlayers() player->BindToInstance(save, true); WorldPackets::Instance::InstanceSaveCreated data; data.Gm = player->IsGameMaster(); - player->GetSession()->SendPacket(data.Write()); + player->SendDirectMessage(data.Write()); player->GetSession()->SendCalendarRaidLockout(save, true); // if group leader is in instance, group also gets bound @@ -5090,10 +5090,14 @@ void Map::UpdateAreaDependentAuras() { Map::PlayerList const& players = GetPlayers(); for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr) + { if (Player* player = itr->GetSource()) + { if (player->IsInWorld()) { player->UpdateAreaDependentAuras(player->GetAreaId()); player->UpdateZoneDependentAuras(player->GetZoneId()); } + } + } } diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index d646a3bf023..4288037297e 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -248,7 +248,7 @@ public: InvalidFile }; - LoadResult loadData(const char* filename); + LoadResult loadData(char const* filename); void unloadData(); uint16 getArea(float x, float y) const; @@ -360,7 +360,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType> void AreaTriggerRelocation(AreaTrigger* at, float x, float y, float z, float orientation); template<class T, class CONTAINER> - void Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER> &visitor); + void Visit(Cell const& cell, TypeContainerVisitor<T, CONTAINER>& visitor); bool IsRemovalGrid(float x, float y) const { @@ -373,8 +373,8 @@ class TC_GAME_API Map : public GridRefManager<NGridType> bool IsGridLoaded(float x, float y) const { return IsGridLoaded(Trinity::ComputeGridCoord(x, y)); } bool IsGridLoaded(Position const& pos) const { return IsGridLoaded(pos.GetPositionX(), pos.GetPositionY()); } - bool GetUnloadLock(const GridCoord &p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); } - void SetUnloadLock(const GridCoord &p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); } + bool GetUnloadLock(GridCoord const& p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); } + void SetUnloadLock(GridCoord const& p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); } void LoadGrid(float x, float y); void LoadAllCells(); bool UnloadGrid(NGridType& ngrid, bool pForce); @@ -453,7 +453,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType> CANNOT_ENTER_UNSPECIFIED_REASON }; virtual EnterState CannotEnter(Player* /*player*/) { return CAN_ENTER; } - const char* GetMapName() const; + char const* GetMapName() const; // have meaning only for instanced map (that have set real difficulty) Difficulty GetDifficultyID() const { return Difficulty(i_spawnMode); } @@ -472,11 +472,11 @@ class TC_GAME_API Map : public GridRefManager<NGridType> bool IsBattleArena() const; bool IsBattlegroundOrArena() const; bool IsGarrison() const; - bool GetEntrancePos(int32 &mapid, float &x, float &y); + bool GetEntrancePos(int32& mapid, float& x, float& y); void AddObjectToRemoveList(WorldObject* obj); void AddObjectToSwitchList(WorldObject* obj, bool on); - virtual void DelayedUpdate(const uint32 diff); + virtual void DelayedUpdate(uint32 diff); void resetMarkedCells() { marked_cells.reset(); } bool isCellMarked(uint32 pCellId) { return marked_cells.test(pCellId); } @@ -571,9 +571,9 @@ class TC_GAME_API Map : public GridRefManager<NGridType> float GetHeight(PhaseShift const& phaseShift, Position const& pos, bool vmap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) { return GetHeight(phaseShift, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), vmap, maxSearchDist); } bool isInLineOfSight(PhaseShift const& phaseShift, float x1, float y1, float z1, float x2, float y2, float z2, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const; void Balance() { _dynamicTree.balance(); } - void RemoveGameObjectModel(const GameObjectModel& model) { _dynamicTree.remove(model); } - void InsertGameObjectModel(const GameObjectModel& model) { _dynamicTree.insert(model); } - bool ContainsGameObjectModel(const GameObjectModel& model) const { return _dynamicTree.contains(model);} + void RemoveGameObjectModel(GameObjectModel const& model) { _dynamicTree.remove(model); } + void InsertGameObjectModel(GameObjectModel const& model) { _dynamicTree.insert(model); } + bool ContainsGameObjectModel(GameObjectModel const& model) const { return _dynamicTree.contains(model);} float GetGameObjectFloor(PhaseShift const& phaseShift, float x, float y, float z, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const { return _dynamicTree.getHeight(x, y, z, maxSearchDist, phaseShift); @@ -687,9 +687,9 @@ class TC_GAME_API Map : public GridRefManager<NGridType> bool _areaTriggersToMoveLock; std::vector<AreaTrigger*> _areaTriggersToMove; - bool IsGridLoaded(const GridCoord &) const; - void EnsureGridCreated(const GridCoord &); - void EnsureGridCreated_i(const GridCoord &); + bool IsGridLoaded(GridCoord const&) const; + void EnsureGridCreated(GridCoord const&); + void EnsureGridCreated_i(GridCoord const&); bool EnsureGridLoaded(Cell const&); void EnsureGridLoadedForActiveObject(Cell const&, WorldObject* object); @@ -737,13 +737,13 @@ class TC_GAME_API Map : public GridRefManager<NGridType> TransportsContainer::iterator _transportsUpdateIter; private: - Player* _GetScriptPlayerSourceOrTarget(Object* source, Object* target, const ScriptInfo* scriptInfo) const; - Creature* _GetScriptCreatureSourceOrTarget(Object* source, Object* target, const ScriptInfo* scriptInfo, bool bReverse = false) const; - Unit* _GetScriptUnit(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const; - Player* _GetScriptPlayer(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const; - Creature* _GetScriptCreature(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const; - WorldObject* _GetScriptWorldObject(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const; - void _ScriptProcessDoor(Object* source, Object* target, const ScriptInfo* scriptInfo) const; + Player* _GetScriptPlayerSourceOrTarget(Object* source, Object* target, ScriptInfo const* scriptInfo) const; + Creature* _GetScriptCreatureSourceOrTarget(Object* source, Object* target, ScriptInfo const* scriptInfo, bool bReverse = false) const; + Unit* _GetScriptUnit(Object* obj, bool isSource, ScriptInfo const* scriptInfo) const; + Player* _GetScriptPlayer(Object* obj, bool isSource, ScriptInfo const* scriptInfo) const; + Creature* _GetScriptCreature(Object* obj, bool isSource, ScriptInfo const* scriptInfo) const; + WorldObject* _GetScriptWorldObject(Object* obj, bool isSource, ScriptInfo const* scriptInfo) const; + void _ScriptProcessDoor(Object* source, Object* target, ScriptInfo const* scriptInfo) const; GameObject* _FindGameObject(WorldObject* pWorldObject, ObjectGuid::LowType guid) const; time_t i_gridExpiry; diff --git a/src/server/game/Maps/MapInstanced.cpp b/src/server/game/Maps/MapInstanced.cpp index d81267144e4..1aa047b9f37 100644 --- a/src/server/game/Maps/MapInstanced.cpp +++ b/src/server/game/Maps/MapInstanced.cpp @@ -45,7 +45,7 @@ void MapInstanced::InitVisibilityDistance() } } -void MapInstanced::Update(const uint32 t) +void MapInstanced::Update(uint32 t) { // take care of loaded GridMaps (when unused, unload it!) Map::Update(t); @@ -74,7 +74,7 @@ void MapInstanced::Update(const uint32 t) } } -void MapInstanced::DelayedUpdate(const uint32 diff) +void MapInstanced::DelayedUpdate(uint32 diff) { for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i) i->second->DelayedUpdate(diff); @@ -111,7 +111,7 @@ void MapInstanced::UnloadAll() - create the instance if it's not created already - the player is not actually added to the instance (only in InstanceMap::Add) */ -Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player, uint32 loginInstanceId) +Map* MapInstanced::CreateInstanceForPlayer(uint32 mapId, Player* player, uint32 loginInstanceId /*= 0*/) { if (GetId() != mapId || !player) return nullptr; @@ -211,13 +211,13 @@ InstanceMap* MapInstanced::CreateInstance(uint32 InstanceId, InstanceSave* save, std::lock_guard<std::mutex> lock(_mapLock); // make sure we have a valid map id - const MapEntry* entry = sMapStore.LookupEntry(GetId()); + MapEntry const* entry = sMapStore.LookupEntry(GetId()); if (!entry) { TC_LOG_ERROR("maps", "CreateInstance: no entry for map %d", GetId()); ABORT(); } - const InstanceTemplate* iTemplate = sObjectMgr->GetInstanceTemplate(GetId()); + InstanceTemplate const* iTemplate = sObjectMgr->GetInstanceTemplate(GetId()); if (!iTemplate) { TC_LOG_ERROR("maps", "CreateInstance: no instance template for map %d", GetId()); diff --git a/src/server/game/Maps/MapInstanced.h b/src/server/game/Maps/MapInstanced.h index e2908625ba3..e6aaefe7c18 100644 --- a/src/server/game/Maps/MapInstanced.h +++ b/src/server/game/Maps/MapInstanced.h @@ -34,13 +34,13 @@ class TC_GAME_API MapInstanced : public Map ~MapInstanced() { } // functions overwrite Map versions - void Update(const uint32) override; - void DelayedUpdate(const uint32 diff) override; + void Update(uint32 diff) override; + void DelayedUpdate(uint32 diff) override; //void RelocationNotify(); void UnloadAll() override; EnterState CannotEnter(Player* /*player*/) override; - Map* CreateInstanceForPlayer(const uint32 mapId, Player* player, uint32 loginInstanceId=0); + Map* CreateInstanceForPlayer(uint32 mapId, Player* player, uint32 loginInstanceId = 0); Map* FindInstanceMap(uint32 instanceId) const { InstancedMaps::const_iterator i = m_InstancedMaps.find(instanceId); diff --git a/src/server/game/Maps/MapManager.h b/src/server/game/Maps/MapManager.h index 9ff42ff557f..d74e87dd32c 100644 --- a/src/server/game/Maps/MapManager.h +++ b/src/server/game/Maps/MapManager.h @@ -82,7 +82,7 @@ class TC_GAME_API MapManager i_timer.Reset(); } - //void LoadGrid(int mapid, int instId, float x, float y, const WorldObject* obj, bool no_unload = false); + //void LoadGrid(int mapid, int instId, float x, float y, WorldObject const* obj, bool no_unload = false); void UnloadAll(); static bool ExistMapAndVMap(uint32 mapid, float x, float y); diff --git a/src/server/game/Maps/MapScripts.cpp b/src/server/game/Maps/MapScripts.cpp index 9a86dfaedbe..5118e160932 100644 --- a/src/server/game/Maps/MapScripts.cpp +++ b/src/server/game/Maps/MapScripts.cpp @@ -100,7 +100,7 @@ void Map::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* sou } // Helpers for ScriptProcess method. -inline Player* Map::_GetScriptPlayerSourceOrTarget(Object* source, Object* target, const ScriptInfo* scriptInfo) const +inline Player* Map::_GetScriptPlayerSourceOrTarget(Object* source, Object* target, ScriptInfo const* scriptInfo) const { Player* player = nullptr; if (!source && !target) @@ -122,7 +122,7 @@ inline Player* Map::_GetScriptPlayerSourceOrTarget(Object* source, Object* targe return player; } -inline Creature* Map::_GetScriptCreatureSourceOrTarget(Object* source, Object* target, const ScriptInfo* scriptInfo, bool bReverse) const +inline Creature* Map::_GetScriptCreatureSourceOrTarget(Object* source, Object* target, ScriptInfo const* scriptInfo, bool bReverse) const { Creature* creature = nullptr; if (!source && !target) @@ -155,7 +155,7 @@ inline Creature* Map::_GetScriptCreatureSourceOrTarget(Object* source, Object* t return creature; } -inline Unit* Map::_GetScriptUnit(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const +inline Unit* Map::_GetScriptUnit(Object* obj, bool isSource, ScriptInfo const* scriptInfo) const { Unit* unit = nullptr; if (!obj) @@ -175,7 +175,7 @@ inline Unit* Map::_GetScriptUnit(Object* obj, bool isSource, const ScriptInfo* s return unit; } -inline Player* Map::_GetScriptPlayer(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const +inline Player* Map::_GetScriptPlayer(Object* obj, bool isSource, ScriptInfo const* scriptInfo) const { Player* player = nullptr; if (!obj) @@ -192,7 +192,7 @@ inline Player* Map::_GetScriptPlayer(Object* obj, bool isSource, const ScriptInf return player; } -inline Creature* Map::_GetScriptCreature(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const +inline Creature* Map::_GetScriptCreature(Object* obj, bool isSource, ScriptInfo const* scriptInfo) const { Creature* creature = nullptr; if (!obj) @@ -209,7 +209,7 @@ inline Creature* Map::_GetScriptCreature(Object* obj, bool isSource, const Scrip return creature; } -inline WorldObject* Map::_GetScriptWorldObject(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const +inline WorldObject* Map::_GetScriptWorldObject(Object* obj, bool isSource, ScriptInfo const* scriptInfo) const { WorldObject* pWorldObject = nullptr; if (!obj) @@ -227,7 +227,7 @@ inline WorldObject* Map::_GetScriptWorldObject(Object* obj, bool isSource, const return pWorldObject; } -inline void Map::_ScriptProcessDoor(Object* source, Object* target, const ScriptInfo* scriptInfo) const +inline void Map::_ScriptProcessDoor(Object* source, Object* target, ScriptInfo const* scriptInfo) const { bool bOpen = false; ObjectGuid::LowType guid = scriptInfo->ToggleDoor.GOGuid; diff --git a/src/server/game/Maps/TransportMgr.h b/src/server/game/Maps/TransportMgr.h index ba9ffcc77e1..ef381d125a2 100644 --- a/src/server/game/Maps/TransportMgr.h +++ b/src/server/game/Maps/TransportMgr.h @@ -30,7 +30,7 @@ class Map; namespace Movement { - template<typename length_type> class Spline; + template <typename length_type> class Spline; } typedef Movement::Spline<double> TransportSpline; diff --git a/src/server/game/Miscellaneous/Formulas.h b/src/server/game/Miscellaneous/Formulas.h index 89852399e65..c49dc93d86a 100644 --- a/src/server/game/Miscellaneous/Formulas.h +++ b/src/server/game/Miscellaneous/Formulas.h @@ -198,7 +198,7 @@ namespace Trinity xpMod *= isBattleGround ? sWorld->getRate(RATE_XP_BG_KILL) : sWorld->getRate(RATE_XP_KILL); if (creature && creature->m_PlayerDamageReq) // if players dealt less than 50% of the damage and were credited anyway (due to CREATURE_FLAG_EXTRA_NO_PLAYER_DAMAGE_REQ), scale XP gained appropriately (linear scaling) - xpMod *= 1.0f - 2.0f*creature->m_PlayerDamageReq / creature->GetMaxHealth(); + xpMod *= 1.0f - 2.0f * creature->m_PlayerDamageReq / creature->GetMaxHealth(); gain = uint32(gain * xpMod); } diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index 068746b7e35..9c87ab14765 100644 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -5101,7 +5101,7 @@ enum BattlegroundTeamId : uint8 #define BG_TEAMS_COUNT 2 -// indexes of BattlemasterList.dbc (7.1.5.23360) +// indexes of BattlemasterList.dbc enum BattlegroundTypeId : uint32 { BATTLEGROUND_TYPE_NONE = 0, // None diff --git a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp index 0432241432d..d3cdffb462f 100755 --- a/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/ConfusedMovementGenerator.cpp @@ -15,13 +15,13 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "ConfusedMovementGenerator.h" #include "Creature.h" -#include "Player.h" -#include "PathGenerator.h" -#include "MoveSplineInit.h" #include "MoveSpline.h" +#include "MoveSplineInit.h" +#include "PathGenerator.h" +#include "Player.h" #include "Random.h" -#include "ConfusedMovementGenerator.h" template<class T> ConfusedMovementGenerator<T>::~ConfusedMovementGenerator() diff --git a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp index 041961ce91c..191877289c8 100644 --- a/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/HomeMovementGenerator.cpp @@ -15,12 +15,12 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "HomeMovementGenerator.h" #include "Creature.h" #include "CreatureAI.h" -#include "MoveSplineInit.h" #include "MoveSpline.h" +#include "MoveSplineInit.h" #include "PathGenerator.h" -#include "HomeMovementGenerator.h" template<class T> HomeMovementGenerator<T>::~HomeMovementGenerator() { } diff --git a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h index 18f552cc1cd..4f5bcbc6e17 100644 --- a/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/PointMovementGenerator.h @@ -30,7 +30,7 @@ template<class T> class PointMovementGenerator : public MovementGeneratorMedium< T, PointMovementGenerator<T> > { public: -explicit PointMovementGenerator(uint32 id, float x, float y, float z, bool generatePath, float speed = 0.0f, Unit const* faceTarget = nullptr, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr) : _movementId(id), _destination(x, y, z), _speed(speed), i_faceTarget(faceTarget), i_spellEffectExtra(spellEffectExtraData), _generatePath(generatePath), _recalculateSpeed(false), _interrupt(false) { } + explicit PointMovementGenerator(uint32 id, float x, float y, float z, bool generatePath, float speed = 0.0f, Unit const* faceTarget = nullptr, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr) : _movementId(id), _destination(x, y, z), _speed(speed), i_faceTarget(faceTarget), i_spellEffectExtra(spellEffectExtraData), _generatePath(generatePath), _recalculateSpeed(false), _interrupt(false) { } MovementGeneratorType GetMovementGeneratorType() const override { return POINT_MOTION_TYPE; } @@ -57,7 +57,7 @@ explicit PointMovementGenerator(uint32 id, float x, float y, float z, bool gener class AssistanceMovementGenerator : public PointMovementGenerator<Creature> { public: - explicit AssistanceMovementGenerator(float _x, float _y, float _z) : PointMovementGenerator<Creature>(0, _x, _y, _z, true) { } + AssistanceMovementGenerator(float x, float y, float z) : PointMovementGenerator<Creature>(0, x, y, z, true) { } MovementGeneratorType GetMovementGeneratorType() const override { return ASSISTANCE_MOTION_TYPE; } void Finalize(Unit*) override; diff --git a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp index ca95243d507..48f1c00c616 100644 --- a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.cpp @@ -15,13 +15,13 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "RandomMovementGenerator.h" #include "Creature.h" #include "Map.h" #include "MoveSplineInit.h" #include "MoveSpline.h" #include "PathGenerator.h" #include "Random.h" -#include "RandomMovementGenerator.h" template<class T> RandomMovementGenerator<T>::~RandomMovementGenerator() { } @@ -42,7 +42,7 @@ void RandomMovementGenerator<Creature>::DoInitialize(Creature* owner) return; owner->AddUnitState(UNIT_STATE_ROAMING); - owner->GetPosition(_reference.m_positionX, _reference.m_positionY, _reference.m_positionZ); + _reference = owner->GetPosition(); owner->StopMoving(); if (!_wanderDistance) diff --git a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h index a615bec49bc..c0716f4c247 100644 --- a/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/RandomMovementGenerator.h @@ -25,7 +25,7 @@ template<class T> class RandomMovementGenerator : public MovementGeneratorMedium< T, RandomMovementGenerator<T> > { public: - explicit RandomMovementGenerator(float distance = 0.0f) : _path(nullptr), _timer(0), _reference(0.f, 0.f, 0.f), _wanderDistance(distance), _interrupt(false) { } + explicit RandomMovementGenerator(float distance = 0.0f) : _path(nullptr), _timer(0), _reference(), _wanderDistance(distance), _interrupt(false) { } ~RandomMovementGenerator(); MovementGeneratorType GetMovementGeneratorType() const override { return RANDOM_MOTION_TYPE; } diff --git a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp index 5c8eb721e18..a2e954ad225 100755 --- a/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/TargetedMovementGenerator.cpp @@ -15,15 +15,15 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "CreatureAI.h" +#include "TargetedMovementGenerator.h" #include "Creature.h" -#include "Player.h" -#include "VehicleDefines.h" -#include "MoveSplineInit.h" +#include "CreatureAI.h" #include "MoveSpline.h" +#include "MoveSplineInit.h" #include "PathGenerator.h" +#include "Player.h" +#include "VehicleDefines.h" #include "World.h" -#include "TargetedMovementGenerator.h" template<class T, typename D> TargetedMovementGenerator<T, D>::~TargetedMovementGenerator() diff --git a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h index b944913a74d..4c5d6cba197 100755 --- a/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h +++ b/src/server/game/Movement/MovementGenerators/WaypointMovementGenerator.h @@ -136,4 +136,5 @@ class FlightPathMovementGenerator : public MovementGeneratorMedium<Player, Fligh std::deque<TaxiNodeChangeInfo> _pointsForPathSwitch; //! node indexes and costs where TaxiPath changes }; + #endif diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp index 66af5f9e55a..25ea5638f08 100644 --- a/src/server/game/Movement/PathGenerator.cpp +++ b/src/server/game/Movement/PathGenerator.cpp @@ -1,19 +1,18 @@ /* * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "PathGenerator.h" @@ -29,7 +28,7 @@ #include "PhasingHandler.h" ////////////////// PathGenerator ////////////////// -PathGenerator::PathGenerator(const Unit* owner) : +PathGenerator::PathGenerator(Unit const* owner) : _polyLength(0), _type(PATHFIND_BLANK), _useStraightPath(false), _forceDestination(false), _pointPathLimit(MAX_POINT_PATH_LENGTH), _straightLine(false), _endPosition(G3D::Vector3::zero()), _sourceUnit(owner), _navMesh(nullptr), @@ -886,7 +885,7 @@ dtStatus PathGenerator::FindSmoothPath(float const* startPos, float const* endPo return nsmoothPath < MAX_POINT_PATH_LENGTH ? DT_SUCCESS : DT_FAILURE; } -bool PathGenerator::InRangeYZX(const float* v1, const float* v2, float r, float h) const +bool PathGenerator::InRangeYZX(float const* v1, float const* v2, float r, float h) const { const float dx = v2[0] - v1[0]; const float dy = v2[1] - v1[1]; // elevation diff --git a/src/server/game/Movement/PathGenerator.h b/src/server/game/Movement/PathGenerator.h index cc554d73c0a..8109579dfbc 100644 --- a/src/server/game/Movement/PathGenerator.h +++ b/src/server/game/Movement/PathGenerator.h @@ -1,18 +1,18 @@ /* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef _PATH_GENERATOR_H diff --git a/src/server/game/Movement/Spline/MoveSpline.cpp b/src/server/game/Movement/Spline/MoveSpline.cpp index c125d9db689..4d72d506549 100644 --- a/src/server/game/Movement/Spline/MoveSpline.cpp +++ b/src/server/game/Movement/Spline/MoveSpline.cpp @@ -1,18 +1,18 @@ /* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "MoveSpline.h" @@ -144,9 +144,9 @@ struct CommonInitializer } }; -void MoveSpline::init_spline(const MoveSplineInitArgs& args) +void MoveSpline::init_spline(MoveSplineInitArgs const& args) { - const SplineBase::EvaluationMode modes[2] = {SplineBase::ModeLinear, SplineBase::ModeCatmullrom}; + static SplineBase::EvaluationMode const modes[2] = { SplineBase::ModeLinear, SplineBase::ModeCatmullrom }; if (args.flags.cyclic) { uint32 cyclic_point = 0; @@ -156,9 +156,7 @@ void MoveSpline::init_spline(const MoveSplineInitArgs& args) spline.init_cyclic_spline(&args.path[0], args.path.size(), modes[args.flags.isSmooth()], cyclic_point); } else - { spline.init_spline(&args.path[0], args.path.size(), modes[args.flags.isSmooth()]); - } // init spline timestamps if (splineflags.falling) diff --git a/src/server/game/Movement/Spline/MoveSpline.h b/src/server/game/Movement/Spline/MoveSpline.h index ac0b808c82e..0bc025fc5f0 100644 --- a/src/server/game/Movement/Spline/MoveSpline.h +++ b/src/server/game/Movement/Spline/MoveSpline.h @@ -1,18 +1,18 @@ /* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef TRINITYSERVER_MOVEPLINE_H @@ -37,8 +37,8 @@ namespace Movement { Location() : orientation(0) { } Location(float x, float y, float z, float o) : Vector3(x, y, z), orientation(o) { } - Location(const Vector3& v) : Vector3(v), orientation(0) { } - Location(const Vector3& v, float o) : Vector3(v), orientation(o) { } + Location(Vector3 const& v) : Vector3(v), orientation(0) { } + Location(Vector3 const& v, float o) : Vector3(v), orientation(o) { } float orientation; }; @@ -82,7 +82,7 @@ namespace Movement int32 point_Idx_offset; Optional<SpellEffectExtraData> spell_effect_extra; - void init_spline(const MoveSplineInitArgs& args); + void init_spline(MoveSplineInitArgs const& args); protected: MySpline::ControlArray const& getPath() const { return spline.getPoints(); } @@ -104,7 +104,7 @@ namespace Movement void _Interrupt() { splineflags.done = true; } public: - void Initialize(const MoveSplineInitArgs&); + void Initialize(MoveSplineInitArgs const&); bool Initialized() const { return !spline.empty(); } MoveSpline(); diff --git a/src/server/game/Movement/Spline/MoveSplineFlag.h b/src/server/game/Movement/Spline/MoveSplineFlag.h index 10f0fb8648e..2f80d1d509c 100644 --- a/src/server/game/Movement/Spline/MoveSplineFlag.h +++ b/src/server/game/Movement/Spline/MoveSplineFlag.h @@ -1,18 +1,18 @@ /* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef TRINITYSERVER_MOVESPLINEFLAG_H @@ -71,7 +71,7 @@ namespace Movement }; inline uint32& raw() { return (uint32&)*this; } - inline const uint32& raw() const { return (const uint32&)*this; } + inline uint32 const& raw() const { return (uint32 const&)*this; } MoveSplineFlag() { raw() = 0; } MoveSplineFlag(uint32 f) { raw() = f; } diff --git a/src/server/game/Movement/Spline/MoveSplineInit.cpp b/src/server/game/Movement/Spline/MoveSplineInit.cpp index 8740500dac5..a5d6a7c86f3 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.cpp +++ b/src/server/game/Movement/Spline/MoveSplineInit.cpp @@ -1,18 +1,18 @@ /* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "MoveSplineInit.h" @@ -222,7 +222,7 @@ namespace Movement args.facing.type = MONSTER_MOVE_FACING_ANGLE; } - void MoveSplineInit::MovebyPath(const PointsArray& controls, int32 path_offset) + void MoveSplineInit::MovebyPath(PointsArray const& controls, int32 path_offset) { args.path_Idx_offset = path_offset; args.path.reserve(controls.size()); @@ -234,7 +234,7 @@ namespace Movement MoveTo(G3D::Vector3(x, y, z), generatePath, forceDestination); } - void MoveSplineInit::MoveTo(const Vector3& dest, bool generatePath, bool forceDestination) + void MoveSplineInit::MoveTo(Vector3 const& dest, bool generatePath, bool forceDestination) { if (generatePath) { diff --git a/src/server/game/Movement/Spline/MoveSplineInit.h b/src/server/game/Movement/Spline/MoveSplineInit.h index 05a64ef7a62..62678e2be91 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.h +++ b/src/server/game/Movement/Spline/MoveSplineInit.h @@ -1,18 +1,18 @@ /* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef TRINITYSERVER_MOVESPLINEINIT_H @@ -87,11 +87,11 @@ namespace Movement * @param path - array of points, shouldn't be empty * @param pointId - Id of fisrt point of the path. Example: when third path point will be done it will notify that pointId + 3 done */ - void MovebyPath(const PointsArray& path, int32 pointId = 0); + void MovebyPath(PointsArray const& path, int32 pointId = 0); /* Initializes simple A to B motion, A is current unit's position, B is destination */ - void MoveTo(const Vector3& destination, bool generatePath = true, bool forceDestination = false); + void MoveTo(Vector3 const& destination, bool generatePath = true, bool forceDestination = false); void MoveTo(float x, float y, float z, bool generatePath = true, bool forceDestination = false); /* Sets Id of fisrt point of the path. When N-th path point will be done ILisener will notify that pointId + N done diff --git a/src/server/game/Movement/Spline/MoveSplineInitArgs.h b/src/server/game/Movement/Spline/MoveSplineInitArgs.h index c190f979362..6ae25b48de0 100644 --- a/src/server/game/Movement/Spline/MoveSplineInitArgs.h +++ b/src/server/game/Movement/Spline/MoveSplineInitArgs.h @@ -1,18 +1,18 @@ /* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef TRINITYSERVER_MOVESPLINEINIT_ARGS_H diff --git a/src/server/game/Movement/Spline/MovementTypedefs.h b/src/server/game/Movement/Spline/MovementTypedefs.h index e2188181841..31760ff01ce 100644 --- a/src/server/game/Movement/Spline/MovementTypedefs.h +++ b/src/server/game/Movement/Spline/MovementTypedefs.h @@ -1,18 +1,18 @@ /* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef TRINITYSERVER_TYPEDEFS_H diff --git a/src/server/game/Movement/Spline/MovementUtil.cpp b/src/server/game/Movement/Spline/MovementUtil.cpp index f706a230480..95ceb3752a5 100644 --- a/src/server/game/Movement/Spline/MovementUtil.cpp +++ b/src/server/game/Movement/Spline/MovementUtil.cpp @@ -1,18 +1,18 @@ /* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "MoveSplineFlag.h" diff --git a/src/server/game/Movement/Spline/Spline.cpp b/src/server/game/Movement/Spline/Spline.cpp index b6318b6c63d..0866dcc066e 100644 --- a/src/server/game/Movement/Spline/Spline.cpp +++ b/src/server/game/Movement/Spline/Spline.cpp @@ -1,19 +1,18 @@ /* * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "Spline.h" @@ -94,7 +93,7 @@ inline void C_Evaluate(const Vector3 *vertice, float t, const float (&matrix)[4] position.z = z; }*/ -inline void C_Evaluate(const Vector3 *vertice, float t, const Matrix4& matr, Vector3 &result) +inline void C_Evaluate(Vector3 const* vertice, float t, Matrix4 const& matr, Vector3 &result) { Vector4 tvec(t*t*t, t*t, t, 1.f); Vector4 weights(tvec * matr); @@ -103,7 +102,7 @@ inline void C_Evaluate(const Vector3 *vertice, float t, const Matrix4& matr, Vec + vertice[2] * weights[2] + vertice[3] * weights[3]; } -inline void C_Evaluate_Derivative(const Vector3 *vertice, float t, const Matrix4& matr, Vector3 &result) +inline void C_Evaluate_Derivative(Vector3 const* vertice, float t, Matrix4 const& matr, Vector3 &result) { Vector4 tvec(3.f*t*t, 2.f*t, 1.f, 0.f); Vector4 weights(tvec * matr); @@ -215,7 +214,7 @@ void SplineBase::init_cyclic_spline(const Vector3 * controls, index_type count, (this->*initializers[m_mode])(controls, count, cyclic_point); } -void SplineBase::InitLinear(const Vector3* controls, index_type count, index_type cyclic_point) +void SplineBase::InitLinear(Vector3 const* controls, index_type count, index_type cyclic_point) { ASSERT(count >= 2); const int real_size = count + 1; @@ -235,7 +234,7 @@ void SplineBase::InitLinear(const Vector3* controls, index_type count, index_typ index_hi = cyclic ? count : (count - 1); } -void SplineBase::InitCatmullRom(const Vector3* controls, index_type count, index_type cyclic_point) +void SplineBase::InitCatmullRom(Vector3 const* controls, index_type count, index_type cyclic_point) { const int real_size = count + (cyclic ? (1+2) : (1+1)); @@ -268,7 +267,7 @@ void SplineBase::InitCatmullRom(const Vector3* controls, index_type count, index index_hi = high_index + (cyclic ? 1 : 0); } -void SplineBase::InitBezier3(const Vector3* controls, index_type count, index_type /*cyclic_point*/) +void SplineBase::InitBezier3(Vector3 const* controls, index_type count, index_type /*cyclic_point*/) { index_type c = count / 3u * 3u; index_type t = c / 3u; diff --git a/src/server/game/Movement/Spline/Spline.h b/src/server/game/Movement/Spline/Spline.h index 5f31115b2af..eeb6ddcc350 100644 --- a/src/server/game/Movement/Spline/Spline.h +++ b/src/server/game/Movement/Spline/Spline.h @@ -1,18 +1,18 @@ /* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef TRINITYSERVER_SPLINE_H @@ -77,10 +77,10 @@ protected: typedef float (SplineBase::*SegLenghtMethtod)(index_type) const; static SegLenghtMethtod seglengths[ModesEnd]; - void InitLinear(const Vector3*, index_type, index_type); - void InitCatmullRom(const Vector3*, index_type, index_type); - void InitBezier3(const Vector3*, index_type, index_type); - typedef void (SplineBase::*InitMethtod)(const Vector3*, index_type, index_type); + void InitLinear(Vector3 const*, index_type, index_type); + void InitCatmullRom(Vector3 const*, index_type, index_type); + void InitBezier3(Vector3 const*, index_type, index_type); + typedef void (SplineBase::*InitMethtod)(Vector3 const*, index_type, index_type); static InitMethtod initializers[ModesEnd]; void UninitializedSplineEvaluationMethod(index_type, float, Vector3&) const { ABORT(); } @@ -111,9 +111,9 @@ public: EvaluationMode mode() const { return (EvaluationMode)m_mode;} bool isCyclic() const { return cyclic;} - const ControlArray& getPoints() const { return points; } - index_type getPointCount() const { return index_type(points.size()); } - const Vector3& getPoint(index_type i) const { return points[i]; } + ControlArray const& getPoints() const { return points; } + index_type getPointCount() const { return index_type(points.size());} + Vector3 const& getPoint(index_type i) const { return points[i]; } /** Initializes spline. Don't call other methods while spline not initialized. */ void init_spline(const Vector3 * controls, index_type count, EvaluationMode m); diff --git a/src/server/game/Movement/Spline/SplineImpl.h b/src/server/game/Movement/Spline/SplineImpl.h index fd77ca3c6fe..4eb7a3f76cd 100644 --- a/src/server/game/Movement/Spline/SplineImpl.h +++ b/src/server/game/Movement/Spline/SplineImpl.h @@ -1,18 +1,18 @@ /* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. */ namespace Movement diff --git a/src/server/game/OutdoorPvP/OutdoorPvP.cpp b/src/server/game/OutdoorPvP/OutdoorPvP.cpp index 379dc7e1d07..b85f344d244 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvP.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvP.cpp @@ -489,7 +489,7 @@ bool OutdoorPvP::IsInsideObjective(Player* player) const bool OPvPCapturePoint::IsInsideObjective(Player* player) const { - GuidSet const &plSet = m_activePlayers[player->GetTeamId()]; + GuidSet const& plSet = m_activePlayers[player->GetTeamId()]; return plSet.find(player->GetGUID()) != plSet.end(); } @@ -589,7 +589,7 @@ void OutdoorPvP::RegisterZone(uint32 zoneId) bool OutdoorPvP::HasPlayer(Player const* player) const { - GuidSet const &plSet = m_players[player->GetTeamId()]; + GuidSet const& plSet = m_players[player->GetTeamId()]; return plSet.find(player->GetGUID()) != plSet.end(); } @@ -652,8 +652,7 @@ void OutdoorPvP::BroadcastWorker(Worker& _worker, uint32 zoneId) void OutdoorPvP::SetMapFromZone(uint32 zone) { - AreaTableEntry const* areaTable = sAreaTableStore.LookupEntry(zone); - ASSERT(areaTable); + AreaTableEntry const* areaTable = sAreaTableStore.AssertEntry(zone); Map* map = sMapMgr->CreateBaseMap(areaTable->ContinentID); ASSERT(!map->Instanceable()); m_map = map; diff --git a/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp b/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp index 7d1036eaa01..9d8107ef8be 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp +++ b/src/server/game/OutdoorPvP/OutdoorPvPMgr.cpp @@ -36,8 +36,7 @@ void OutdoorPvPMgr::Die() m_OutdoorPvPSet.clear(); - for (uint32 i = 0; i < MAX_OUTDOORPVP_TYPES; ++i) - m_OutdoorPvPDatas[i] = 0; + m_OutdoorPvPDatas.fill(0); m_OutdoorPvPMap.clear(); } diff --git a/src/server/game/OutdoorPvP/OutdoorPvPMgr.h b/src/server/game/OutdoorPvP/OutdoorPvPMgr.h index 1a73a46da70..f91a971597f 100644 --- a/src/server/game/OutdoorPvP/OutdoorPvPMgr.h +++ b/src/server/game/OutdoorPvP/OutdoorPvPMgr.h @@ -21,6 +21,7 @@ #define OUTDOORPVP_OBJECTIVE_UPDATE_INTERVAL 1000 #include "OutdoorPvP.h" +#include <array> #include <unordered_map> class Player; @@ -80,7 +81,7 @@ class TC_GAME_API OutdoorPvPMgr private: typedef std::vector<OutdoorPvP*> OutdoorPvPSet; - typedef std::unordered_map<uint32 /* zoneid */, OutdoorPvP*> OutdoorPvPMap; + typedef std::unordered_map<uint32 /*zoneid*/, OutdoorPvP*> OutdoorPvPMap; typedef std::array<uint32, MAX_OUTDOORPVP_TYPES> OutdoorPvPScriptIds; // contains all initiated outdoor pvp events diff --git a/src/server/game/Petitions/PetitionMgr.cpp b/src/server/game/Petitions/PetitionMgr.cpp index c1dcee3ff87..87199224c4f 100644 --- a/src/server/game/Petitions/PetitionMgr.cpp +++ b/src/server/game/Petitions/PetitionMgr.cpp @@ -21,9 +21,8 @@ #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "Player.h" -#include "WorldSession.h" #include "Timer.h" - +#include "WorldSession.h" #include <unordered_map> namespace diff --git a/src/server/game/Petitions/PetitionMgr.h b/src/server/game/Petitions/PetitionMgr.h index bddc63eb61f..913ed796105 100644 --- a/src/server/game/Petitions/PetitionMgr.h +++ b/src/server/game/Petitions/PetitionMgr.h @@ -21,7 +21,6 @@ #include "Define.h" #include "ObjectGuid.h" #include "SharedDefines.h" - #include <string> #include <utility> #include <vector> diff --git a/src/server/game/Pools/PoolMgr.cpp b/src/server/game/Pools/PoolMgr.cpp index f7f1facd90c..44a1ef3ee82 100644 --- a/src/server/game/Pools/PoolMgr.cpp +++ b/src/server/game/Pools/PoolMgr.cpp @@ -796,8 +796,8 @@ void PoolMgr::LoadFromDB() if (checkedPools.find(poolItr->second) != checkedPools.end()) { std::ostringstream ss; - ss<< "The pool(s) "; - for (std::set<uint32>::const_iterator itr=checkedPools.begin(); itr != checkedPools.end(); ++itr) + ss << "The pool(s) "; + for (std::set<uint32>::const_iterator itr = checkedPools.begin(); itr != checkedPools.end(); ++itr) ss << *itr << ' '; ss << "create(s) a circular reference, which can cause the server to freeze.\nRemoving the last link between mother pool " << poolItr->first << " and child pool " << poolItr->second; @@ -909,8 +909,8 @@ void PoolMgr::LoadFromDB() uint32 oldMSTime = getMSTime(); QueryResult result = WorldDatabase.Query("SELECT DISTINCT pool_template.entry, pool_pool.pool_id, pool_pool.mother_pool FROM pool_template" - " LEFT JOIN game_event_pool ON pool_template.entry=game_event_pool.pool_entry" - " LEFT JOIN pool_pool ON pool_template.entry=pool_pool.pool_id WHERE game_event_pool.pool_entry IS NULL"); + " LEFT JOIN game_event_pool ON pool_template.entry = game_event_pool.pool_entry" + " LEFT JOIN pool_pool ON pool_template.entry = pool_pool.pool_id WHERE game_event_pool.pool_entry IS NULL"); if (!result) { diff --git a/src/server/game/PrecompiledHeaders/gamePCH.h b/src/server/game/PrecompiledHeaders/gamePCH.h index 65de2d11f94..86714e97a59 100644 --- a/src/server/game/PrecompiledHeaders/gamePCH.h +++ b/src/server/game/PrecompiledHeaders/gamePCH.h @@ -1,3 +1,20 @@ +/* + * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + //add here most rarely modified headers to speed up debug build compilation #include "Creature.h" diff --git a/src/server/game/Reputation/ReputationMgr.cpp b/src/server/game/Reputation/ReputationMgr.cpp index b4d39b846ca..4e18c5f0978 100644 --- a/src/server/game/Reputation/ReputationMgr.cpp +++ b/src/server/game/Reputation/ReputationMgr.cpp @@ -21,12 +21,10 @@ #include "DB2Stores.h" #include "Log.h" #include "ObjectMgr.h" -#include "Opcodes.h" #include "Player.h" #include "ReputationPackets.h" #include "ScriptMgr.h" #include "World.h" -#include "WorldPacket.h" #include "WorldSession.h" const int32 ReputationMgr::PointsInRank[MAX_REPUTATION_RANK] = {36000, 3000, 3000, 3000, 6000, 12000, 21000, 1000}; @@ -271,7 +269,7 @@ bool ReputationMgr::SetReputation(FactionEntry const* factionEntry, int32 standi if (!noSpillover) { // if spillover definition exists in DB, override DBC - if (const RepSpilloverTemplate* repTemplate = sObjectMgr->GetRepSpilloverTemplate(factionEntry->ID)) + if (RepSpilloverTemplate const* repTemplate = sObjectMgr->GetRepSpilloverTemplate(factionEntry->ID)) { for (uint32 i = 0; i < MAX_SPILLOVER_FACTIONS; ++i) { diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index b70994a3ed2..6ca57b18391 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -1105,7 +1105,7 @@ struct TSpellSummary uint8 Effects; // set of enum SelectEffect } *SpellSummary; -ScriptObject::ScriptObject(const char* name) : _name(name) +ScriptObject::ScriptObject(char const* name) : _name(name) { sScriptMgr->IncreaseScriptCount(); } @@ -1694,7 +1694,7 @@ std::vector<ChatCommand> ScriptMgr::GetChatCommands() } // Sort commands in alphabetical order - std::sort(table.begin(), table.end(), [](const ChatCommand& a, const ChatCommand&b) + std::sort(table.begin(), table.end(), [](ChatCommand const& a, ChatCommand const& b) { return strcmp(a.Name, b.Name) < 0; }); @@ -2150,7 +2150,7 @@ void ScriptMgr::OnGroupInviteMember(Group* group, ObjectGuid guid) FOREACH_SCRIPT(GroupScript)->OnInviteMember(group, guid); } -void ScriptMgr::OnGroupRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, const char* reason) +void ScriptMgr::OnGroupRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, char const* reason) { ASSERT(group); FOREACH_SCRIPT(GroupScript)->OnRemoveMember(group, guid, method, kicker, reason); @@ -2263,38 +2263,38 @@ void ScriptMgr::OnQuestObjectiveChange(Player* player, Quest const* quest, Quest tmpscript->OnQuestObjectiveChange(player, quest, objective, oldAmount, newAmount); } -SpellScriptLoader::SpellScriptLoader(const char* name) +SpellScriptLoader::SpellScriptLoader(char const* name) : ScriptObject(name) { ScriptRegistry<SpellScriptLoader>::Instance()->AddScript(this); } -ServerScript::ServerScript(const char* name) +ServerScript::ServerScript(char const* name) : ScriptObject(name) { ScriptRegistry<ServerScript>::Instance()->AddScript(this); } -WorldScript::WorldScript(const char* name) +WorldScript::WorldScript(char const* name) : ScriptObject(name) { ScriptRegistry<WorldScript>::Instance()->AddScript(this); } -FormulaScript::FormulaScript(const char* name) +FormulaScript::FormulaScript(char const* name) : ScriptObject(name) { ScriptRegistry<FormulaScript>::Instance()->AddScript(this); } -UnitScript::UnitScript(const char* name, bool addToScripts) +UnitScript::UnitScript(char const* name, bool addToScripts) : ScriptObject(name) { if (addToScripts) ScriptRegistry<UnitScript>::Instance()->AddScript(this); } -WorldMapScript::WorldMapScript(const char* name, uint32 mapId) +WorldMapScript::WorldMapScript(char const* name, uint32 mapId) : ScriptObject(name), MapScript<Map>(sMapStore.LookupEntry(mapId)) { if (!GetEntry()) @@ -2306,7 +2306,7 @@ WorldMapScript::WorldMapScript(const char* name, uint32 mapId) ScriptRegistry<WorldMapScript>::Instance()->AddScript(this); } -InstanceMapScript::InstanceMapScript(const char* name, uint32 mapId) +InstanceMapScript::InstanceMapScript(char const* name, uint32 mapId) : ScriptObject(name), MapScript<InstanceMap>(sMapStore.LookupEntry(mapId)) { if (!GetEntry()) @@ -2318,7 +2318,7 @@ InstanceMapScript::InstanceMapScript(const char* name, uint32 mapId) ScriptRegistry<InstanceMapScript>::Instance()->AddScript(this); } -BattlegroundMapScript::BattlegroundMapScript(const char* name, uint32 mapId) +BattlegroundMapScript::BattlegroundMapScript(char const* name, uint32 mapId) : ScriptObject(name), MapScript<BattlegroundMap>(sMapStore.LookupEntry(mapId)) { if (!GetEntry()) @@ -2330,25 +2330,25 @@ BattlegroundMapScript::BattlegroundMapScript(const char* name, uint32 mapId) ScriptRegistry<BattlegroundMapScript>::Instance()->AddScript(this); } -ItemScript::ItemScript(const char* name) +ItemScript::ItemScript(char const* name) : ScriptObject(name) { ScriptRegistry<ItemScript>::Instance()->AddScript(this); } -CreatureScript::CreatureScript(const char* name) +CreatureScript::CreatureScript(char const* name) : UnitScript(name, false) { ScriptRegistry<CreatureScript>::Instance()->AddScript(this); } -GameObjectScript::GameObjectScript(const char* name) +GameObjectScript::GameObjectScript(char const* name) : ScriptObject(name) { ScriptRegistry<GameObjectScript>::Instance()->AddScript(this); } -AreaTriggerScript::AreaTriggerScript(const char* name) +AreaTriggerScript::AreaTriggerScript(char const* name) : ScriptObject(name) { ScriptRegistry<AreaTriggerScript>::Instance()->AddScript(this); @@ -2375,97 +2375,97 @@ BattlegroundScript::BattlegroundScript(char const* name) ScriptRegistry<BattlegroundScript>::Instance()->AddScript(this); } -OutdoorPvPScript::OutdoorPvPScript(const char* name) +OutdoorPvPScript::OutdoorPvPScript(char const* name) : ScriptObject(name) { ScriptRegistry<OutdoorPvPScript>::Instance()->AddScript(this); } -CommandScript::CommandScript(const char* name) +CommandScript::CommandScript(char const* name) : ScriptObject(name) { ScriptRegistry<CommandScript>::Instance()->AddScript(this); } -WeatherScript::WeatherScript(const char* name) +WeatherScript::WeatherScript(char const* name) : ScriptObject(name) { ScriptRegistry<WeatherScript>::Instance()->AddScript(this); } -AuctionHouseScript::AuctionHouseScript(const char* name) +AuctionHouseScript::AuctionHouseScript(char const* name) : ScriptObject(name) { ScriptRegistry<AuctionHouseScript>::Instance()->AddScript(this); } -ConditionScript::ConditionScript(const char* name) +ConditionScript::ConditionScript(char const* name) : ScriptObject(name) { ScriptRegistry<ConditionScript>::Instance()->AddScript(this); } -VehicleScript::VehicleScript(const char* name) +VehicleScript::VehicleScript(char const* name) : ScriptObject(name) { ScriptRegistry<VehicleScript>::Instance()->AddScript(this); } -DynamicObjectScript::DynamicObjectScript(const char* name) +DynamicObjectScript::DynamicObjectScript(char const* name) : ScriptObject(name) { ScriptRegistry<DynamicObjectScript>::Instance()->AddScript(this); } -TransportScript::TransportScript(const char* name) +TransportScript::TransportScript(char const* name) : ScriptObject(name) { ScriptRegistry<TransportScript>::Instance()->AddScript(this); } -AchievementCriteriaScript::AchievementCriteriaScript(const char* name) +AchievementCriteriaScript::AchievementCriteriaScript(char const* name) : ScriptObject(name) { ScriptRegistry<AchievementCriteriaScript>::Instance()->AddScript(this); } -PlayerScript::PlayerScript(const char* name) +PlayerScript::PlayerScript(char const* name) : UnitScript(name, false) { ScriptRegistry<PlayerScript>::Instance()->AddScript(this); } -AccountScript::AccountScript(const char* name) +AccountScript::AccountScript(char const* name) : ScriptObject(name) { ScriptRegistry<AccountScript>::Instance()->AddScript(this); } -SceneScript::SceneScript(const char* name) +SceneScript::SceneScript(char const* name) : ScriptObject(name) { ScriptRegistry<SceneScript>::Instance()->AddScript(this); } -QuestScript::QuestScript(const char* name) +QuestScript::QuestScript(char const* name) : ScriptObject(name) { ScriptRegistry<QuestScript>::Instance()->AddScript(this); } -GuildScript::GuildScript(const char* name) +GuildScript::GuildScript(char const* name) : ScriptObject(name) { ScriptRegistry<GuildScript>::Instance()->AddScript(this); } -GroupScript::GroupScript(const char* name) +GroupScript::GroupScript(char const* name) : ScriptObject(name) { ScriptRegistry<GroupScript>::Instance()->AddScript(this); } -AreaTriggerEntityScript::AreaTriggerEntityScript(const char* name) +AreaTriggerEntityScript::AreaTriggerEntityScript(char const* name) : ScriptObject(name) { ScriptRegistry<AreaTriggerEntityScript>::Instance()->AddScript(this); diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 375b75264b2..e4765c44bec 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -113,7 +113,7 @@ enum XPColorChar : uint8; protected: - MyScriptType(const char* name, uint32 someId) + MyScriptType(char const* name, uint32 someId) : ScriptObject(name), _someId(someId) { ScriptRegistry<MyScriptType>::AddScript(this); @@ -174,7 +174,7 @@ class TC_GAME_API ScriptObject protected: - ScriptObject(const char* name); + ScriptObject(char const* name); virtual ~ScriptObject(); private: @@ -201,7 +201,7 @@ class TC_GAME_API SpellScriptLoader : public ScriptObject { protected: - SpellScriptLoader(const char* name); + SpellScriptLoader(char const* name); public: @@ -216,7 +216,7 @@ class TC_GAME_API ServerScript : public ScriptObject { protected: - ServerScript(const char* name); + ServerScript(char const* name); public: @@ -246,7 +246,7 @@ class TC_GAME_API WorldScript : public ScriptObject { protected: - WorldScript(const char* name); + WorldScript(char const* name); public: @@ -279,7 +279,7 @@ class TC_GAME_API FormulaScript : public ScriptObject { protected: - FormulaScript(const char* name); + FormulaScript(char const* name); public: @@ -342,7 +342,7 @@ class TC_GAME_API WorldMapScript : public ScriptObject, public MapScript<Map> { protected: - WorldMapScript(const char* name, uint32 mapId); + WorldMapScript(char const* name, uint32 mapId); }; class TC_GAME_API InstanceMapScript @@ -350,26 +350,26 @@ class TC_GAME_API InstanceMapScript { protected: - InstanceMapScript(const char* name, uint32 mapId); + InstanceMapScript(char const* name, uint32 mapId); public: // Gets an InstanceScript object for this instance. - virtual InstanceScript* GetInstanceScript(InstanceMap* /*map*/) const { return NULL; } + virtual InstanceScript* GetInstanceScript(InstanceMap* /*map*/) const { return nullptr; } }; class TC_GAME_API BattlegroundMapScript : public ScriptObject, public MapScript<BattlegroundMap> { protected: - BattlegroundMapScript(const char* name, uint32 mapId); + BattlegroundMapScript(char const* name, uint32 mapId); }; class TC_GAME_API ItemScript : public ScriptObject { protected: - ItemScript(const char* name); + ItemScript(char const* name); public: @@ -393,7 +393,7 @@ class TC_GAME_API UnitScript : public ScriptObject { protected: - UnitScript(const char* name, bool addToScripts = true); + UnitScript(char const* name, bool addToScripts = true); public: // Called when a unit deals healing to another unit @@ -416,7 +416,7 @@ class TC_GAME_API CreatureScript : public UnitScript { protected: - CreatureScript(const char* name); + CreatureScript(char const* name); public: @@ -431,7 +431,7 @@ class TC_GAME_API GameObjectScript : public ScriptObject { protected: - GameObjectScript(const char* name); + GameObjectScript(char const* name); public: @@ -443,7 +443,7 @@ class TC_GAME_API AreaTriggerScript : public ScriptObject { protected: - AreaTriggerScript(const char* name); + AreaTriggerScript(char const* name); public: @@ -468,7 +468,7 @@ class TC_GAME_API BattlegroundScript : public ScriptObject { protected: - BattlegroundScript(const char* name); + BattlegroundScript(char const* name); public: @@ -480,7 +480,7 @@ class TC_GAME_API OutdoorPvPScript : public ScriptObject { protected: - OutdoorPvPScript(const char* name); + OutdoorPvPScript(char const* name); public: @@ -492,7 +492,7 @@ class TC_GAME_API CommandScript : public ScriptObject { protected: - CommandScript(const char* name); + CommandScript(char const* name); public: @@ -504,7 +504,7 @@ class TC_GAME_API WeatherScript : public ScriptObject, public UpdatableScript<We { protected: - WeatherScript(const char* name); + WeatherScript(char const* name); public: @@ -516,7 +516,7 @@ class TC_GAME_API AuctionHouseScript : public ScriptObject { protected: - AuctionHouseScript(const char* name); + AuctionHouseScript(char const* name); public: @@ -537,7 +537,7 @@ class TC_GAME_API ConditionScript : public ScriptObject { protected: - ConditionScript(const char* name); + ConditionScript(char const* name); public: @@ -549,7 +549,7 @@ class TC_GAME_API VehicleScript : public ScriptObject { protected: - VehicleScript(const char* name); + VehicleScript(char const* name); public: @@ -576,14 +576,14 @@ class TC_GAME_API DynamicObjectScript : public ScriptObject, public UpdatableScr { protected: - DynamicObjectScript(const char* name); + DynamicObjectScript(char const* name); }; class TC_GAME_API TransportScript : public ScriptObject, public UpdatableScript<Transport> { protected: - TransportScript(const char* name); + TransportScript(char const* name); public: @@ -604,7 +604,7 @@ class TC_GAME_API AchievementCriteriaScript : public ScriptObject { protected: - AchievementCriteriaScript(const char* name); + AchievementCriteriaScript(char const* name); public: @@ -616,7 +616,7 @@ class TC_GAME_API PlayerScript : public UnitScript { protected: - PlayerScript(const char* name); + PlayerScript(char const* name); public: @@ -722,7 +722,7 @@ class TC_GAME_API AccountScript : public ScriptObject { protected: - AccountScript(const char* name); + AccountScript(char const* name); public: @@ -749,7 +749,7 @@ class TC_GAME_API GuildScript : public ScriptObject { protected: - GuildScript(const char* name); + GuildScript(char const* name); public: @@ -790,7 +790,7 @@ class TC_GAME_API GroupScript : public ScriptObject { protected: - GroupScript(const char* name); + GroupScript(char const* name); public: @@ -801,7 +801,7 @@ class TC_GAME_API GroupScript : public ScriptObject virtual void OnInviteMember(Group* /*group*/, ObjectGuid /*guid*/) { } // Called when a member is removed from a group. - virtual void OnRemoveMember(Group* /*group*/, ObjectGuid /*guid*/, RemoveMethod /*method*/, ObjectGuid /*kicker*/, const char* /*reason*/) { } + virtual void OnRemoveMember(Group* /*group*/, ObjectGuid /*guid*/, RemoveMethod /*method*/, ObjectGuid /*kicker*/, char const* /*reason*/) { } // Called when the leader of a group is changed. virtual void OnChangeLeader(Group* /*group*/, ObjectGuid /*newLeaderGuid*/, ObjectGuid /*oldLeaderGuid*/) { } @@ -814,7 +814,7 @@ class TC_GAME_API AreaTriggerEntityScript : public ScriptObject { protected: - AreaTriggerEntityScript(const char* name); + AreaTriggerEntityScript(char const* name); public: @@ -837,7 +837,7 @@ class TC_GAME_API SceneScript : public ScriptObject { protected: - SceneScript(const char* name); + SceneScript(char const* name); public: // Called when a player start a scene @@ -857,7 +857,7 @@ class TC_GAME_API QuestScript : public ScriptObject { protected: - QuestScript(const char* name); + QuestScript(char const* name); public: // Called when a quest status change @@ -1114,7 +1114,7 @@ class TC_GAME_API ScriptMgr void OnGroupAddMember(Group* group, ObjectGuid guid); void OnGroupInviteMember(Group* group, ObjectGuid guid); - void OnGroupRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, const char* reason); + void OnGroupRemoveMember(Group* group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, char const* reason); void OnGroupChangeLeader(Group* group, ObjectGuid newLeaderGuid, ObjectGuid oldLeaderGuid); void OnGroupDisband(Group* group); diff --git a/src/server/game/Scripting/ScriptSystem.cpp b/src/server/game/Scripting/ScriptSystem.cpp index 0cb051b3cdf..90f01de55fb 100644 --- a/src/server/game/Scripting/ScriptSystem.cpp +++ b/src/server/game/Scripting/ScriptSystem.cpp @@ -111,7 +111,7 @@ void SystemMgr::LoadScriptSplineChains() uint32 entry = fieldsMeta[0].GetUInt32(); uint16 chainId = fieldsMeta[1].GetUInt16(); uint8 splineId = fieldsMeta[2].GetUInt8(); - std::vector<SplineChainLink>& chain = m_mSplineChainsMap[{entry,chainId}]; + std::vector<SplineChainLink>& chain = m_mSplineChainsMap[{entry, chainId}]; if (splineId != chain.size()) { diff --git a/src/server/game/Server/Packets/EquipmentSetPackets.cpp b/src/server/game/Server/Packets/EquipmentSetPackets.cpp index e4b8aadf00e..3ef50d4d525 100644 --- a/src/server/game/Server/Packets/EquipmentSetPackets.cpp +++ b/src/server/game/Server/Packets/EquipmentSetPackets.cpp @@ -37,7 +37,7 @@ WorldPacket const* WorldPackets::EquipmentSet::LoadEquipmentSet::Write() _worldPacket << uint32(equipSet->SetID); _worldPacket << uint32(equipSet->IgnoreMask); - for (std::size_t i = 0; i < EQUIPEMENT_SET_SLOTS; ++i) + for (std::size_t i = 0; i < EQUIPMENT_SET_SLOTS; ++i) { _worldPacket << equipSet->Pieces[i]; _worldPacket << int32(equipSet->Appearances[i]); @@ -67,7 +67,7 @@ void WorldPackets::EquipmentSet::SaveEquipmentSet::Read() _worldPacket >> Set.SetID; _worldPacket >> Set.IgnoreMask; - for (uint8 i = 0; i < EQUIPEMENT_SET_SLOTS; ++i) + for (uint8 i = 0; i < EQUIPMENT_SET_SLOTS; ++i) { _worldPacket >> Set.Pieces[i]; _worldPacket >> Set.Appearances[i]; @@ -97,7 +97,7 @@ void WorldPackets::EquipmentSet::UseEquipmentSet::Read() { _worldPacket >> Inv; - for (uint8 i = 0; i < EQUIPEMENT_SET_SLOTS; ++i) + for (uint8 i = 0; i < EQUIPMENT_SET_SLOTS; ++i) { _worldPacket >> Items[i].Item; _worldPacket >> Items[i].ContainerSlot; diff --git a/src/server/game/Server/Packets/EquipmentSetPackets.h b/src/server/game/Server/Packets/EquipmentSetPackets.h index 609372d1789..a36c95829e0 100644 --- a/src/server/game/Server/Packets/EquipmentSetPackets.h +++ b/src/server/game/Server/Packets/EquipmentSetPackets.h @@ -18,7 +18,7 @@ #pragma once #include "Packet.h" -#include "EquipementSet.h" +#include "EquipmentSet.h" #include "ItemPacketsCommon.h" namespace WorldPackets @@ -82,7 +82,7 @@ namespace WorldPackets }; WorldPackets::Item::InvUpdate Inv; - EquipmentSetItem Items[EQUIPEMENT_SET_SLOTS]; + EquipmentSetItem Items[EQUIPMENT_SET_SLOTS]; uint64 GUID = 0; ///< Set Identifier }; diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index aec308cee5e..15a3b354d42 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -271,11 +271,11 @@ void WorldSession::SendPacket(WorldPacket const* packet, bool forced /*= false*/ if ((cur_time - lastTime) < 60) { - sendPacketCount+=1; - sendPacketBytes+=packet->size(); + sendPacketCount += 1; + sendPacketBytes += packet->size(); - sendLastPacketCount+=1; - sendLastPacketBytes+=packet->size(); + sendLastPacketCount += 1; + sendLastPacketBytes += packet->size(); } else { @@ -303,7 +303,7 @@ void WorldSession::QueuePacket(WorldPacket* new_packet) } /// Logging helper for unexpected opcodes -void WorldSession::LogUnexpectedOpcode(WorldPacket* packet, const char* status, const char *reason) +void WorldSession::LogUnexpectedOpcode(WorldPacket* packet, char const* status, const char *reason) { TC_LOG_ERROR("network.opcode", "Received unexpected opcode %s Status: %s Reason: %s from %s", GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str(), status, reason, GetPlayerInfo().c_str()); @@ -551,7 +551,7 @@ void WorldSession::LogoutPlayer(bool save) } } - // Repop at GraveYard or other player far teleport will prevent saving player because of not present map + // Repop at Graveyard or other player far teleport will prevent saving player because of not present map // Teleport player immediately for correct player save while (_player->IsBeingTeleportedFar()) HandleMoveWorldportAck(); diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 8027cec4f43..34c698f2a7f 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -1809,7 +1809,7 @@ class TC_GAME_API WorldSession bool CanUseBank(ObjectGuid bankerGUID = ObjectGuid::Empty) const; // logging helper - void LogUnexpectedOpcode(WorldPacket* packet, const char* status, const char *reason); + void LogUnexpectedOpcode(WorldPacket* packet, char const* status, const char *reason); // EnumData helpers bool IsLegitCharacterForAccount(ObjectGuid lowGUID) diff --git a/src/server/game/Skills/SkillDiscovery.cpp b/src/server/game/Skills/SkillDiscovery.cpp index 1117589d0ab..5dd988f8a73 100644 --- a/src/server/game/Skills/SkillDiscovery.cpp +++ b/src/server/game/Skills/SkillDiscovery.cpp @@ -15,16 +15,16 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "SkillDiscovery.h" #include "DatabaseEnv.h" #include "DB2Stores.h" #include "Log.h" -#include "World.h" -#include "Util.h" -#include "SkillDiscovery.h" -#include "SpellMgr.h" #include "Player.h" #include "Random.h" +#include "SpellMgr.h" #include "SpellInfo.h" +#include "Util.h" +#include "World.h" #include <map> #include <sstream> diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 5c618b76954..95e68152182 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -4873,7 +4873,7 @@ void AuraEffect::HandleChannelDeathItem(AuraApplication const* aurApp, uint8 mod InventoryResult msg = plCaster->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, GetSpellEffectInfo()->ItemType, count, &noSpaceForCount); if (msg != EQUIP_ERR_OK) { - count-=noSpaceForCount; + count -= noSpaceForCount; plCaster->SendEquipError(msg, nullptr, nullptr, GetSpellEffectInfo()->ItemType); if (count == 0) return; diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h index 7f315de9a54..730d177e2b4 100644 --- a/src/server/game/Spells/Auras/SpellAuras.h +++ b/src/server/game/Spells/Auras/SpellAuras.h @@ -230,7 +230,7 @@ class TC_GAME_API Aura // Helpers for targets ApplicationMap const& GetApplicationMap() { return m_applications; } void GetApplicationList(Unit::AuraApplicationList& applicationList) const; - const AuraApplication* GetApplicationOfTarget(ObjectGuid guid) const { ApplicationMap::const_iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return nullptr; } + AuraApplication const* GetApplicationOfTarget(ObjectGuid guid) const { ApplicationMap::const_iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return nullptr; } AuraApplication* GetApplicationOfTarget(ObjectGuid guid) { ApplicationMap::iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return nullptr; } bool IsAppliedOnTarget(ObjectGuid guid) const { return m_applications.find(guid) != m_applications.end(); } @@ -281,7 +281,7 @@ class TC_GAME_API Aura bool CallScriptEffectProcHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, ProcEventInfo& eventInfo); void CallScriptAfterEffectProcHandlers(AuraEffect const* aurEff, AuraApplication const* aurApp, ProcEventInfo& eventInfo); - template<class Script> + template <class Script> Script* GetScript(std::string const& scriptName) const { return dynamic_cast<Script*>(GetScriptByName(scriptName)); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index bc68a92561c..c7678330cec 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -3173,7 +3173,7 @@ void Spell::_cast(bool skipCheck) // As of 3.0.2 pets begin attacking their owner's target immediately // Let any pets know we've attacked something. Check DmgClass for harmful spells only // This prevents spells such as Hunter's Mark from triggering pet attack - if (this->GetSpellInfo()->DmgClass != SPELL_DAMAGE_CLASS_NONE) + if (GetSpellInfo()->DmgClass != SPELL_DAMAGE_CLASS_NONE) if (Unit* unitTarget = m_targets.GetUnitTarget()) for (Unit* controlled : playerCaster->m_Controlled) if (Creature* cControlled = controlled->ToCreature()) @@ -4024,7 +4024,7 @@ void Spell::SendCastResult(Player* caster, SpellInfo const* spellInfo, uint32 sp WorldPackets::Spells::CastFailed packet; packet.SpellXSpellVisualID = spellVisual; FillSpellCastFailedArgs(packet, cast_count, spellInfo, result, customError, param1, param2, caster); - caster->GetSession()->SendPacket(packet.Write()); + caster->SendDirectMessage(packet.Write()); } void Spell::SendMountResult(MountResult result) @@ -4551,21 +4551,15 @@ void Spell::SendResurrectRequest(Player* target) WorldPackets::Spells::ResurrectRequest resurrectRequest; resurrectRequest.ResurrectOffererGUID = m_caster->GetGUID(); resurrectRequest.ResurrectOffererVirtualRealmAddress = GetVirtualRealmAddress(); - + resurrectRequest.Name = sentName; + resurrectRequest.Sickness = m_caster->GetTypeId() != TYPEID_PLAYER && m_caster->IsSpiritHealer(); // "you'll be afflicted with resurrection sickness" + resurrectRequest.UseTimer = !m_spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_RESURRECTION_TIMER); if (Pet* pet = target->GetPet()) - { if (CharmInfo* charmInfo = pet->GetCharmInfo()) resurrectRequest.PetNumber = charmInfo->GetPetNumber(); - } resurrectRequest.SpellID = m_spellInfo->Id; - - //packet.ReadBit("UseTimer"); /// @todo: 6.x Has to be implemented - resurrectRequest.Sickness = m_caster->GetTypeId() != TYPEID_PLAYER; // "you'll be afflicted with resurrection sickness" - - resurrectRequest.Name = sentName; - - target->GetSession()->SendPacket(resurrectRequest.Write()); + target->SendDirectMessage(resurrectRequest.Write()); } void Spell::TakeCastItem() @@ -4991,7 +4985,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint m_needComboPoints = false; if ((*j)->GetMiscValue() == 1) { - reqCombat=false; + reqCombat = false; break; } } diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index fdec7c09a13..712e6a365c8 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -954,4 +954,5 @@ namespace Trinity } typedef void(Spell::*pEffect)(SpellEffIndex effIndex); + #endif diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index c13ea7388e9..e08f7231605 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -2683,7 +2683,7 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex) pet->SetCreatedBySpell(m_spellInfo->Id); // generate new name for summon pet - std::string new_name=sObjectMgr->GeneratePetName(petentry); + std::string new_name = sObjectMgr->GeneratePetName(petentry); if (!new_name.empty()) pet->SetName(new_name); diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index f8967a2f23a..3c2ea638171 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -17,7 +17,6 @@ #include "SpellInfo.h" #include "Battleground.h" -#include "ConditionMgr.h" #include "Corpse.h" #include "DB2Stores.h" #include "GameTables.h" @@ -3627,6 +3626,7 @@ float SpellInfo::GetMaxRange(bool positive, Unit* caster, Spell* spell) const if (caster) if (Player* modOwner = caster->GetSpellModOwner()) modOwner->ApplySpellMod(Id, SPELLMOD_RANGE, range, spell); + return range; } diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp index 10722473019..638f69d8721 100644 --- a/src/server/game/Spells/SpellScript.cpp +++ b/src/server/game/Spells/SpellScript.cpp @@ -44,6 +44,7 @@ bool _SpellScript::_ValidateSpellInfo(uint32 const* begin, uint32 const* end) TC_LOG_ERROR("scripts.spells", "_SpellScript::ValidateSpellInfo: Spell %u does not exist.", *begin); allValid = false; } + ++begin; } return allValid; diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index e0cca835925..e5a9fb5b491 100644 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -148,13 +148,13 @@ class TC_GAME_API _SpellScript return _ValidateSpellInfo(spellIds.begin(), spellIds.end()); } - template<class T> + template <class T> static bool ValidateSpellInfo(T const& spellIds) { return _ValidateSpellInfo(std::begin(spellIds), std::end(spellIds)); } -private: + private: static bool _ValidateSpellInfo(uint32 const* begin, uint32 const* end); }; diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index 30f578aa872..9e27747c60a 100644 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -334,7 +334,7 @@ void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket const* if (!whisperTarget || whisperTarget->GetTypeId() != TYPEID_PLAYER) return; - whisperTarget->ToPlayer()->GetSession()->SendPacket(data); + whisperTarget->ToPlayer()->SendDirectMessage(data); return; } break; diff --git a/src/server/game/Texts/CreatureTextMgr.h b/src/server/game/Texts/CreatureTextMgr.h index c24884582a5..cc76ae1588b 100644 --- a/src/server/game/Texts/CreatureTextMgr.h +++ b/src/server/game/Texts/CreatureTextMgr.h @@ -101,7 +101,7 @@ class TC_GAME_API CreatureTextMgr bool TextExist(uint32 sourceEntry, uint8 textGroup) const; std::string GetLocalizedChatString(uint32 entry, uint8 gender, uint8 textGroup, uint32 id, LocaleConstant locale) const; - template<class Builder> + template <class Builder> static void SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, WorldObject const* whisperTarget = nullptr, CreatureTextRange range = TEXT_RANGE_NORMAL, Team team = TEAM_OTHER, bool gmOnly = false); private: diff --git a/src/server/game/Time/GameTime.h b/src/server/game/Time/GameTime.h index b21b0d1c064..cb1f7d337f0 100644 --- a/src/server/game/Time/GameTime.h +++ b/src/server/game/Time/GameTime.h @@ -19,7 +19,6 @@ #define __GAMETIME_H #include "Define.h" - #include <chrono> namespace GameTime diff --git a/src/server/game/Tools/CharacterDatabaseCleaner.cpp b/src/server/game/Tools/CharacterDatabaseCleaner.cpp index 86210d8f56e..4f67878885e 100644 --- a/src/server/game/Tools/CharacterDatabaseCleaner.cpp +++ b/src/server/game/Tools/CharacterDatabaseCleaner.cpp @@ -18,10 +18,10 @@ #include "Common.h" #include "CriteriaHandler.h" #include "CharacterDatabaseCleaner.h" +#include "DatabaseEnv.h" #include "DB2Stores.h" #include "Log.h" #include "World.h" -#include "Database/DatabaseEnv.h" #include "SpellMgr.h" #include "SpellInfo.h" #include <sstream> @@ -69,7 +69,7 @@ void CharacterDatabaseCleaner::CleanDatabase() TC_LOG_INFO("server.loading", ">> Cleaned character database in %u ms", GetMSTimeDiffToNow(oldMSTime)); } -void CharacterDatabaseCleaner::CheckUnique(const char* column, const char* table, bool (*check)(uint32)) +void CharacterDatabaseCleaner::CheckUnique(char const* column, char const* table, bool (*check)(uint32)) { QueryResult result = CharacterDatabase.PQuery("SELECT DISTINCT %s FROM %s", column, table); if (!result) diff --git a/src/server/game/Tools/CharacterDatabaseCleaner.h b/src/server/game/Tools/CharacterDatabaseCleaner.h index d1cec3575bc..83a639f99ab 100644 --- a/src/server/game/Tools/CharacterDatabaseCleaner.h +++ b/src/server/game/Tools/CharacterDatabaseCleaner.h @@ -31,7 +31,7 @@ namespace CharacterDatabaseCleaner TC_GAME_API void CleanDatabase(); - TC_GAME_API void CheckUnique(const char* column, const char* table, bool (*check)(uint32)); + TC_GAME_API void CheckUnique(char const* column, char const* table, bool (*check)(uint32)); TC_GAME_API bool AchievementProgressCheck(uint32 criteria); TC_GAME_API bool SkillCheck(uint32 skill); diff --git a/src/server/game/Warden/Warden.cpp b/src/server/game/Warden/Warden.cpp index d8255c96e7a..7e44537215a 100644 --- a/src/server/game/Warden/Warden.cpp +++ b/src/server/game/Warden/Warden.cpp @@ -139,7 +139,7 @@ void Warden::EncryptData(uint8* buffer, uint32 length) _outputCrypto.UpdateData(buffer, length); } -bool Warden::IsValidCheckSum(uint32 checksum, const uint8* data, const uint16 length) +bool Warden::IsValidCheckSum(uint32 checksum, uint8 const* data, const uint16 length) { uint32 newChecksum = BuildChecksum(data, length); @@ -170,7 +170,7 @@ struct keyData { }; }; -uint32 Warden::BuildChecksum(const uint8* data, uint32 length) +uint32 Warden::BuildChecksum(uint8 const* data, uint32 length) { keyData hash; SHA1(data, length, hash.bytes.bytes); diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index e7335bb766f..f4a1a4fc2aa 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -60,6 +60,7 @@ #include "IPLocation.h" #include "Language.h" #include "LFGMgr.h" +#include "Log.h" #include "LootItemStorage.h" #include "LootMgr.h" #include "M2Stores.h" @@ -68,7 +69,6 @@ #include "Metric.h" #include "MiscPackets.h" #include "MMapFactory.h" -#include "Object.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "OutdoorPvPMgr.h" @@ -1405,7 +1405,7 @@ void World::LoadConfigSettings(bool reload) #if TRINITY_PLATFORM == TRINITY_PLATFORM_UNIX || TRINITY_PLATFORM == TRINITY_PLATFORM_APPLE if (dataPath[0] == '~') { - const char* home = getenv("HOME"); + char const* home = getenv("HOME"); if (home) dataPath.replace(0, 1, home); } @@ -2779,7 +2779,7 @@ void World::SendGMText(uint32 string_id, ...) } /// DEPRECATED, only for debug purpose. Send a System Message to all players (except self if mentioned) -void World::SendGlobalText(const char* text, WorldSession* self) +void World::SendGlobalText(char const* text, WorldSession* self) { // need copy to prevent corruption by strtok call in LineFromMessage original string char* buf = strdup(text); @@ -2819,7 +2819,7 @@ bool World::SendZoneMessage(uint32 zone, WorldPacket const* packet, WorldSession } /// Send a System Message to all players in the zone (except self if mentioned) -void World::SendZoneText(uint32 zone, const char* text, WorldSession* self, uint32 team) +void World::SendZoneText(uint32 zone, char const* text, WorldSession* self, uint32 team) { WorldPackets::Chat::Chat packet; packet.Initialize(CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, text); @@ -3142,7 +3142,7 @@ void World::SendServerMessage(ServerMessageType messageID, std::string stringPar chatServerMessage.StringParam = stringParam; if (player) - player->GetSession()->SendPacket(chatServerMessage.Write()); + player->SendDirectMessage(chatServerMessage.Write()); else SendGlobalMessage(chatServerMessage.Write()); } @@ -3258,9 +3258,9 @@ void World::_UpdateRealmCharCount(PreparedQueryResult resultCharCount) void World::InitWeeklyQuestResetTime() { - time_t wstime = sWorld->getWorldState(WS_WEEKLY_QUEST_RESET_TIME); + time_t wstime = uint64(sWorld->getWorldState(WS_WEEKLY_QUEST_RESET_TIME)); time_t curtime = time(nullptr); - m_NextWeeklyQuestReset = wstime < curtime ? curtime : wstime; + m_NextWeeklyQuestReset = wstime < curtime ? curtime : time_t(wstime); } void World::InitDailyQuestResetTime(bool loading) @@ -3300,16 +3300,16 @@ void World::InitDailyQuestResetTime(bool loading) void World::InitMonthlyQuestResetTime() { - time_t wstime = sWorld->getWorldState(WS_MONTHLY_QUEST_RESET_TIME); + time_t wstime = uint64(sWorld->getWorldState(WS_MONTHLY_QUEST_RESET_TIME)); time_t curtime = time(nullptr); - m_NextMonthlyQuestReset = wstime < curtime ? curtime : wstime; + m_NextMonthlyQuestReset = wstime < curtime ? curtime : time_t(wstime); } void World::InitRandomBGResetTime() { time_t bgtime = sWorld->getWorldState(WS_BG_DAILY_RESET_TIME); if (!bgtime) - m_NextRandomBGReset = time(nullptr); // game time not yet init + m_NextRandomBGReset = time(nullptr); // game time not yet init // generate time by config time_t curTime = time(nullptr); @@ -3337,7 +3337,7 @@ void World::InitGuildResetTime() { time_t gtime = getWorldState(WS_GUILD_DAILY_RESET_TIME); if (!gtime) - m_NextGuildReset = time(nullptr); // game time not yet init + m_NextGuildReset = time(nullptr); // game time not yet init // generate time by config time_t curTime = time(nullptr); diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index cd14025fce1..1f32f9630fb 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -560,13 +560,12 @@ enum WorldStates /// Storage class for commands issued for delayed execution struct TC_GAME_API CliCommandHolder { - typedef void(*Print)(void*, const char*); + typedef void(*Print)(void*, char const*); typedef void(*CommandFinished)(void*, bool success); void* m_callbackArg; - char *m_command; + char* m_command; Print m_print; - CommandFinished m_commandFinished; CliCommandHolder(void* callbackArg, char const* command, Print zprint, CommandFinished commandFinished); @@ -594,7 +593,7 @@ class TC_GAME_API World bool RemoveSession(uint32 id); /// Get the number of current active sessions void UpdateMaxSessionCounters(); - const SessionMap& GetAllSessions() const { return m_sessions; } + SessionMap const& GetAllSessions() const { return m_sessions; } uint32 GetActiveAndQueuedSessionCount() const { return uint32(m_sessions.size()); } uint32 GetActiveSessionCount() const { return uint32(m_sessions.size() - m_QueuedPlayer.size()); } uint32 GetQueuedSessionCount() const { return uint32(m_QueuedPlayer.size()); } @@ -673,7 +672,7 @@ class TC_GAME_API World void LoadConfigSettings(bool reload = false); void SendWorldText(uint32 string_id, ...); - void SendGlobalText(const char* text, WorldSession* self); + void SendGlobalText(char const* text, WorldSession* self); void SendGMText(uint32 string_id, ...); void SendServerMessage(ServerMessageType messageID, std::string stringParam = "", Player* player = nullptr); void SendGlobalMessage(WorldPacket const* packet, WorldSession* self = nullptr, uint32 team = 0); |