From d08b50e36f64981c37e2ac41b50579af2398b580 Mon Sep 17 00:00:00 2001 From: William Kendrick Date: Tue, 5 Sep 2006 18:15:09 +0000 Subject: [PATCH] If brush is too big, it would play an incorrect sound. Now clipping array index. --- src/tuxpaint.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 1d03e7831..9e59c4ea3 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -1200,6 +1200,7 @@ static void mirror_starter(void); static void flip_starter(void); int valid_click(Uint8 button); int in_circle(int x, int y); +int paintsound(int size); #ifdef DEBUG static char *debug_gettext(const char *str); @@ -2656,7 +2657,7 @@ static void mainloop(void) reset_brush_counter(); brush_draw(old_x, old_y, old_x, old_y, 1); - playsound(screen, 0, SND_PAINT1 + (img_cur_brush_w) / 12, 1, + playsound(screen, 0, paintsound(img_cur_brush_w), 1, event.button.x, SNDDIST_NEAR); } else if (cur_tool == TOOL_STAMP) @@ -3209,7 +3210,7 @@ static void mainloop(void) brush_draw(old_x, old_y, new_x, new_y, 1); - playsound(screen, 0, SND_PAINT1 + (img_cur_brush_w) / 12, 0, + playsound(screen, 0, paintsound(img_cur_brush_w), 0, event.button.x, SNDDIST_NEAR); } else if (cur_tool == TOOL_LINES) @@ -15188,3 +15189,11 @@ int in_circle(int x, int y) else return (0); } + +int paintsound(int size) +{ + if (SND_PAINT1 + (size / 12) >= SND_PAINT4) + return(SND_PAINT4); + else + return(SND_PAINT1 + (size / 12)); +}