diff options
author | Paul Gilbert | 2016-07-23 18:10:34 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-23 18:10:34 -0400 |
commit | d690ca322c04ee2044b7502369c5cc104a0c7b76 (patch) | |
tree | 62e2dbf89fa413b3cba6aca5c76a5dd0c7b033f0 | |
parent | d979dcd020d65aa0019d7a53c1dcd8b4f4a0f909 (diff) | |
download | scummvm-rg350-d690ca322c04ee2044b7502369c5cc104a0c7b76.tar.gz scummvm-rg350-d690ca322c04ee2044b7502369c5cc104a0c7b76.tar.bz2 scummvm-rg350-d690ca322c04ee2044b7502369c5cc104a0c7b76.zip |
TITANIC: Cleanup of CTimeEventInfo class
-rw-r--r-- | engines/titanic/core/game_object.cpp | 8 | ||||
-rw-r--r-- | engines/titanic/core/game_object.h | 4 | ||||
-rw-r--r-- | engines/titanic/game/computer_screen.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/messages/messages.h | 8 | ||||
-rw-r--r-- | engines/titanic/support/time_event_info.cpp | 35 | ||||
-rw-r--r-- | engines/titanic/support/time_event_info.h | 10 |
6 files changed, 34 insertions, 33 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 4f9a2a5c9f..d33a0c928b 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -659,17 +659,17 @@ void CGameObject::stopSound(int handle, int val2) { } } -int CGameObject::addTimer(int endVal, uint firstDuration, uint duration) { +int CGameObject::addTimer(int endVal, uint firstDuration, uint repeatDuration) { CTimeEventInfo *timer = new CTimeEventInfo(g_vm->_events->getTicksCount(), - duration != 0, firstDuration, duration, this, endVal, CString()); + repeatDuration != 0, firstDuration, repeatDuration, this, endVal, CString()); getGameManager()->addTimer(timer); return timer->_id; } -int CGameObject::addTimer(uint firstDuration, uint duration) { +int CGameObject::addTimer(uint firstDuration, uint repeatDuration) { CTimeEventInfo *timer = new CTimeEventInfo(g_vm->_events->getTicksCount(), - duration != 0, firstDuration, duration, this, 0, CString()); + repeatDuration != 0, firstDuration, repeatDuration, this, 0, CString()); getGameManager()->addTimer(timer); return timer->_id; diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index 3f77776bf5..bde5e25c58 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -210,12 +210,12 @@ protected: /** * Adds a timer */ - int addTimer(int endVal, uint firstDuration, uint duration); + int addTimer(int endVal, uint firstDuration, uint repeatDuration); /** * Adds a timer */ - int addTimer(uint firstDuration, uint duration); + int addTimer(uint firstDuration, uint repeatDuration); /** * Stops a timer diff --git a/engines/titanic/game/computer_screen.cpp b/engines/titanic/game/computer_screen.cpp index b73beda8a7..fd56737b01 100644 --- a/engines/titanic/game/computer_screen.cpp +++ b/engines/titanic/game/computer_screen.cpp @@ -73,7 +73,7 @@ bool CComputerScreen::EnterViewMsg(CEnterViewMsg *msg) { bool CComputerScreen::TimerMsg(CTimerMsg *msg) { int handle; - switch (msg->_val3) { + switch (msg->_actionVal) { case 0: loadSound("a#32.wav"); loadSound("a#31.wav"); diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index de5d0bdcc0..0fe6968ed4 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -185,13 +185,13 @@ MESSAGE1(CTimeMsg, uint, _ticks, 0); class CTimerMsg : public CTimeMsg { public: uint _timerCtr; - int _val3; + int _actionVal; CString _action; public: CLASSDEF - CTimerMsg() : CTimeMsg(), _timerCtr(0), _val3(0) {} - CTimerMsg(uint ticks, uint timerCtr, int val2, const CString &action) : - CTimeMsg(ticks), _timerCtr(timerCtr), _val3(val2), _action(action) {} + CTimerMsg() : CTimeMsg(), _timerCtr(0), _actionVal(0) {} + CTimerMsg(uint ticks, uint timerCtr, int actionVal, const CString &action) : + CTimeMsg(ticks), _timerCtr(timerCtr), _actionVal(actionVal), _action(action) {} static bool isSupportedBy(const CTreeItem *item) { return supports(item, _type); diff --git a/engines/titanic/support/time_event_info.cpp b/engines/titanic/support/time_event_info.cpp index a1922338d1..1787741809 100644 --- a/engines/titanic/support/time_event_info.cpp +++ b/engines/titanic/support/time_event_info.cpp @@ -91,17 +91,17 @@ void CTimeEventInfoList::set44(uint id, uint val) { uint CTimeEventInfo::_nextId; CTimeEventInfo::CTimeEventInfo() : ListItem(), _lockCounter(0), - _field14(0), _firstDuration(0), _duration(0), _target(nullptr), + _repeated(false), _firstDuration(0), _repeatDuration(0), _target(nullptr), _actionVal(0), _field2C(0), _field30(0), _timerCtr(0), - _lastTimerTicks(0), _field3C(0), _done(false), _field44(0) { + _lastTimerTicks(0), _relativeTicks(0), _done(false), _field44(0) { _id = _nextId++; } -CTimeEventInfo::CTimeEventInfo(uint ticks, uint f14, uint firstDuration, - uint duration, CTreeItem *target, int timerVal3, const CString &action) : - ListItem(), _lockCounter(0), _field14(f14), _firstDuration(firstDuration), - _duration(duration), _target(target), _actionVal(0), _field2C(0), _field30(0), - _timerCtr(0), _lastTimerTicks(ticks), _field3C(0), _done(false), +CTimeEventInfo::CTimeEventInfo(uint ticks, bool repeated, uint firstDuration, + uint repeatDuration, CTreeItem *target, int endVal, const CString &action) : + ListItem(), _lockCounter(0), _repeated(repeated), _firstDuration(firstDuration), + _repeatDuration(repeatDuration), _target(target), _actionVal(endVal), _field2C(0), + _field30(0), _timerCtr(0), _lastTimerTicks(ticks), _relativeTicks(0), _done(false), _field44(true) { _id = _nextId++; } @@ -114,13 +114,13 @@ void CTimeEventInfo::save(SimpleFile *file, int indent) { targetName = _target->getName(); file->writeQuotedLine(targetName, indent); file->writeNumberLine(_id, indent); - file->writeNumberLine(_field14, indent); + file->writeNumberLine(_repeated, indent); file->writeNumberLine(_firstDuration, indent); - file->writeNumberLine(_duration, indent); + file->writeNumberLine(_repeatDuration, indent); file->writeNumberLine(_actionVal, indent); file->writeQuotedLine(_action, indent); file->writeNumberLine(_timerCtr, indent); - file->writeNumberLine(_field3C, indent); + file->writeNumberLine(_relativeTicks, indent); file->writeNumberLine(_done, indent); file->writeNumberLine(_field44, indent); } @@ -132,13 +132,13 @@ void CTimeEventInfo::load(SimpleFile *file) { if (!val) { _targetName = file->readString(); _id = file->readNumber(); - _field14 = file->readNumber(); + _repeated = file->readNumber(); _firstDuration = file->readNumber(); - _duration = file->readNumber(); + _repeatDuration = file->readNumber(); _actionVal = file->readNumber(); _action = file->readString(); _timerCtr = file->readNumber(); - _field3C = file->readNumber(); + _relativeTicks = file->readNumber(); _done = file->readNumber() != 0; _field44 = file->readNumber(); _target = nullptr; @@ -155,7 +155,7 @@ void CTimeEventInfo::postLoad(uint ticks, CProjectItem *project) { if (!_target) _done = true; - _lastTimerTicks = ticks + _field3C; + _lastTimerTicks = ticks + _relativeTicks; if (_id >= _nextId) _nextId = _id + 1; @@ -163,7 +163,7 @@ void CTimeEventInfo::postLoad(uint ticks, CProjectItem *project) { } void CTimeEventInfo::preSave(uint ticks) { - _field3C = _lastTimerTicks - ticks; + _relativeTicks = _lastTimerTicks - ticks; lock(); } @@ -176,7 +176,7 @@ bool CTimeEventInfo::update(uint ticks) { return false; if (_timerCtr) { - if (ticks > (_lastTimerTicks + _duration)) { + if (ticks > (_lastTimerTicks + _repeatDuration)) { ++_timerCtr; _lastTimerTicks = ticks; @@ -195,7 +195,8 @@ bool CTimeEventInfo::update(uint ticks) { timerMsg.execute(_target); } - if (!_field14) + if (!_repeated) + // Event is done, and can be removed return true; } } diff --git a/engines/titanic/support/time_event_info.h b/engines/titanic/support/time_event_info.h index b436f87f65..23d0d2b803 100644 --- a/engines/titanic/support/time_event_info.h +++ b/engines/titanic/support/time_event_info.h @@ -49,9 +49,9 @@ public: public: int _lockCounter; uint _id; - uint _field14; + bool _repeated; uint _firstDuration; - uint _duration; + uint _repeatDuration; CTreeItem *_target; uint _actionVal; CString _action; @@ -59,15 +59,15 @@ public: uint _field30; uint _timerCtr; uint _lastTimerTicks; - uint _field3C; + uint _relativeTicks; bool _done; uint _field44; CString _targetName; public: CLASSDEF CTimeEventInfo(); - CTimeEventInfo(uint ticks, uint f14, uint firstDuration, uint duration, - CTreeItem *target, int timerVal3, const CString &action); + CTimeEventInfo(uint ticks, bool repeated, uint firstDuration, uint repeatDuration, + CTreeItem *target, int endVal, const CString &action); /** * Save the data for the class to file |