From bb292845ede82f8d07d1ab94aa0e83ef5309332f Mon Sep 17 00:00:00 2001 From: Machiavelli Date: Sat, 5 Jun 2010 17:48:56 +0200 Subject: Fix SCRIPT_COMMAND_FIELD_SET, it will no longer throw error that the specified parameter was an invalid field. In addition, the command is now usable from gossip scripts. --HG-- branch : trunk --- src/game/Map.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/game') diff --git a/src/game/Map.cpp b/src/game/Map.cpp index f8e48d3a326..8e071d71747 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -3016,20 +3016,32 @@ void Map::ScriptsProcess() } case SCRIPT_COMMAND_FIELD_SET: + { if (!source) { - sLog.outError("SCRIPT_COMMAND_FIELD_SET (script id: %u) call for NULL object.", step.script->id); + sLog.outError("SCRIPT_COMMAND_FIELD_SET (script id: %u) call for NULL source.", step.script->id); break; } - if (step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= source->GetValuesCount()) + + // Source should only be Creature or GO, but in case of gossip, the target is our source. + Creature* cSource = source->ToCreature() != NULL ? source->ToCreature() : target->ToCreature(); + if (!cSource) + { + sLog.outError("SCRIPT_COMMAND_FIELD_SET (script id: %u) call for non-creature or non-GO source.", step.script->id); + break; + } + + if (step.script->datalong <= OBJECT_FIELD_ENTRY || step.script->datalong >= cSource->GetValuesCount()) { sLog.outError("SCRIPT_COMMAND_FIELD_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->SetUInt32Value(step.script->datalong, step.script->datalong2); + cSource->SetUInt32Value(step.script->datalong, step.script->datalong2); break; + } + case SCRIPT_COMMAND_MOVE_TO: { if (!source) -- cgit v1.2.3