From 7095e613d59630ec03dbf8a17e18ae9b4aabf289 Mon Sep 17 00:00:00 2001 From: richiesams Date: Sat, 24 Aug 2013 00:00:30 -0500 Subject: ZVISION: Keep a member variable ZVision pointer instead of passing it in every process() --- engines/zvision/action_node.cpp | 9 +++++---- engines/zvision/action_node.h | 20 +++++++++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/action_node.cpp b/engines/zvision/action_node.cpp index 1a51690b3f..f51801a75d 100644 --- a/engines/zvision/action_node.cpp +++ b/engines/zvision/action_node.cpp @@ -28,14 +28,15 @@ namespace ZVision { -NodeTimer::NodeTimer(uint32 key, uint timeInSeconds) - : _key(key), _timeLeft(timeInSeconds * 1000) {} +TimerNode::TimerNode(ZVision *engine, uint32 key, uint timeInSeconds) + : _engine(engine), _key(key), _timeLeft(timeInSeconds * 1000) { +} -bool NodeTimer::process(ZVision *engine, uint32 deltaTimeInMillis) { +bool TimerNode::process(uint32 deltaTimeInMillis) { _timeLeft -= deltaTimeInMillis; if (_timeLeft <= 0) { - engine->getScriptManager()->setStateValue(_key, 0); + _engine->getScriptManager()->setStateValue(_key, 0); return true; } diff --git a/engines/zvision/action_node.h b/engines/zvision/action_node.h index 5b4430c3a4..9a5ca0be0b 100644 --- a/engines/zvision/action_node.h +++ b/engines/zvision/action_node.h @@ -32,23 +32,29 @@ class ZVision; class ActionNode { public: virtual ~ActionNode() {} - virtual bool process(ZVision *engine, uint32 deltaTimeInMillis) = 0; + /** + * Processes the node given the deltaTime since last frame + * + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes + */ + virtual bool process(uint32 deltaTimeInMillis) = 0; }; -class NodeTimer : public ActionNode { +class TimerNode : public ActionNode { public: - NodeTimer(uint32 key, uint timeInSeconds); + TimerNode(ZVision *engine, uint32 key, uint timeInSeconds); /** * Decrement the timer by the delta time. If the timer is finished, set the status * in _globalState and let this node be deleted * - * @param engine Pointer to the ZVision instance - * @param deltaTimeInMillis Amount of time that has passed since the last frame - * @return Node should be deleted after this (true) or kept (false) + * @param deltaTimeInMillis The number of milliseconds that have passed since last frame + * @return If true, the node can be deleted after process() finishes */ - bool process(ZVision *engine, uint32 deltaTimeInMillis); + bool process(uint32 deltaTimeInMillis); private: + ZVision *_engine; uint32 _key; uint32 _timeLeft; }; -- cgit v1.2.3