diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 3a100ffd29f..67b7920f048 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -748,7 +748,7 @@ int CGameObject::queueSound(const CString &name, uint priorHandle, uint volume, prox._fieldC = val3; prox._repeated = repeated; prox._channelVolume = volume; - prox._soundHandle = priorHandle; + prox._priorSoundHandle = priorHandle; return playSound(name, prox); } diff --git a/engines/titanic/sound/proximity.cpp b/engines/titanic/sound/proximity.cpp index ce91a0770f7..7502eb3ef80 100644 --- a/engines/titanic/sound/proximity.cpp +++ b/engines/titanic/sound/proximity.cpp @@ -26,7 +26,7 @@ namespace Titanic { CProximity::CProximity() : _field4(0), _channelVolume(100), _fieldC(0), - _soundHandle((uint)-1), _field14(0), _frequencyMultiplier(0.0), _field1C(1.875), + _priorSoundHandle(-1), _field14(0), _frequencyMultiplier(0.0), _field1C(1.875), _repeated(false), _channel(10), _field28(0), _azimuth(0.0), _range(0.5), _elevation(0), _posX(0.0), _posY(0.0), _posZ(0.0), _hasVelocity(false), _velocityX(0), _velocityY(0), _velocityZ(0), diff --git a/engines/titanic/sound/proximity.h b/engines/titanic/sound/proximity.h index d8eee4d9e59..7c1f8598e83 100644 --- a/engines/titanic/sound/proximity.h +++ b/engines/titanic/sound/proximity.h @@ -36,7 +36,7 @@ public: int _field4; int _channelVolume; int _fieldC; - uint _soundHandle; + int _priorSoundHandle; int _field14; double _frequencyMultiplier; double _field1C; diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp index d86262ae23e..d14c628a788 100644 --- a/engines/titanic/sound/sound.cpp +++ b/engines/titanic/sound/sound.cpp @@ -48,16 +48,12 @@ void CSound::preLoad() { void CSound::preEnterView(CViewItem *newView, bool isNewRoom) { CNodeItem *node = newView->findNode(); - CRoomItem *room = node->findRoom(); double xp, yp, zp; node->getPosition(xp, yp, zp); double cosVal = cos(newView->_angle); double sinVal = -sin(newView->_angle); - // WORKAROUND: The original does a weird call below, doing the room's - // (width + height) / 2 and passing it in the isNewRoom field, along with - // two extra unused parameters that aren't used _soundManager.setListenerPosition(xp, yp, zp, cosVal, sinVal, 0, isNewRoom); } diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp index 7f0834ccb1e..a8bd0dfbe93 100644 --- a/engines/titanic/sound/sound_manager.cpp +++ b/engines/titanic/sound/sound_manager.cpp @@ -151,11 +151,15 @@ int QSoundManager::playSound(CWaveFile &waveFile, CProximity &prox) { int channel = -1; uint flags = QMIX_CLEARQUEUE; - for (uint idx = 0; idx < _slots.size(); ++idx) { - if (_slots[idx]._handle == prox._soundHandle) { - channel = _slots[idx]._channel; - flags = QMIX_QUEUEWAVE; - break; + if (prox._priorSoundHandle >= 1) { + // This sound should only be started after a prior one finishes, + // so scan the slots for the specified sound + for (uint idx = 0; idx < _slots.size(); ++idx) { + if (_slots[idx]._handle == prox._priorSoundHandle) { + channel = _slots[idx]._channel; + flags = QMIX_QUEUEWAVE; + break; + } } } diff --git a/engines/titanic/sound/sound_manager.h b/engines/titanic/sound/sound_manager.h index 466607a1d50..2c9975ede40 100644 --- a/engines/titanic/sound/sound_manager.h +++ b/engines/titanic/sound/sound_manager.h @@ -191,17 +191,17 @@ public: /** * Returns the music volume percent */ - int getMusicVolume() const { return _musicPercent; } + double getMusicVolume() const { return _musicPercent; } /** * Returns the speech volume percent */ - int getSpeechVolume() const { return _speechPercent; } + double getSpeechVolume() const { return _speechPercent; } /** * Returns the parrot volume percent */ - int getParrotVolume() const { return _parrotPercent; } + double getParrotVolume() const { return _parrotPercent; } /** * Gets the volume for a given mode? value @@ -255,7 +255,7 @@ class QSoundManager : public CSoundManager, public QMixer { bool _isTimed; uint _ticks; int _channel; - uint _handle; + int _handle; uint _val3; Slot() : _waveFile(0), _isTimed(0), _ticks(0), _channel(-1), _handle(0), _val3(0) {} diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp index 82d443fcda4..61ad924d908 100644 --- a/engines/titanic/true_talk/true_talk_manager.cpp +++ b/engines/titanic/true_talk/true_talk_manager.cpp @@ -523,6 +523,9 @@ void CTrueTalkManager::playSpeech(TTtalker *talker, TTroomScript *roomScript, CV view->getPosition(p1._posX, p1._posY, p1._posZ); } + // Loop through adding each of the speech portions in. We use the + // _priorSoundHandle of CProximity to chain each successive speech + // to start when the prior one finishes for (uint idx = 0; idx < _titleEngine._indexes.size(); ++idx) { uint id = _titleEngine._indexes[idx]; if (id > 100000) @@ -535,18 +538,18 @@ void CTrueTalkManager::playSpeech(TTtalker *talker, TTroomScript *roomScript, CV } // Start the speech - p1._soundHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p1); + p1._priorSoundHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p1); if (!milli) continue; if (idx == 0) g_vm->_events->sleep(milli); - p3._soundHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p3); + p3._priorSoundHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p3); if (idx == 0) g_vm->_events->sleep(milli); - p2._soundHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p2); + p2._priorSoundHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p2); } }