aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/ScriptedAI
diff options
context:
space:
mode:
authorccrs <ccrs@users.noreply.github.com>2019-05-15 01:33:55 +0200
committerccrs <ccrs@users.noreply.github.com>2019-05-15 01:33:55 +0200
commit179c7da1fc264b1444aa50632317e16dca02f78b (patch)
treec55bedd307f4af55636778e4082305d4fefcde0a /src/server/game/AI/ScriptedAI
parent7025b0065646e0d70ba2ca0ef807ff4e9d8612ce (diff)
Core/AI: variable naming standarization
plus minimum codestyle changes
Diffstat (limited to 'src/server/game/AI/ScriptedAI')
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp34
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.h28
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp30
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h14
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedGossip.cpp48
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedGossip.h1
6 files changed, 93 insertions, 62 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index 81cf82c440a..c88da8e76a5 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -40,19 +40,19 @@ struct TSpellSummary
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))
@@ -64,14 +64,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
@@ -81,10 +81,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();
}
@@ -92,20 +92,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;
}
@@ -117,7 +117,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 94a27265a7a..e97430bed3f 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h
@@ -35,52 +35,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);
@@ -91,14 +89,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);
}
@@ -110,8 +108,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 a8196f67a5a..e1f8783272a 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.cpp
@@ -40,9 +40,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)
@@ -127,7 +127,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.
@@ -138,16 +138,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);
@@ -189,7 +189,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))
{
@@ -237,10 +237,10 @@ void FollowerAI::UpdateAI(uint32 uiDiff)
return;
}
- m_uiUpdateFollowTimer = 1000;
+ _updateFollowTimer = 1000;
}
else
- m_uiUpdateFollowTimer -= uiDiff;
+ _updateFollowTimer -= uiDiff;
}
UpdateFollowerAI(uiDiff);
@@ -286,12 +286,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 a9a6c2eb711..b00fb5ddba9 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h
+++ b/src/server/game/AI/ScriptedAI/ScriptedFollowerAI.h
@@ -61,22 +61,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 b0675608522..e619cd503db 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedGossip.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedGossip.cpp
@@ -19,14 +19,46 @@
#include "Player.h"
#include "Creature.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, uint32 icon, std::string const& text, uint32 sender, uint32 action) { player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, icon, text, sender, action, "", 0); }
+void AddGossipItemFor(Player* player, uint32 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, uint32 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, uint32 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();
+}
diff --git a/src/server/game/AI/ScriptedAI/ScriptedGossip.h b/src/server/game/AI/ScriptedAI/ScriptedGossip.h
index ef9ddac11bf..58a9f2b2bfe 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedGossip.h
+++ b/src/server/game/AI/ScriptedAI/ScriptedGossip.h
@@ -81,6 +81,7 @@ enum eTradeskill
};
class Creature;
+
uint32 TC_GAME_API GetGossipActionFor(Player* player, uint32 gossipListId);
void TC_GAME_API ClearGossipMenuFor(Player* player);
// Using provided text, not from DB