aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision/timer_node.cpp
diff options
context:
space:
mode:
authorMarisa-Chan2013-10-31 07:45:43 +0000
committerMarisa-Chan2013-10-31 07:45:43 +0000
commitb2aa30afebe9c799ad2513f6c22cd798c1818eb0 (patch)
tree105043ab1c3b489c1265cf4adda0f4be62147261 /engines/zvision/timer_node.cpp
parentfa943f1044e78ad9b1305f2d91085c25a945aaa9 (diff)
downloadscummvm-rg350-b2aa30afebe9c799ad2513f6c22cd798c1818eb0.tar.gz
scummvm-rg350-b2aa30afebe9c799ad2513f6c22cd798c1818eb0.tar.bz2
scummvm-rg350-b2aa30afebe9c799ad2513f6c22cd798c1818eb0.zip
ZVISION: Correct timer code to match original.
Diffstat (limited to 'engines/zvision/timer_node.cpp')
-rw-r--r--engines/zvision/timer_node.cpp19
1 files changed, 14 insertions, 5 deletions
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);