ZVISION: Implement indirect addressing in add()

Some ZGI scripts use action:add(14999, [...]) to add to the score.
Without this, it would always add 0 instead. This affected the puzzles
where you use the snapdragon and where you open the first time tunnel.
This commit is contained in:
Torbjörn Andersson 2020-07-21 16:14:02 +02:00 committed by Eugene Sandulenko
parent 022a65ee52
commit 02a1552efe
2 changed files with 6 additions and 4 deletions

View File

@ -60,13 +60,15 @@ ResultAction::ResultAction(ZVision *engine, int32 slotKey) :
ActionAdd::ActionAdd(ZVision *engine, int32 slotKey, const Common::String &line) :
ResultAction(engine, slotKey) {
_key = 0;
_value = 0;
sscanf(line.c_str(), "%u,%d", &_key, &_value);
char buf[64];
memset(buf, 0, 64);
sscanf(line.c_str(), "%u,%s", &_key, buf);
_value = new ValueSlot(_scriptManager, buf);
}
bool ActionAdd::execute() {
_scriptManager->setStateValue(_key, _scriptManager->getStateValue(_key) + _value);
_scriptManager->setStateValue(_key, _scriptManager->getStateValue(_key) + _value->getValue());
return true;
}

View File

@ -63,7 +63,7 @@ public:
private:
uint32 _key;
int _value;
ValueSlot *_value;
};
class ActionAssign : public ResultAction {