aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/messages/bilge_dispensor_event.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2017-07-25 22:04:28 -0400
committerPaul Gilbert2017-07-25 22:04:28 -0400
commit6b80c13467df4253b19454d7fdb17a6c2c290d97 (patch)
tree78509f75a6c6fab03433a021d4abbd530fdb7bf5 /engines/titanic/messages/bilge_dispensor_event.cpp
parentd4623c14a133dbfbe43eacf3c3ed3f4f34d8eaa2 (diff)
downloadscummvm-rg350-6b80c13467df4253b19454d7fdb17a6c2c290d97.tar.gz
scummvm-rg350-6b80c13467df4253b19454d7fdb17a6c2c290d97.tar.bz2
scummvm-rg350-6b80c13467df4253b19454d7fdb17a6c2c290d97.zip
TITANIC: Fix the CBilgeDispensorEvent not firing
It seems in the original CGameManager::update, and thus frameMessage, is called at an ultra high rate, allowing the dispensor's counter to quickly reach a trigger level. Whereas in the ScummVM implementation, the update method is only called at most a few times per frame. Rather than needlessly increasing the rate the update method is called, I've refactored CBilgeDispensorEvent to not need the counter. Though it still derives from CAutoSoundEvent so savegame loading still works.
Diffstat (limited to 'engines/titanic/messages/bilge_dispensor_event.cpp')
-rw-r--r--engines/titanic/messages/bilge_dispensor_event.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/engines/titanic/messages/bilge_dispensor_event.cpp b/engines/titanic/messages/bilge_dispensor_event.cpp
index 584da00a6f..336a1caf0d 100644
--- a/engines/titanic/messages/bilge_dispensor_event.cpp
+++ b/engines/titanic/messages/bilge_dispensor_event.cpp
@@ -21,6 +21,7 @@
*/
#include "titanic/messages/bilge_dispensor_event.h"
+#include "titanic/titanic.h"
namespace Titanic {
@@ -42,22 +43,31 @@ void CBilgeDispensorEvent::load(SimpleFile *file) {
}
bool CBilgeDispensorEvent::EnterRoomMsg(CEnterRoomMsg *msg) {
- _value1 = 0;
+ _counter = 0;
+ _ticksDelayEnd = 0;
+ _soundHandle = -1;
return true;
}
bool CBilgeDispensorEvent::LeaveRoomMsg(CLeaveRoomMsg *msg) {
- _value1 = -1;
+ _counter = -1;
return true;
}
bool CBilgeDispensorEvent::FrameMsg(CFrameMsg *msg) {
- if (_value1 >= 0 && (_value1 & 0xffff) == 0x4000) {
- int volume = 20 + getRandomNumber(30);
- int val3 = getRandomNumber(20) - 10;
+ uint32 ticks = g_vm->_events->getTicksCount();
+
+ if ((_ticksDelayEnd && ticks >= _ticksDelayEnd) ||
+ _soundHandle == -1 || !isSoundActive(_soundHandle)) {
+ _soundHandle = -1;
+ _ticksDelayEnd = 0;
if (getRandomNumber(2) == 0) {
- playSound("b#18.wav", volume, val3);
+ int volume = 20 + getRandomNumber(30);
+ int balance = getRandomNumber(20) - 10;
+ _soundHandle = playSound("b#18.wav", volume, balance);
+ } else {
+ _ticksDelayEnd = ticks + 1000;
}
}
@@ -67,9 +77,9 @@ bool CBilgeDispensorEvent::FrameMsg(CFrameMsg *msg) {
bool CBilgeDispensorEvent::StatusChangeMsg(CStatusChangeMsg *msg) {
if (msg->_newStatus == 1)
- _value1 = -1;
+ _counter = -1;
else if (msg->_newStatus == 2)
- _value1 = 0;
+ _counter = 0;
return true;
}