Core/SmartScript: Fixed crashes with stored target lists

Closes #5786
This commit is contained in:
Shauren
2012-04-05 22:13:20 +02:00
parent 926f02f792
commit b5dc7bc45b
2 changed files with 9 additions and 3 deletions

View File

@@ -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");
}

View File

@@ -266,7 +266,6 @@ struct CreatureData
// `creature_addon` table
struct CreatureAddon
{
uint32 guidOrEntry;
uint32 path_id;
uint32 mount;
uint32 bytes1;