fixed bug which causes wrong score and time after solving level
authorHolger Schemel <info@artsoft.org>
Wed, 17 Sep 2025 17:36:05 +0000 (19:36 +0200)
committerHolger Schemel <info@artsoft.org>
Thu, 18 Sep 2025 13:15:23 +0000 (15:15 +0200)
This is a terrible bug that only happens if the "frames" part of the
level time counter (counted in frames and seconds) overflows exactly
at the moment when the level is solved, resulting in a wrong score
and time (that is one second or 50 frames too low) and therefore in a
better ranking in the high score table.

As the game uses 50 frames per second, about 2 % of all existing score
entries are affected by this bug (which can be fixed for the scores on
the high score server, but not for the locally stored personal scores).

src/game.c

index 36be17fc1654fd08452cae62e56dc0d5f38ebac1..4e26225db799c13efc7e37a2fc604b3eab1ccd05 100644 (file)
@@ -12368,7 +12368,7 @@ static void CheckLevelTime(void)
       }
     }
 
-    if (!game.LevelSolved && !level.use_step_counter)
+    if (!level.use_step_counter)
     {
       TimePlayed++;
 
@@ -12376,29 +12376,32 @@ static void CheckLevelTime(void)
       {
        TimeLeft--;
 
-       if (TimeLeft <= 10 && game.time_limit)
-         PlayTimeoutSound(TimeLeft);
+        if (!game.LevelSolved)
+        {
+         if (TimeLeft <= 10 && game.time_limit)
+           PlayTimeoutSound(TimeLeft);
 
-       /* this does not make sense: game_panel_controls[GAME_PANEL_TIME].value
-          is reset from other values in UpdateGameDoorValues() -- FIX THIS */
+         /* this does not make sense: game_panel_controls[GAME_PANEL_TIME].value
+            is reset from other values in UpdateGameDoorValues() -- FIX THIS */
 
-       game_panel_controls[GAME_PANEL_TIME].value = TimeLeft;
+         game_panel_controls[GAME_PANEL_TIME].value = TimeLeft;
 
-       if (!TimeLeft && game.time_limit)
-       {
-         if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
-         {
-           if (game_bd.game->cave->player_state == GD_PL_LIVING)
-             game_bd.game->cave->player_state = GD_PL_TIMEOUT;
-         }
-         else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
-         {
-           game_em.lev->killed_out_of_time = TRUE;
-         }
-         else
+         if (!TimeLeft && game.time_limit)
          {
-           for (i = 0; i < MAX_PLAYERS; i++)
-             KillPlayer(&stored_player[i]);
+           if (level.game_engine_type == GAME_ENGINE_TYPE_BD)
+           {
+             if (game_bd.game->cave->player_state == GD_PL_LIVING)
+               game_bd.game->cave->player_state = GD_PL_TIMEOUT;
+           }
+           else if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
+           {
+             game_em.lev->killed_out_of_time = TRUE;
+           }
+           else
+           {
+             for (i = 0; i < MAX_PLAYERS; i++)
+               KillPlayer(&stored_player[i]);
+           }
          }
        }
       }