summaryrefslogtreecommitdiff
path: root/src/sound.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-02-18 14:59:30 +0000
committersmatz <smatz@openttd.org>2008-02-18 14:59:30 +0000
commita0a225ab021f4cbb65679c04898d6f3eb8eb3662 (patch)
treef1fada8a52151a0d8f5493ebfad9fb899d65ccd5 /src/sound.cpp
parenta0fda5b96922a98fe652ff6e6e9aa95e7f045f1e (diff)
downloadopenttd-a0a225ab021f4cbb65679c04898d6f3eb8eb3662.tar.xz
(svn r12176) -Codechange: one division less when playing sounds (patch by Dominik)
Diffstat (limited to 'src/sound.cpp')
-rw-r--r--src/sound.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/sound.cpp b/src/sound.cpp
index ed4651800..960794bbd 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -222,10 +222,12 @@ static void SndPlayScreenCoordFx(SoundFx sound, int left, int right, int top, in
left < vp->virtual_left + vp->virtual_width && right > vp->virtual_left &&
top < vp->virtual_top + vp->virtual_height && bottom > vp->virtual_top) {
int screen_x = (left + right) / 2 - vp->virtual_left;
+ int width = (vp->virtual_width == 0 ? 1 : vp->virtual_width);
+ int panning = (screen_x * PANNING_LEVELS * 2) / width - PANNING_LEVELS;
StartSound(
sound,
- screen_x / max(1, vp->virtual_width / ((PANNING_LEVELS << 1) + 1)) - PANNING_LEVELS,
+ panning,
(msf.effect_vol * _vol_factor_by_zoom[vp->zoom - ZOOM_LVL_BEGIN]) / 256
);
return;