From f918de5d644a2d6b040ade3934fd12966dc33ce9 Mon Sep 17 00:00:00 2001
From: sezero <sezero@af15c1b1-3010-417e-b628-4374ebc0bcbd>
Date: Tue, 18 Jan 2011 06:50:35 +0000
Subject: [PATCH] * snd_mix.c (SND_PaintChannelFrom16): multiplication might
 cause   integer overflow as observed in the warpspasm mod depending on   the
 volume level. so, moved the left shifting to left/right   volume before the
 multiplication.

git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@401 af15c1b1-3010-417e-b628-4374ebc0bcbd
---
 quakespasm/Quake/snd_mix.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/quakespasm/Quake/snd_mix.c b/quakespasm/Quake/snd_mix.c
index 2bfbb070..598a55e8 100644
--- a/quakespasm/Quake/snd_mix.c
+++ b/quakespasm/Quake/snd_mix.c
@@ -302,13 +302,19 @@ static void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count)
 
 	leftvol = ch->leftvol * snd_vol;
 	rightvol = ch->rightvol * snd_vol;
+	leftvol >>= 8;
+	rightvol >>= 8;
 	sfx = (signed short *)sc->data + ch->pos;
 
 	for (i = 0; i < count; i++)
 	{
 		data = sfx[i];
-		left = (data * leftvol) >> 8;
-		right = (data * rightvol) >> 8;
+	// this was causing integer overflow as observed in quakespasm
+	// with the warpspasm mod moved <<8 to left/right volume above.
+	//	left = (data * leftvol) >> 8;
+	//	right = (data * rightvol) >> 8;
+		left = data * leftvol;
+		right = data * rightvol;
 		paintbuffer[i].left += left;
 		paintbuffer[i].right += right;
 	}