aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/SmartScripts
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2025-07-11 17:40:34 +0200
committerShauren <shauren.trinity@gmail.com>2025-07-11 17:40:34 +0200
commitcbb532e4bec11d59f2072441a43b7c797de6d16d (patch)
tree27a0dc63805e527d2f47744963fc2f341493ce27 /src/server/game/AI/SmartScripts
parentae197a62b77cd93799571b16756c372081704929 (diff)
Core/Groups: Use iterators instead of raw LinkedListElement to interact with group members
Diffstat (limited to 'src/server/game/AI/SmartScripts')
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp8
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp7
2 files changed, 7 insertions, 8 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index 11f645bc6da..de5fbddfb5a 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -202,9 +202,9 @@ void SmartAI::EndPath(bool fail)
if (Group* group = player->GetGroup())
{
- for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
+ for (GroupReference const& groupRef : group->GetMembers())
{
- Player* groupGuy = groupRef->GetSource();
+ Player* groupGuy = groupRef.GetSource();
if (!groupGuy->IsInMap(player))
continue;
@@ -306,9 +306,9 @@ bool SmartAI::IsEscortInvokerInRange()
if (Group* group = player->GetGroup())
{
- for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
+ for (GroupReference const& groupRef : group->GetMembers())
{
- Player* groupGuy = groupRef->GetSource();
+ Player* groupGuy = groupRef.GetSource();
if (groupGuy->IsInMap(player) && me->GetDistance(groupGuy) <= checkDist)
return true;
}
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 3a6054fe3d5..d089abc9ca7 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -2795,10 +2795,9 @@ void SmartScript::GetTargets(ObjectVector& targets, SmartScriptHolder const& e,
{
if (Group* group = player->GetGroup())
{
- for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
- if (Player* member = groupRef->GetSource())
- if (member->IsInMap(player))
- targets.push_back(member);
+ for (GroupReference const& groupRef : group->GetMembers())
+ if (groupRef.GetSource()->IsInMap(player))
+ targets.push_back(groupRef.GetSource());
}
// We still add the player to the list if there is no group. If we do
// this even if there is a group (thus the else-check), it will add the