Skip to content

Commit

Permalink
Avoid shifting negative values in Audio.cpp (#7147)
Browse files Browse the repository at this point in the history
Rather than shifting negative values, which invokes undefined behaviour,
use a multiplication.
  • Loading branch information
janisozaur authored and IntelOrca committed Feb 8, 2018
1 parent 00cc6fd commit 0e032c9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/openrct2/audio/Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 0e032c9

Please sign in to comment.