diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/zvision/actions.cpp | 12 | ||||
-rw-r--r-- | engines/zvision/actions.h | 3 |
2 files changed, 12 insertions, 3 deletions
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index d7921d3653..5fbfbd6436 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -296,11 +296,19 @@ bool ActionQuit::execute() { ActionRandom::ActionRandom(ZVision *engine, const Common::String &line) : ResultAction(engine) { - sscanf(line.c_str(), "%*[^:]:%*[^:]:%u, %u)", &_key, &_max); + char max_buf[64]; + memset(max_buf, 0, 64); + sscanf(line.c_str(), "%*[^:]:%*[^:]:%u(%s)", &_key, max_buf); + _max = new ValueSlot(_engine->getScriptManager(), max_buf); +} + +ActionRandom::~ActionRandom() { + if (_max) + delete _max; } bool ActionRandom::execute() { - uint randNumber = _engine->getRandomSource()->getRandomNumber(_max); + uint randNumber = _engine->getRandomSource()->getRandomNumber(_max->getValue()); _engine->getScriptManager()->setStateValue(_key, randNumber); return true; } diff --git a/engines/zvision/actions.h b/engines/zvision/actions.h index e900167068..cc32cc0b43 100644 --- a/engines/zvision/actions.h +++ b/engines/zvision/actions.h @@ -288,11 +288,12 @@ public: class ActionRandom : public ResultAction { public: ActionRandom(ZVision *engine, const Common::String &line); + ~ActionRandom(); bool execute(); private: uint32 _key; - uint _max; + ValueSlot *_max; }; class ActionSetPartialScreen : public ResultAction { |