From: Holger Schemel Date: Sat, 18 Jan 2025 13:27:10 +0000 (+0100) Subject: fixed playing sounds for levels with small playfield in BD engine X-Git-Tag: 4.4.0.1~1 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=3718b06e7f744b9275cdaf046aed7647e65bc8c4;p=rocksndiamonds.git fixed playing sounds for levels with small playfield in BD engine --- diff --git a/src/game_bd/bd_sound.c b/src/game_bd/bd_sound.c index 7849e685..cefc7f3c 100644 --- a/src/game_bd/bd_sound.c +++ b/src/game_bd/bd_sound.c @@ -486,6 +486,16 @@ static void gd_sound_info_to_play(int channel, int x, int y, int element, int so si->sound = sound; } +static int get_middle_screen_level_position_x(GdCave *cave) +{ + return (cave->w < get_play_area_w() ? cave->w / 2 : get_play_area_w() / 2 + get_scroll_x()); +} + +static int get_middle_screen_level_position_y(GdCave *cave) +{ + return (cave->h < get_play_area_h() ? cave->h / 2 : get_play_area_h() / 2 + get_scroll_y()); +} + // plays sound in a cave void gd_sound_play(GdCave *cave, GdSound sound, GdElement element, int x, int y) { @@ -507,8 +517,8 @@ void gd_sound_play(GdCave *cave, GdSound sound, GdElement element, int x, int y) // when using native sound engine or if no position specified, use middle screen position if (game.use_native_bd_sound_engine || (x == -1 && y == -1)) { - x = get_play_area_w() / 2 + get_scroll_x(); - y = get_play_area_h() / 2 + get_scroll_y(); + x = get_middle_screen_level_position_x(cave); + y = get_middle_screen_level_position_y(cave); } if (!game.use_native_bd_sound_engine)