rnd-20100309-1-src
[rocksndiamonds.git] / src / tape.c
index a7bd35ee2f94196452216d1adcd08749b5119e5e..88f0f5a0300e4e0799ff9abf40cda0e138d3fd51 100644 (file)
@@ -453,12 +453,16 @@ void TapeDeactivateDisplayOff(boolean redraw_display)
 /* tape control functions                                                    */
 /* ========================================================================= */
 
-static void TapeSetDate()
+void TapeSetDateFromEpochSeconds(time_t epoch_seconds)
 {
-  time_t epoch_seconds = time(NULL);
-  struct tm *now = localtime(&epoch_seconds);
+  struct tm *lt = localtime(&epoch_seconds);
 
-  tape.date = 10000 * (now->tm_year % 100) + 100 * now->tm_mon + now->tm_mday;
+  tape.date = 10000 * (lt->tm_year % 100) + 100 * lt->tm_mon + lt->tm_mday;
+}
+
+void TapeSetDateFromNow()
+{
+  TapeSetDateFromEpochSeconds(time(NULL));
 }
 
 void TapeErase()
@@ -475,13 +479,13 @@ void TapeErase()
   tape.pos[tape.counter].delay = 0;
   tape.changed = TRUE;
 
-  tape.random_seed = InitRND(NEW_RANDOMIZE);
+  tape.random_seed = InitRND(level.random_seed);
 
   tape.file_version = FILE_VERSION_ACTUAL;
   tape.game_version = GAME_VERSION_ACTUAL;
   tape.engine_version = level.game_version;
 
-  TapeSetDate();
+  TapeSetDateFromNow();
 
   for (i = 0; i < MAX_PLAYERS; i++)
     tape.player_participates[i] = FALSE;
@@ -538,7 +542,7 @@ void TapeStartRecording(long random_seed)
 
 static void TapeStartGameRecording()
 {
-  TapeStartRecording(NEW_RANDOMIZE);
+  TapeStartRecording(level.random_seed);
 
 #if defined(NETWORK_AVALIABLE)
   if (options.network)
@@ -562,10 +566,14 @@ static void TapeAppendRecording()
   tape.recording = TRUE;
   tape.changed = TRUE;
 
-  TapeSetDate();
+  TapeSetDateFromNow();
 
   DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
   DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON, 0);
+
+#if 1
+  UpdateAndDisplayGameControlValues();
+#endif
 }
 
 void TapeHaltRecording()
@@ -919,11 +927,14 @@ void TapeQuickSave()
     TapeHaltRecording();       /* prepare tape for saving on-the-fly */
 
   if (TAPE_IS_EMPTY(tape))
+  {
     Request("No tape that can be saved !", REQ_CONFIRM);
-  else
-    SaveTape(tape.level_nr);
 
-  SaveEngineSnapshot();
+    return;
+  }
+
+  if (SaveTapeChecked(tape.level_nr))
+    SaveEngineSnapshot();
 }
 
 void TapeQuickLoad()
@@ -948,12 +959,14 @@ void TapeQuickLoad()
   if (game_status != GAME_MODE_PLAYING && game_status != GAME_MODE_MAIN)
     return;
 
-  if (1 && CheckEngineSnapshot())
+  if (CheckEngineSnapshot())
   {
     TapeStartGamePlaying();
 
     LoadEngineSnapshot();
 
+    DrawCompleteVideoDisplay();
+
     tape.playing = TRUE;
     tape.pausing = TRUE;
 
@@ -1234,6 +1247,7 @@ void CreateTapeButtons()
                      GDI_STATE, GD_BUTTON_UNPRESSED,
                      GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y,
                      GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y,
+                     GDI_DIRECT_DRAW, FALSE,
                      GDI_EVENT_MASK, GD_EVENT_RELEASED,
                      GDI_CALLBACK_ACTION, HandleTapeButtons,
                      GDI_END);
@@ -1296,18 +1310,22 @@ static void HandleTapeButtons(struct GadgetInfo *gi)
   {
     case TAPE_CTRL_ID_EJECT:
       TapeStop();
+
       if (TAPE_IS_EMPTY(tape))
       {
        LoadTape(level_nr);
+
        if (TAPE_IS_EMPTY(tape))
          Request("No tape for this level !", REQ_CONFIRM);
       }
       else
       {
        if (tape.changed)
-         SaveTape(tape.level_nr);
+         SaveTapeChecked(tape.level_nr);
+
        TapeErase();
       }
+
       DrawCompleteVideoDisplay();
       break;
 
@@ -1325,6 +1343,7 @@ static void HandleTapeButtons(struct GadgetInfo *gi)
       }
       else if (tape.recording)
        TapeSingleStep();
+
       break;
 
     case TAPE_CTRL_ID_STOP: