Skip to content

Commit 116357c

Browse files
committed
more tinkering to avoid mismatch in replays
1 parent c406045 commit 116357c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Core/GameEngine/Source/Common/Audio/GameAudio.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,19 @@ AudioHandle AudioManager::addAudioEvent(const AudioEventRTS *eventToAdd)
445445
return AHSV_NoSound;
446446
}
447447

448-
AudioEventRTS *audioEvent = MSGNEW("AudioEventRTS") AudioEventRTS(*eventToAdd); // poolify
448+
AudioEventRTS tempEvent = *eventToAdd;
449+
tempEvent.generateFilename();
450+
((AudioEventRTS*)eventToAdd)->setPlayingAudioIndex( tempEvent.getPlayingAudioIndex() );
451+
tempEvent.generatePlayInfo();
452+
453+
if (!tempEvent.getUninterruptable()) {
454+
if (!shouldPlayLocally(&tempEvent)) {
455+
return AHSV_NotForLocal;
456+
}
457+
}
458+
459+
AudioEventRTS *audioEvent = MSGNEW("AudioEventRTS") AudioEventRTS(tempEvent); // poolify
449460
audioEvent->setPlayingHandle( allocateNewHandle() );
450-
audioEvent->generateFilename(); // which file are we actually going to play?
451-
((AudioEventRTS*)eventToAdd)->setPlayingAudioIndex( audioEvent->getPlayingAudioIndex() );
452-
audioEvent->generatePlayInfo(); // generate pitch shift and volume shift now as well
453461

454462
std::list<std::pair<AsciiString, Real> >::iterator it;
455463
for (it = m_adjustedVolumes.begin(); it != m_adjustedVolumes.end(); ++it) {
@@ -459,13 +467,6 @@ AudioHandle AudioManager::addAudioEvent(const AudioEventRTS *eventToAdd)
459467
}
460468
}
461469

462-
if (!audioEvent->getUninterruptable()) {
463-
if (!shouldPlayLocally(audioEvent)) {
464-
releaseAudioEventRTS(audioEvent);
465-
return AHSV_NotForLocal;
466-
}
467-
}
468-
469470
// cull muted audio
470471
if (audioEvent->getVolume() < m_audioSettings->m_minVolume) {
471472
#ifdef INTENSIVE_AUDIO_DEBUG

0 commit comments

Comments
 (0)