aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/SmartScripts
diff options
context:
space:
mode:
authorxinef1 <w.szyszko2@gmail.com>2017-02-04 22:37:16 +0100
committerShauren <shauren.trinity@gmail.com>2019-07-21 21:06:54 +0200
commitad008c43b75080ec59aa973f1e2e4424332c34a4 (patch)
treef5b7e98e0fc47a25246ce999e15d6f413b8018ab /src/server/game/AI/SmartScripts
parent92e95ddf558db5fdcdf3c54ecd1d694da92c3a44 (diff)
Core/Misc: Fix various crashes, also related to multithreading (#19012)
* When iterating groups we have to either do it not in multithreaded context (map updates) or start with checking maps (they are guaranteed to change in single thread update). * Properly clear ComboPoint references on player remove * remove some possible references item may have when it is deleted during save. * Also clear all hostile references when unit is removed from map. (cherrypicked from 86da1a19bb36edf3242dafac6e45e87434ddff73)
Diffstat (limited to 'src/server/game/AI/SmartScripts')
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp5
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp6
2 files changed, 7 insertions, 4 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index acd2f794bca..96ed78b08de 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -243,6 +243,8 @@ void SmartAI::EndPath(bool fail)
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
{
Player* groupGuy = groupRef->GetSource();
+ if (!groupGuy->IsInMap(player))
+ continue;
if (!fail && groupGuy->IsAtGroupRewardDistance(me) && !groupGuy->HasCorpse())
groupGuy->AreaExploredOrEventHappens(mEscortQuestID);
@@ -411,8 +413,7 @@ bool SmartAI::IsEscortInvokerInRange()
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
{
Player* groupGuy = groupRef->GetSource();
-
- if (me->GetDistance(groupGuy) <= SMART_ESCORT_MAX_PLAYER_DIST)
+ if (groupGuy->IsInMap(player) && me->GetDistance(groupGuy) <= SMART_ESCORT_MAX_PLAYER_DIST)
return true;
}
}
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index f5026728012..be37c0e671e 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -2831,7 +2831,8 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /*
{
for (GroupReference* groupRef = group->GetFirstMember(); groupRef != nullptr; groupRef = groupRef->next())
if (Player* member = groupRef->GetSource())
- l->push_back(member);
+ if (member->IsInMap(player))
+ l->push_back(member);
}
// 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
@@ -3048,7 +3049,8 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /*
{
for (GroupReference* it = lootGroup->GetFirstMember(); it != nullptr; it = it->next())
if (Player* recipient = it->GetSource())
- l->push_back(recipient);
+ if (recipient->IsInMap(me))
+ l->push_back(recipient);
}
else
{