Permalink
Browse files

Core/SmartScript: Fixed crashes with stored target lists

Closes #5786
  • Loading branch information...
1 parent 926f02f commit b5dc7bc45b658bc0f5627628337992c944224345 @Shauren Shauren committed Apr 5, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −2 src/server/game/AI/SmartScripts/SmartScript.cpp
  2. +0 −1 src/server/game/Entities/Creature/Creature.h
@@ -1865,19 +1865,26 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!targets)
break;
+ ObjectList* storedTargets = GetTargetList(e.action.sendTargetToTarget.id);
+ if (!storedTargets)
+ {
+ delete targets;
+ return;
+ }
+
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
{
if (IsCreature(*itr))
{
if (SmartAI* ai = CAST_AI(SmartAI, (*itr)->ToCreature()->AI()))
- ai->GetScript()->StoreTargetList(GetTargetList(e.action.sendTargetToTarget.id), e.action.sendTargetToTarget.id);
+ ai->GetScript()->StoreTargetList(new ObjectList(*storedTargets), e.action.sendTargetToTarget.id); // store a copy of target list
else
sLog->outErrorDb("SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartAI, skipping");
}
else if (IsGameObject(*itr))
{
if (SmartGameObjectAI* ai = CAST_AI(SmartGameObjectAI, (*itr)->ToGameObject()->AI()))
- ai->GetScript()->StoreTargetList(GetTargetList(e.action.sendTargetToTarget.id), e.action.sendTargetToTarget.id);
+ ai->GetScript()->StoreTargetList(new ObjectList(*storedTargets), e.action.sendTargetToTarget.id); // store a copy of target list
else
sLog->outErrorDb("SmartScript: Action target for SMART_ACTION_SEND_TARGET_TO_TARGET is not using SmartGameObjectAI, skipping");
}
@@ -266,7 +266,6 @@ struct CreatureData
// `creature_addon` table
struct CreatureAddon
{
- uint32 guidOrEntry;
uint32 path_id;
uint32 mount;
uint32 bytes1;

0 comments on commit b5dc7bc

Please sign in to comment.