From: Holger Schemel Date: Sun, 11 Feb 2024 00:41:25 +0000 (+0100) Subject: added special timeout sounds (for all game engines) X-Git-Tag: 4.4.0.0-test-1~404 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=d352042c48614e31f98321bcad1b4df6235569b9;p=rocksndiamonds.git added special timeout sounds (for all game engines) --- diff --git a/src/game.c b/src/game.c index 0dc8e067..4d0611b6 100644 --- a/src/game.c +++ b/src/game.c @@ -11669,6 +11669,23 @@ static void CheckLevelSolved(void) } } +static void PlayTimeoutSound(int seconds_left) +{ + // try to use individual "running out of time" sound for each second left + int sound = SND_GAME_RUNNING_OUT_OF_TIME_0 - seconds_left; + + // if special sound per second not defined, use default sound + if (getSoundInfoEntryFilename(sound) == NULL) + sound = SND_GAME_RUNNING_OUT_OF_TIME; + + // if out of time, but player still alive, play special "timeout" sound, if defined + if (seconds_left == 0 && !checkGameFailed()) + if (getSoundInfoEntryFilename(SND_GAME_TIMEOUT) != NULL) + sound = SND_GAME_TIMEOUT; + + PlaySound(sound); +} + static void CheckLevelTime_StepCounter(void) { int i; @@ -11680,7 +11697,7 @@ static void CheckLevelTime_StepCounter(void) TimeLeft--; if (TimeLeft <= 10 && game.time_limit && !game.LevelSolved) - PlaySound(SND_GAME_RUNNING_OUT_OF_TIME); + PlayTimeoutSound(TimeLeft); game_panel_controls[GAME_PANEL_TIME].value = TimeLeft; @@ -11728,7 +11745,7 @@ static void CheckLevelTime(void) TimeLeft--; if (TimeLeft <= 10 && game.time_limit) - PlaySound(SND_GAME_RUNNING_OUT_OF_TIME); + PlayTimeoutSound(TimeLeft); /* this does not make sense: game_panel_controls[GAME_PANEL_TIME].value is reset from other values in UpdateGameDoorValues() -- FIX THIS */