From: Holger Schemel Date: Sat, 20 Mar 2021 10:16:59 +0000 (+0100) Subject: changed calculating final game values when game is really over X-Git-Tag: 4.3.0.0~201 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=ef1162b39495bd80698e6e449060ba82a43ed21c;p=rocksndiamonds.git changed calculating final game values when game is really over Before this change, final game values (like final score and final playing time or steps) were calculated before the game was really over (but instead at the time the player started moving to the exit). This especially caused calculating a wrong playing time that did not include the time the player needed to finally reach the exit, which was especially wrong when using steps instead of seconds/frames to count the playing time, as the very last step was always missing in this case. This change fixes this bug by moving the code to calculate the final game values to a later point where there is no player action anymore. --- diff --git a/src/game.c b/src/game.c index 1b2db60f..2432ab34 100644 --- a/src/game.c +++ b/src/game.c @@ -4708,24 +4708,6 @@ static void LevelSolved(void) game.LevelSolved = TRUE; game.GameOver = TRUE; - - 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; } void GameWon(void) @@ -4748,6 +4730,24 @@ 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; + game.LevelSolved_GameWon = TRUE; game.LevelSolved_SaveTape = tape.recording; game.LevelSolved_SaveScore = !tape.playing;