added separate time counter for tape time frames
[rocksndiamonds.git] / src / game.c
index fd943b996e0155de3c0509a8498cc9e7a445e29a..789fb0159ba165689ba3b14896f58855ef41f7d0 100644 (file)
@@ -3843,6 +3843,8 @@ void InitGame(void)
   TimeFrames = 0;
   TimePlayed = 0;
   TimeLeft = level.time;
+
+  TapeTimeFrames = 0;
   TapeTime = 0;
 
   ScreenMovDir = MV_NONE;
@@ -9448,7 +9450,7 @@ static void Life(int ax, int ay)
 
   for (y1 = -1; y1 < 2; y1++) for (x1 = -1; x1 < 2; x1++)
   {
-    int xx = ax+x1, yy = ay+y1;
+    int xx = ax + x1, yy = ay + y1;
     int old_element = Tile[xx][yy];
     int num_neighbours = 0;
 
@@ -9457,7 +9459,7 @@ static void Life(int ax, int ay)
 
     for (y2 = -1; y2 < 2; y2++) for (x2 = -1; x2 < 2; x2++)
     {
-      int x = xx+x2, y = yy+y2;
+      int x = xx + x2, y = yy + y2;
 
       if (!IN_LEV_FIELD(x, y) || (x == xx && y == yy))
        continue;
@@ -11679,7 +11681,6 @@ static void CheckLevelTime(void)
   if (TimeFrames >= FRAMES_PER_SECOND)
   {
     TimeFrames = 0;
-    TapeTime++;
 
     for (i = 0; i < MAX_PLAYERS; i++)
     {
@@ -11726,6 +11727,12 @@ static void CheckLevelTime(void)
 
       game_em.lev->time = (game.no_level_time_limit ? TimePlayed : TimeLeft);
     }
+  }
+
+  if (TapeTimeFrames >= FRAMES_PER_SECOND)
+  {
+    TapeTimeFrames = 0;
+    TapeTime++;
 
     if (tape.recording || tape.playing)
       DrawVideoDisplay(VIDEO_STATE_TIME_ON, TapeTime);
@@ -11741,8 +11748,11 @@ void AdvanceFrameAndPlayerCounters(int player_nr)
 {
   int i;
 
-  // advance frame counters (global frame counter and time frame counter)
+  // advance frame counters (global frame counter and tape time frame counter)
   FrameCounter++;
+  TapeTimeFrames++;
+
+  // advance time frame counter (used to control available time to solve level)
   TimeFrames++;
 
   // advance player counters (counters for move delay, move animation etc.)
@@ -15705,7 +15715,9 @@ void RequestQuitGameExt(boolean skip_request, boolean quick_quit, char *message)
     }
 
     if (network.enabled)
+    {
       SendToServer_StopPlaying(NETWORK_STOP_BY_PLAYER);
+    }
     else
     {
       if (quick_quit)
@@ -16034,6 +16046,7 @@ static ListNode *SaveEngineSnapshotBuffers(void)
   SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(TimeFrames));
   SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(TimePlayed));
   SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(TimeLeft));
+  SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(TapeTimeFrames));
   SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(TapeTime));
 
   SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(ScreenMovDir));