aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichieSams2013-10-30 23:47:29 -0500
committerRichieSams2013-10-31 23:38:03 -0500
commit37d4316a4014970171dfea8fc19f8c9e978e9102 (patch)
treeaef2c01463a36ab723d9edd6f8f348e96f593593
parent992f43cc9c926364e50c88d33980d1a6830440fa (diff)
downloadscummvm-rg350-37d4316a4014970171dfea8fc19f8c9e978e9102.tar.gz
scummvm-rg350-37d4316a4014970171dfea8fc19f8c9e978e9102.tar.bz2
scummvm-rg350-37d4316a4014970171dfea8fc19f8c9e978e9102.zip
ZVISION: Update timer logic
Also account ZNem and ZGI using different timer scales
-rw-r--r--engines/zvision/timer_node.cpp20
-rw-r--r--engines/zvision/timer_node.h1
2 files changed, 18 insertions, 3 deletions
diff --git a/engines/zvision/timer_node.cpp b/engines/zvision/timer_node.cpp
index 55dfa51dfe..b529a661cf 100644
--- a/engines/zvision/timer_node.cpp
+++ b/engines/zvision/timer_node.cpp
@@ -31,16 +31,30 @@
namespace ZVision {
+
+TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
+ : Control(engine, key) {
+ if (_engine->getGameId() == GID_NEMESIS) {
+ _timeLeft = timeInSeconds * 1000;
+ } else if (_engine->getGameId() == GID_GRANDINQUISITOR) {
+ _timeLeft = timeInSeconds * 100;
+ }
+
+ _engine->getScriptManager()->setStateValue(_key, 1);
+}
-TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds)
- : Control(engine, key), _timeLeft(timeInSeconds * 1000) {
+TimerNode::~TimerNode() {
+ if (_timeLeft <= 0)
+ _engine->getScriptManager()->setStateValue(_key, 2);
+ else
+ _engine->getScriptManager()->setStateValue(_key, _timeLeft); // If timer was stopped by stop or kill
}
bool TimerNode::process(uint32 deltaTimeInMillis) {
_timeLeft -= deltaTimeInMillis;
if (_timeLeft <= 0) {
- _engine->getScriptManager()->setStateValue(_key, 0);
+ // Let the destructor reset the state value
return true;
}
diff --git a/engines/zvision/timer_node.h b/engines/zvision/timer_node.h
index 32dca71548..a95373353b 100644
--- a/engines/zvision/timer_node.h
+++ b/engines/zvision/timer_node.h
@@ -32,6 +32,7 @@ class ZVision;
class TimerNode : public Control {
public:
TimerNode(ZVision *engine, uint32 key, uint timeInSeconds);
+ ~TimerNode();
/**
* Decrement the timer by the delta time. If the timer is finished, set the status