diff options
author | Machiavelli <none@none> | 2010-06-05 17:48:56 +0200 |
---|---|---|
committer | Machiavelli <none@none> | 2010-06-05 17:48:56 +0200 |
commit | bb292845ede82f8d07d1ab94aa0e83ef5309332f (patch) | |
tree | ba63e6a0af2dd6ebfbb583ceb308b45d8b278cfc /src | |
parent | 8aed0837829bb95cd54c07f5692dfbbe511252e1 (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Map.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
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) |