aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarisa-Chan2013-10-31 09:53:17 +0700
committerMarisa-Chan2013-10-31 09:53:17 +0700
commit44464ce686f26128a37ef3b8da17ed01f436b928 (patch)
tree9fa77094a8d91b4112e3e1ab98590d96a40d72b8
parent0b61b653aea21bf0329bcd5738617611d7109ee8 (diff)
downloadscummvm-rg350-44464ce686f26128a37ef3b8da17ed01f436b928.tar.gz
scummvm-rg350-44464ce686f26128a37ef3b8da17ed01f436b928.tar.bz2
scummvm-rg350-44464ce686f26128a37ef3b8da17ed01f436b928.zip
ZVISION: Fix actionRandom parameter reader.
-rw-r--r--engines/zvision/actions.cpp12
-rw-r--r--engines/zvision/actions.h3
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 {