Skip to content

Commit 47b5369

Browse files
committed
Move the shouldPlayLocally() check to after the state-modifying operations
1 parent 45a76aa commit 47b5369

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

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

448-
if (!eventToAdd->getUninterruptable()) {
449-
if (!shouldPlayLocally(eventToAdd)) {
450-
return AHSV_NotForLocal;
451-
}
452-
}
453-
454448
AudioEventRTS *audioEvent = MSGNEW("AudioEventRTS") AudioEventRTS(*eventToAdd); // poolify
455449
audioEvent->setPlayingHandle( allocateNewHandle() );
456450
audioEvent->generateFilename(); // which file are we actually going to play?
457451
((AudioEventRTS*)eventToAdd)->setPlayingAudioIndex( audioEvent->getPlayingAudioIndex() );
458452
audioEvent->generatePlayInfo(); // generate pitch shift and volume shift now as well
459453

454+
if (!audioEvent->getUninterruptable()) {
455+
if (!shouldPlayLocally(audioEvent)) {
456+
releaseAudioEventRTS(audioEvent);
457+
return AHSV_NotForLocal;
458+
}
459+
}
460+
460461
std::list<std::pair<AsciiString, Real> >::iterator it;
461462
for (it = m_adjustedVolumes.begin(); it != m_adjustedVolumes.end(); ++it) {
462463
if (it->first == audioEvent->getEventName()) {

0 commit comments

Comments
 (0)