(svn r12176) -Codechange: one division less when playing sounds (patch by Dominik)
authorsmatz
Mon, 18 Feb 2008 14:59:30 +0000
changeset 9091 c1cddeb8511c
parent 9090 0edc62c72d1d
child 9092 383a632de666
(svn r12176) -Codechange: one division less when playing sounds (patch by Dominik)
src/sound.cpp
--- a/src/sound.cpp	Mon Feb 18 13:19:57 2008 +0000
+++ b/src/sound.cpp	Mon Feb 18 14:59:30 2008 +0000
@@ -222,10 +222,12 @@
 				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;