summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-01-16 17:46:04 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-01-18 23:49:19 +0100
commitf663f5bbb75b850ae22f451a22d112b6c62b2ad6 (patch)
treec51f3273962df7d402d2bffb6995f86381486c20
parent715d07feeb01a3f633aa42aeb40a524c16ca321e (diff)
downloadmana-f663f5bbb75b850ae22f451a22d112b6c62b2ad6.tar.gz
mana-f663f5bbb75b850ae22f451a22d112b6c62b2ad6.tar.bz2
mana-f663f5bbb75b850ae22f451a22d112b6c62b2ad6.tar.xz
mana-f663f5bbb75b850ae22f451a22d112b6c62b2ad6.zip
Check for negative positional values in the playSfx() function.
From http://www.gitorious.org/manaplus/manaplus/commit/6c885855b0c06bd7c4b6ab3574d8e2f3398ad97a Thanks to 4144. Trivial.
-rw-r--r--src/sound.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/sound.cpp b/src/sound.cpp
index a8090f84..c64e10d8 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -253,6 +253,10 @@ void Sound::playSfx(const std::string &path, int x, int y)
if (dy < 0)
dy = -dy;
int dist = dx > dy ? dx : dy;
+
+ // Check for negative values
+ if (dist * 8 > vol)
+ return;
vol -= dist * 8;
}
sample->play(0, vol);