diff options
Diffstat (limited to 'engines/zvision')
-rw-r--r-- | engines/zvision/actions.cpp | 1 | ||||
-rw-r--r-- | engines/zvision/script_manager.h | 1 | ||||
-rw-r--r-- | engines/zvision/timer_node.cpp | 19 | ||||
-rw-r--r-- | engines/zvision/timer_node.h | 2 |
4 files changed, 18 insertions, 5 deletions
diff --git a/engines/zvision/actions.cpp b/engines/zvision/actions.cpp index 08e99dc501..d7921d3653 100644 --- a/engines/zvision/actions.cpp +++ b/engines/zvision/actions.cpp @@ -408,6 +408,7 @@ ActionTimer::ActionTimer(ZVision *engine, const Common::String &line) : ActionTimer::~ActionTimer() { if (_time) delete _time; + _engine->getScriptManager()->killSideFx(_key); } bool ActionTimer::execute() { diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index dd995f4661..c75296b586 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -49,6 +49,7 @@ enum StateKey { StateKey_KeyPress = 8, StateKey_InventoryItem = 9, StateKey_LMouse = 10, + StateKey_NotSet = 11, // This key doesn't set StateKey_Rounds = 12, StateKey_Venus = 13, StateKey_RMouse = 18, diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp index c7cefd6150..f8da0bcf37 100644 --- a/engines/zvision/timer_node.cpp +++ b/engines/zvision/timer_node.cpp @@ -38,25 +38,34 @@ TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds) _timeLeft = timeInSeconds * 1000; else if (_engine->getGameId() == GID_GRANDINQUISITOR) _timeLeft = timeInSeconds * 100; - _engine->getScriptManager()->setStateValue(_key, 1); + + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 1); } TimerNode::~TimerNode() { - if (_timeLeft <= 0) + if (_key != StateKey_NotSet) _engine->getScriptManager()->setStateValue(_key, 2); - else - _engine->getScriptManager()->setStateValue(_key, _timeLeft); // If timer was stopped by stop or kill + int32 timeLeft = _timeLeft / (_engine->getGameId() == GID_NEMESIS ? 1000 : 100); + if (timeLeft > 0) + _engine->getScriptManager()->setStateValue(_key, timeLeft); // If timer was stopped by stop or kill } bool TimerNode::process(uint32 deltaTimeInMillis) { _timeLeft -= deltaTimeInMillis; if (_timeLeft <= 0) - return true; + return stop(); return false; } +bool TimerNode::stop() { + if (_key != StateKey_NotSet) + _engine->getScriptManager()->setStateValue(_key, 2); + return true; +} + void TimerNode::serialize(Common::WriteStream *stream) { stream->writeUint32LE(_key); stream->writeUint32LE(_timeLeft); diff --git a/engines/zvision/timer_node.h b/engines/zvision/timer_node.h index 4a9c95d72b..f6584becda 100644 --- a/engines/zvision/timer_node.h +++ b/engines/zvision/timer_node.h @@ -48,6 +48,8 @@ public: return true; } + bool stop(); + private: int32 _timeLeft; }; |