bugfix: UI audio no longer plays at maximum volume for a single frame when navigating between the shell map #2019
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1941
This change fixes an issue where currently playing UI audio can be heard at maximum volume for a single frame when navigating between the shell map and other menus.
The issue is caused by a script being run via the shell map. The script reduces the sound volume to 5% when opening the options or entering other menu screens in order to silence the explosions and other noise coming from the shell map. As this also reduces the UI sound effect volume, another script is run to offset the reduced volume by adjusting a manually defined list of UI sound effect volumes to 600%. See the script reference images further below.
When the game processes a volume override command for a particular sound, the override is also immediately applied to any currently playing instances of that sound. However, when the game processes a global volume command, that volume adjustment is not applied until the next frame.
The issue is that
adjustVolumeOfPlayingAudioapplies the override without multiplying the global volume (m_soundVolume), so the sound immediately plays at 600% volume instead of 30% (6 × 0.05). Then, on the next frame,processPlayingList()seesm_volumeHasChanged = TRUEand callsadjustPlayingVolume(), which correctly applies the global volume. So for one frame, the sound plays at 600% volume before being corrected to 30%.The solution is to make
adjustVolumeOfPlayingAudioapply the same global volume modifiers asadjustPlayingVolume.Script Reference