From 095914eb59ee6756b582fe07b1e332b1b354f243 Mon Sep 17 00:00:00 2001 From: Machiavelli Date: Sat, 5 Jun 2010 18:10:18 +0200 Subject: Fix SCRIPT_COMMAND_FLAG_SET and SCRIPT_COMMAND_FLAG_REMOVE, allow them to be used in gossip scripts and fix error message that specified field was alledgedly out of bounds. --HG-- branch : trunk --- src/game/Map.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/game/Map.cpp') diff --git a/src/game/Map.cpp b/src/game/Map.cpp index eab7c67f778..11bfdcd6f99 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -3070,14 +3070,21 @@ void Map::ScriptsProcess() break; } - if (step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= source->GetValuesCount()) + Creature* cSource = source->ToCreature() != NULL ? source->ToCreature() : target->ToCreature(); + if (!cSource) + { + sLog.outError("SCRIPT_COMMAND_FLAG_SET (script id: %u) call for non-creature source.", step.script->id); + break; + } + + if (step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= cSource->GetValuesCount()) { sLog.outError("SCRIPT_COMMAND_FLAG_SET (script id: %u) call for wrong field %u (max count: %u) in object (TypeId: %u, Entry: %u, GUID: %u).", step.script->id, step.script->datalong,source->GetValuesCount(),source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); break; } - source->SetFlag(step.script->datalong, step.script->datalong2); + cSource->SetFlag(step.script->datalong, step.script->datalong2); break; } @@ -3088,14 +3095,22 @@ void Map::ScriptsProcess() sLog.outError("SCRIPT_COMMAND_FLAG_REMOVE (script id: %u) call for NULL object.", step.script->id); break; } - if (step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= source->GetValuesCount()) + + Creature* cSource = source->ToCreature() != NULL ? source->ToCreature() : target->ToCreature(); + if (!cSource) + { + sLog.outError("SCRIPT_COMMAND_FLAG_REMOVE (script id: %u) call for non-creature source.", step.script->id); + break; + } + + if (step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= cSource->GetValuesCount()) { sLog.outError("SCRIPT_COMMAND_FLAG_REMOVE (script id: %u) call for wrong field %u (max count: %u) in object (TypeId: %u, Entry: %u, GUID: %u).", step.script->id, step.script->datalong,source->GetValuesCount(),source->GetTypeId(),source->GetEntry(),source->GetGUIDLow()); break; } - source->RemoveFlag(step.script->datalong, step.script->datalong2); + cSource->RemoveFlag(step.script->datalong, step.script->datalong2); break; } -- cgit v1.2.3