TITANIC: Field renaming and warning fixes in sound code

This commit is contained in:
Paul Gilbert 2016-08-09 22:16:17 -04:00
parent 668c486f4f
commit 17a665e2aa
7 changed files with 22 additions and 19 deletions

View File

@ -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);
}

View File

@ -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),

View File

@ -36,7 +36,7 @@ public:
int _field4;
int _channelVolume;
int _fieldC;
uint _soundHandle;
int _priorSoundHandle;
int _field14;
double _frequencyMultiplier;
double _field1C;

View File

@ -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);
}

View File

@ -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;
}
}
}

View File

@ -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) {}

View File

@ -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);
}
}