From 2c5c63c03d263bcc50c98eb049d1e07baae9f55e Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 14 Jun 2021 16:50:00 +0200 Subject: [PATCH] fixed displaying invalid panel values when finishing a game This change fixes a graphical bug that occurs when the player solves a game by entering the exit. During that last movement, the level time in the game panel is displayed incorrectly as zero, because the final game values for time, score etc. are calculated not before the player has completed the last step (while the panel values are displayed from different variables in the last stage after winning a game). This is a fix for commit ef1162b3. --- src/game.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/src/game.c b/src/game.c index 0dc37771..0093ee45 100644 --- a/src/game.c +++ b/src/game.c @@ -4696,6 +4696,27 @@ void InitAmoebaNr(int x, int y) AmoebaCnt2[group_nr]++; } +static void LevelSolved_SetFinalGameValues(void) +{ + game.time_final = (game.no_time_limit ? TimePlayed : TimeLeft); + game.score_time_final = (level.use_step_counter ? TimePlayed : + TimePlayed * FRAMES_PER_SECOND + TimeFrames); + + game.score_final = (level.game_engine_type == GAME_ENGINE_TYPE_EM ? + game_em.lev->score : + level.game_engine_type == GAME_ENGINE_TYPE_MM ? + game_mm.score : + game.score); + + game.health_final = (level.game_engine_type == GAME_ENGINE_TYPE_MM ? + MM_HEALTH(game_mm.laser_overload_value) : + game.health); + + game.LevelSolved_CountingTime = game.time_final; + game.LevelSolved_CountingScore = game.score_final; + game.LevelSolved_CountingHealth = game.health_final; +} + static void LevelSolved(void) { if (level.game_engine_type == GAME_ENGINE_TYPE_RND && @@ -4704,6 +4725,9 @@ static void LevelSolved(void) game.LevelSolved = TRUE; game.GameOver = TRUE; + + // needed here to display correct panel values while player walks into exit + LevelSolved_SetFinalGameValues(); } void GameWon(void) @@ -4726,23 +4750,8 @@ void GameWon(void) if (local_player->active && local_player->MovPos) return; - game.time_final = (game.no_time_limit ? TimePlayed : TimeLeft); - game.score_time_final = (level.use_step_counter ? TimePlayed : - TimePlayed * FRAMES_PER_SECOND + TimeFrames); - - game.score_final = (level.game_engine_type == GAME_ENGINE_TYPE_EM ? - game_em.lev->score : - level.game_engine_type == GAME_ENGINE_TYPE_MM ? - game_mm.score : - game.score); - - game.health_final = (level.game_engine_type == GAME_ENGINE_TYPE_MM ? - MM_HEALTH(game_mm.laser_overload_value) : - game.health); - - game.LevelSolved_CountingTime = game.time_final; - game.LevelSolved_CountingScore = game.score_final; - game.LevelSolved_CountingHealth = game.health_final; + // calculate final game values after player finished walking into exit + LevelSolved_SetFinalGameValues(); game.LevelSolved_GameWon = TRUE; game.LevelSolved_SaveTape = tape.recording; -- 2.34.1