fixed score time for BD engine
authorHolger Schemel <holger.schemel@virtion.de>
Sat, 11 May 2024 11:24:18 +0000 (13:24 +0200)
committerHolger Schemel <holger.schemel@virtion.de>
Sat, 11 May 2024 11:24:18 +0000 (13:24 +0200)
src/game.c
src/game_bd/export_bd.h
src/game_bd/main_bd.c

index 1966bb3c6c03ec01db36464d7fce410a6fbedd9a..d835b19f8cb9b11be758fdfe42502cc754d138d6 100644 (file)
@@ -4864,7 +4864,8 @@ static void LevelSolved_SetFinalGameValues(void)
 {
   game.time_final = (level.game_engine_type == GAME_ENGINE_TYPE_BD ? game_bd.time_left :
                     game.no_level_time_limit ? TimePlayed : TimeLeft);
-  game.score_time_final = (level.use_step_counter ? TimePlayed :
+  game.score_time_final = (level.game_engine_type == GAME_ENGINE_TYPE_BD ? game_bd.frames_played :
+                           level.use_step_counter ? TimePlayed :
                           TimePlayed * FRAMES_PER_SECOND + TimeFrames);
 
   game.score_final = (level.game_engine_type == GAME_ENGINE_TYPE_BD ? game_bd.score :
@@ -11835,6 +11836,9 @@ static void CheckLevelTime(void)
     // if last second running, wait for native engine time to exactly reach zero
     if (getTimeLeft_BD() == 1 && TimeLeft == 1)
       TimeFrames = frames_per_second - 1;
+
+    // needed to store final time after solving game (before counting down remaining time)
+    SetTimeFrames_BD(TimePlayed * FRAMES_PER_SECOND + TimeFrames);
   }
 
   if (TimeFrames >= frames_per_second)
index f11a4aad60f9ea2eab548e35c9a01c6e58d316df..2344d2d07bfa9de9917ed81486770b453c2ec527 100644 (file)
@@ -47,6 +47,9 @@ struct GameInfo_BD
   int time_left;
   int gems_still_needed;
   int score;
+
+  // needed for saving score time
+  int frames_played;
 };
 
 struct LevelInfo_BD
@@ -96,6 +99,7 @@ boolean checkGamePlaying_BD(void);
 boolean checkBonusTime_BD(void);
 int getFramesPerSecond_BD(void);
 int getTimeLeft_BD(void);
+void SetTimeFrames_BD(int);
 
 void InitGfxBuffers_BD(void);
 
index 32305736fda1a21780d7d4fc923e2ec4ff6733a1..e6def9ed41643850f7e1dead0799690339f5cd08 100644 (file)
@@ -255,6 +255,14 @@ int getTimeLeft_BD(void)
   return 0;
 }
 
+void SetTimeFrames_BD(int frames_played)
+{
+  // needed to store final time after solving game (before counting down remaining time)
+  if (game_bd.game->state_counter == GAME_INT_CAVE_RUNNING)
+    game_bd.frames_played = frames_played;
+
+}
+
 static void UpdateGameDoorValues_BD(void)
 {
   GdCave *cave = game_bd.game->cave;