Avoid shifting negative values in Audio.cpp (#7147)

Rather than shifting negative values, which invokes undefined behaviour,
use a multiplication.
This commit is contained in:
Michał Janiszewski 2018-02-08 08:47:35 +01:00 committed by Ted John
parent 00cc6fd7fe
commit 0e032c9ca4
1 changed files with 1 additions and 1 deletions

View File

@ -234,7 +234,7 @@ AudioParams audio_get_params_from_location(sint32 soundId, const LocationXYZ16 *
sint16 vy = pos2.y - viewport->view_y;
sint16 vx = pos2.x - viewport->view_x;
params.pan = viewport->x + (vx >> viewport->zoom);
params.volume = SoundVolumeAdjust[soundId] + ((-1024 * viewport->zoom - 1) << volumeDown) + 1;
params.volume = SoundVolumeAdjust[soundId] + ((-1024 * viewport->zoom - 1) * (1 << volumeDown)) + 1;
if (vy < 0 || vy >= viewport->view_height || vx < 0 || vx >= viewport->view_width || params.volume < -10000)
{