diff options
| author | ccrs <ccrs@users.noreply.github.com> | 2019-05-15 01:33:55 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-12-05 16:17:02 +0100 |
| commit | dd11603150e73ebaf94100af65625b3cbfb1093e (patch) | |
| tree | 554ea305e67c783cde0a6d1cc43d48eb8ac3ab9b /src/server/game/AI/ScriptedAI | |
| parent | 6efb8d2d22f65b5267033366c502455c3c13286e (diff) | |
Core/AI: variable naming standarization
plus minimum codestyle changes
(cherry picked from commit 179c7da1fc264b1444aa50632317e16dca02f78b)
Diffstat (limited to 'src/server/game/AI/ScriptedAI')
| -rw-r--r-- | src/server/game/AI/ScriptedAI/ScriptedCreature.cpp | 34 | ||||
| -rw-r--r-- | src/server/game/AI/ScriptedAI/ScriptedCreature.h | 28 | ||||
| -rw-r--r-- | src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp | 30 | ||||
| -rw-r--r-- | src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h | 14 | ||||
| -rw-r--r-- | src/server/game/AI/ScriptedAI/ScriptedGossip.cpp | 48 |
5 files changed, 92 insertions, 62 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp index 69681e171aa..32ba4bdf5a1 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp @@ -33,19 +33,19 @@ void SummonList::Summon(Creature const* summon) { - storage_.push_back(summon->GetGUID()); + _storage.push_back(summon->GetGUID()); } void SummonList::Despawn(Creature const* summon) { - storage_.remove(summon->GetGUID()); + _storage.remove(summon->GetGUID()); } void SummonList::DoZoneInCombat(uint32 entry) { - for (StorageType::iterator i = storage_.begin(); i != storage_.end();) + for (StorageType::iterator i = _storage.begin(); i != _storage.end();) { - Creature* summon = ObjectAccessor::GetCreature(*me, *i); + Creature* summon = ObjectAccessor::GetCreature(*_me, *i); ++i; if (summon && summon->IsAIEnabled() && (!entry || summon->GetEntry() == entry)) @@ -57,14 +57,14 @@ void SummonList::DoZoneInCombat(uint32 entry) void SummonList::DespawnEntry(uint32 entry) { - for (StorageType::iterator i = storage_.begin(); i != storage_.end();) + for (StorageType::iterator i = _storage.begin(); i != _storage.end();) { - Creature* summon = ObjectAccessor::GetCreature(*me, *i); + Creature* summon = ObjectAccessor::GetCreature(*_me, *i); if (!summon) - i = storage_.erase(i); + i = _storage.erase(i); else if (summon->GetEntry() == entry) { - i = storage_.erase(i); + i = _storage.erase(i); summon->DespawnOrUnsummon(); } else @@ -74,10 +74,10 @@ void SummonList::DespawnEntry(uint32 entry) void SummonList::DespawnAll() { - while (!storage_.empty()) + while (!_storage.empty()) { - Creature* summon = ObjectAccessor::GetCreature(*me, storage_.front()); - storage_.pop_front(); + Creature* summon = ObjectAccessor::GetCreature(*_me, _storage.front()); + _storage.pop_front(); if (summon) summon->DespawnOrUnsummon(); } @@ -85,20 +85,20 @@ void SummonList::DespawnAll() void SummonList::RemoveNotExisting() { - for (StorageType::iterator i = storage_.begin(); i != storage_.end();) + for (StorageType::iterator i = _storage.begin(); i != _storage.end();) { - if (ObjectAccessor::GetCreature(*me, *i)) + if (ObjectAccessor::GetCreature(*_me, *i)) ++i; else - i = storage_.erase(i); + i = _storage.erase(i); } } bool SummonList::HasEntry(uint32 entry) const { - for (StorageType::const_iterator i = storage_.begin(); i != storage_.end(); ++i) + for (StorageType::const_iterator i = _storage.begin(); i != _storage.end(); ++i) { - Creature* summon = ObjectAccessor::GetCreature(*me, *i); + Creature* summon = ObjectAccessor::GetCreature(*_me, *i); if (summon && summon->GetEntry() == entry) return true; } @@ -110,7 +110,7 @@ void SummonList::DoActionImpl(int32 action, StorageType const& summons) { for (auto const& guid : summons) { - Creature* summon = ObjectAccessor::GetCreature(*me, guid); + Creature* summon = ObjectAccessor::GetCreature(*_me, guid); if (summon && summon->IsAIEnabled()) summon->AI()->DoAction(action); } diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h index bc7d558e87e..f6f9f23a322 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h @@ -36,52 +36,50 @@ public: typedef StorageType::size_type size_type; typedef StorageType::value_type value_type; - explicit SummonList(Creature* creature) - : me(creature) - { } + explicit SummonList(Creature* creature) : _me(creature) { } // And here we see a problem of original inheritance approach. People started // to exploit presence of std::list members, so I have to provide wrappers iterator begin() { - return storage_.begin(); + return _storage.begin(); } const_iterator begin() const { - return storage_.begin(); + return _storage.begin(); } iterator end() { - return storage_.end(); + return _storage.end(); } const_iterator end() const { - return storage_.end(); + return _storage.end(); } iterator erase(iterator i) { - return storage_.erase(i); + return _storage.erase(i); } bool empty() const { - return storage_.empty(); + return _storage.empty(); } size_type size() const { - return storage_.size(); + return _storage.size(); } // Clear the underlying storage. This does NOT despawn the creatures - use DespawnAll for that! void clear() { - storage_.clear(); + _storage.clear(); } void Summon(Creature const* summon); @@ -92,14 +90,14 @@ public: template <typename T> void DespawnIf(T const& predicate) { - storage_.remove_if(predicate); + _storage.remove_if(predicate); } template <class Predicate> void DoAction(int32 info, Predicate&& predicate, uint16 max = 0) { // We need to use a copy of SummonList here, otherwise original SummonList would be modified - StorageType listCopy = storage_; + StorageType listCopy = _storage; Trinity::Containers::RandomResize<StorageType, Predicate>(listCopy, std::forward<Predicate>(predicate), max); DoActionImpl(info, listCopy); } @@ -111,8 +109,8 @@ public: private: void DoActionImpl(int32 action, StorageType const& summons); - Creature* me; - StorageType storage_; + Creature* _me; + StorageType _storage; }; class TC_GAME_API EntryCheckPredicate diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp index 30cec2a814d..156daa0aed9 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp @@ -39,9 +39,9 @@ enum Points }; FollowerAI::FollowerAI(Creature* creature) : ScriptedAI(creature), - m_uiUpdateFollowTimer(2500), - m_uiFollowState(STATE_FOLLOW_NONE), - m_pQuestForFollow(nullptr) + _updateFollowTimer(2500), + _followState(STATE_FOLLOW_NONE), + _questForFollow(nullptr) { } void FollowerAI::AttackStart(Unit* who) @@ -126,7 +126,7 @@ void FollowerAI::MoveInLineOfSight(Unit* who) void FollowerAI::JustDied(Unit* /*killer*/) { - if (!HasFollowState(STATE_FOLLOW_INPROGRESS) || !m_uiLeaderGUID || !m_pQuestForFollow) + if (!HasFollowState(STATE_FOLLOW_INPROGRESS) || !_leaderGUID || !_questForFollow) return; /// @todo need a better check for quests with time limit. @@ -137,16 +137,16 @@ void FollowerAI::JustDied(Unit* /*killer*/) for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next()) if (Player* member = groupRef->GetSource()) if (member->IsInMap(player)) - member->FailQuest(m_pQuestForFollow->GetQuestId()); + member->FailQuest(_questForFollow->GetQuestId()); } else - player->FailQuest(m_pQuestForFollow->GetQuestId()); + player->FailQuest(_questForFollow->GetQuestId()); } } void FollowerAI::JustAppeared() { - m_uiFollowState = STATE_FOLLOW_NONE; + _followState = STATE_FOLLOW_NONE; if (!IsCombatMovementAllowed()) SetCombatMovement(true); @@ -188,7 +188,7 @@ void FollowerAI::UpdateAI(uint32 uiDiff) { if (HasFollowState(STATE_FOLLOW_INPROGRESS) && !me->GetVictim()) { - if (m_uiUpdateFollowTimer <= uiDiff) + if (_updateFollowTimer <= uiDiff) { if (HasFollowState(STATE_FOLLOW_COMPLETE) && !HasFollowState(STATE_FOLLOW_POSTEVENT)) { @@ -236,10 +236,10 @@ void FollowerAI::UpdateAI(uint32 uiDiff) return; } - m_uiUpdateFollowTimer = 1000; + _updateFollowTimer = 1000; } else - m_uiUpdateFollowTimer -= uiDiff; + _updateFollowTimer -= uiDiff; } UpdateFollowerAI(uiDiff); @@ -285,12 +285,12 @@ void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, Quest co } //set variables - m_uiLeaderGUID = player->GetGUID(); + _leaderGUID = player->GetGUID(); if (factionForFollower) me->SetFaction(factionForFollower); - m_pQuestForFollow = quest; + _questForFollow = quest; if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE) { @@ -306,12 +306,12 @@ void FollowerAI::StartFollow(Player* player, uint32 factionForFollower, Quest co me->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); - TC_LOG_DEBUG("scripts", "FollowerAI start follow %s (%s)", player->GetName().c_str(), m_uiLeaderGUID.ToString().c_str()); + TC_LOG_DEBUG("scripts", "FollowerAI start follow %s (%s)", player->GetName().c_str(), _leaderGUID.ToString().c_str()); } Player* FollowerAI::GetLeaderForFollower() { - if (Player* player = ObjectAccessor::GetPlayer(*me, m_uiLeaderGUID)) + if (Player* player = ObjectAccessor::GetPlayer(*me, _leaderGUID)) { if (player->IsAlive()) return player; @@ -325,7 +325,7 @@ Player* FollowerAI::GetLeaderForFollower() if (member && me->IsWithinDistInMap(member, MAX_PLAYER_DISTANCE) && member->IsAlive()) { TC_LOG_DEBUG("scripts", "FollowerAI GetLeader changed and returned new leader."); - m_uiLeaderGUID = member->GetGUID(); + _leaderGUID = member->GetGUID(); return member; } } diff --git a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h index 39c5da0e8ae..f0f8fbb26a1 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h +++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h @@ -60,22 +60,22 @@ class TC_GAME_API FollowerAI : public ScriptedAI void SetFollowPaused(bool bPaused); //if special event require follow mode to hold/resume during the follow void SetFollowComplete(bool bWithEndEvent = false); - bool HasFollowState(uint32 uiFollowState) { return (m_uiFollowState & uiFollowState) != 0; } + bool HasFollowState(uint32 uiFollowState) { return (_followState & uiFollowState) != 0; } protected: Player* GetLeaderForFollower(); private: - void AddFollowState(uint32 uiFollowState) { m_uiFollowState |= uiFollowState; } - void RemoveFollowState(uint32 uiFollowState) { m_uiFollowState &= ~uiFollowState; } + void AddFollowState(uint32 uiFollowState) { _followState |= uiFollowState; } + void RemoveFollowState(uint32 uiFollowState) { _followState &= ~uiFollowState; } bool AssistPlayerInCombatAgainst(Unit* who); - ObjectGuid m_uiLeaderGUID; - uint32 m_uiUpdateFollowTimer; - uint32 m_uiFollowState; + ObjectGuid _leaderGUID; + uint32 _updateFollowTimer; + uint32 _followState; - Quest const* m_pQuestForFollow; //normally we have a quest + Quest const* _questForFollow; }; #endif diff --git a/src/server/game/AI/ScriptedAI/ScriptedGossip.cpp b/src/server/game/AI/ScriptedAI/ScriptedGossip.cpp index 4790eee5649..c9b4fe249b4 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedGossip.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedGossip.cpp @@ -19,14 +19,46 @@ #include "Creature.h" #include "Player.h" -uint32 GetGossipActionFor(Player* player, uint32 gossipListId) { return player->PlayerTalkClass->GetGossipOptionAction(gossipListId); } -void ClearGossipMenuFor(Player* player) { player->PlayerTalkClass->ClearMenus(); } +uint32 GetGossipActionFor(Player* player, uint32 gossipListId) +{ + return player->PlayerTalkClass->GetGossipOptionAction(gossipListId); +} + +void ClearGossipMenuFor(Player* player) +{ + player->PlayerTalkClass->ClearMenus(); +} + // Using provided text, not from DB -void AddGossipItemFor(Player* player, GossipOptionIcon icon, std::string const& text, uint32 sender, uint32 action) { player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, icon, text, sender, action, "", 0); } +void AddGossipItemFor(Player* player, GossipOptionIcon icon, std::string const& text, uint32 sender, uint32 action) +{ + player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, icon, text, sender, action, "", 0); +} + // Using provided texts, not from DB -void AddGossipItemFor(Player* player, GossipOptionIcon icon, std::string const& text, uint32 sender, uint32 action, std::string const& popupText, uint32 popupMoney, bool coded) { player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, icon, text, sender, action, popupText, popupMoney, coded); } +void AddGossipItemFor(Player* player, GossipOptionIcon icon, std::string const& text, uint32 sender, uint32 action, std::string const& popupText, uint32 popupMoney, bool coded) +{ + player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, icon, text, sender, action, popupText, popupMoney, coded); +} + // Uses gossip item info from DB -void AddGossipItemFor(Player* player, uint32 gossipMenuID, uint32 gossipMenuItemID, uint32 sender, uint32 action) { player->PlayerTalkClass->GetGossipMenu().AddMenuItem(gossipMenuID, gossipMenuItemID, sender, action); } -void SendGossipMenuFor(Player* player, uint32 npcTextID, ObjectGuid const& guid) { player->PlayerTalkClass->SendGossipMenu(npcTextID, guid); } -void SendGossipMenuFor(Player* player, uint32 npcTextID, Creature const* creature) { if (creature) SendGossipMenuFor(player, npcTextID, creature->GetGUID()); } -void CloseGossipMenuFor(Player* player) { player->PlayerTalkClass->SendCloseGossip(); } +void AddGossipItemFor(Player* player, uint32 gossipMenuID, uint32 gossipMenuItemID, uint32 sender, uint32 action) +{ + player->PlayerTalkClass->GetGossipMenu().AddMenuItem(gossipMenuID, gossipMenuItemID, sender, action); +} + +void SendGossipMenuFor(Player* player, uint32 npcTextID, ObjectGuid const& guid) +{ + player->PlayerTalkClass->SendGossipMenu(npcTextID, guid); +} + +void SendGossipMenuFor(Player* player, uint32 npcTextID, Creature const* creature) +{ + if (creature) + SendGossipMenuFor(player, npcTextID, creature->GetGUID()); +} + +void CloseGossipMenuFor(Player* player) +{ + player->PlayerTalkClass->SendCloseGossip(); +} |
