changed "http" to "https" in URLs
[rocksndiamonds.git] / src / tape.c
index d1d4aa6b6ad5cd8cc8ba3d3b1351e014263bb9dd..3f031f01018e117ef029ef04bea72d2c5457c8f3 100644 (file)
@@ -4,7 +4,7 @@
 // (c) 1995-2014 by Artsoft Entertainment
 //                         Holger Schemel
 //                 info@artsoft.org
-//                 http://www.artsoft.org/
+//                 https://www.artsoft.org/
 // ----------------------------------------------------------------------------
 // tape.c
 // ============================================================================
@@ -547,7 +547,9 @@ void TapeErase(void)
   tape.centered_player_nr_next = -1;
   tape.set_centered_player = FALSE;
 
-  tape.use_mouse = (level.game_engine_type == GAME_ENGINE_TYPE_MM);
+  // set flags for game actions to default values (may be overwritten later)
+  tape.use_key_actions = TRUE;
+  tape.use_mouse_actions = FALSE;
 }
 
 static void TapeRewind(void)
@@ -596,6 +598,10 @@ void TapeStartRecording(int random_seed)
 
   SetDrawDeactivationMask(REDRAW_NONE);
   audio.sound_deactivated = FALSE;
+
+  // required here to update video display if tape door is closed
+  if (GetDoorState() & DOOR_CLOSE_2)
+    OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
 }
 
 static void TapeStartGameRecording(void)
@@ -656,7 +662,7 @@ void TapeStopRecording(void)
   MapTapeEjectButton();
 }
 
-boolean TapeAddAction(byte action[MAX_PLAYERS])
+boolean TapeAddAction(byte action[MAX_TAPE_ACTIONS])
 {
   int i;
 
@@ -664,7 +670,7 @@ boolean TapeAddAction(byte action[MAX_PLAYERS])
   {
     boolean changed_events = FALSE;
 
-    for (i = 0; i < MAX_PLAYERS; i++)
+    for (i = 0; i < MAX_TAPE_ACTIONS; i++)
       if (tape.pos[tape.counter].action[i] != action[i])
        changed_events = TRUE;
 
@@ -682,7 +688,7 @@ boolean TapeAddAction(byte action[MAX_PLAYERS])
 
   if (tape.pos[tape.counter].delay == 0)       // store new action
   {
-    for (i = 0; i < MAX_PLAYERS; i++)
+    for (i = 0; i < MAX_TAPE_ACTIONS; i++)
       tape.pos[tape.counter].action[i] = action[i];
 
     tape.pos[tape.counter].delay++;
@@ -691,18 +697,18 @@ boolean TapeAddAction(byte action[MAX_PLAYERS])
   return TRUE;
 }
 
-void TapeRecordAction(byte action_raw[MAX_PLAYERS])
+void TapeRecordAction(byte action_raw[MAX_TAPE_ACTIONS])
 {
-  byte action[MAX_PLAYERS];
+  byte action[MAX_TAPE_ACTIONS];
   int i;
 
   if (!tape.recording)         // (record action even when tape is paused)
     return;
 
-  for (i = 0; i < MAX_PLAYERS; i++)
+  for (i = 0; i < MAX_TAPE_ACTIONS; i++)
     action[i] = action_raw[i];
 
-  if (!tape.use_mouse && tape.set_centered_player)
+  if (tape.use_key_actions && tape.set_centered_player)
   {
     for (i = 0; i < MAX_PLAYERS; i++)
       if (tape.centered_player_nr_next == i ||
@@ -760,14 +766,17 @@ void TapeTogglePause(boolean toggle_mode)
     return;
   }
 
-  if (setup.show_snapshot_buttons &&
-      game_status == GAME_MODE_PLAYING &&
-      CheckEngineSnapshotList())
+  if (game_status == GAME_MODE_PLAYING)
   {
-    if (tape.pausing)
-      MapUndoRedoButtons();
-    else if (!tape.single_step)
-      UnmapUndoRedoButtons();
+    if (setup.show_snapshot_buttons && CheckEngineSnapshotList())
+    {
+      if (tape.pausing)
+       MapUndoRedoButtons();
+      else if (!tape.single_step)
+       UnmapUndoRedoButtons();
+    }
+
+    ModifyPauseButtons();
   }
 }
 
@@ -818,7 +827,7 @@ byte *TapePlayAction(void)
   int update_delay = FRAMES_PER_SECOND / 2;
   boolean update_video_display = (FrameCounter % update_delay == 0);
   boolean update_draw_label_on = ((FrameCounter / update_delay) % 2 == 1);
-  static byte action[MAX_PLAYERS];
+  static byte action[MAX_TAPE_ACTIONS];
   int i;
 
   if (!tape.playing || tape.pausing)
@@ -867,12 +876,12 @@ byte *TapePlayAction(void)
     DrawVideoDisplaySymbol(state);
   }
 
-  for (i = 0; i < MAX_PLAYERS; i++)
+  for (i = 0; i < MAX_TAPE_ACTIONS; i++)
     action[i] = tape.pos[tape.counter].action[i];
 
 #if DEBUG_TAPE_WHEN_PLAYING
   printf("%05d", FrameCounter);
-  for (i = 0; i < MAX_PLAYERS; i++)
+  for (i = 0; i < MAX_TAPE_ACTIONS; i++)
     printf("   %08x", action[i]);
   printf("\n");
 #endif
@@ -880,7 +889,7 @@ byte *TapePlayAction(void)
   tape.set_centered_player = FALSE;
   tape.centered_player_nr_next = -999;
 
-  if (!tape.use_mouse)
+  if (tape.use_key_actions)
   {
     for (i = 0; i < MAX_PLAYERS; i++)
     {
@@ -1128,9 +1137,9 @@ boolean PlaySolutionTape(void)
 }
 
 
-/* ------------------------------------------------------------------------- *
- * tape autoplay functions
- * ------------------------------------------------------------------------- */
+// ----------------------------------------------------------------------------
+// tape autoplay functions
+// ----------------------------------------------------------------------------
 
 void AutoPlayTape(void)
 {
@@ -1244,12 +1253,13 @@ void AutoPlayTape(void)
   PrintLine("=", 79);
   Print("Number of levels played: %d\n", num_levels_played);
   Print("Number of levels solved: %d (%d%%)\n", num_levels_solved,
-        (num_levels_played ? num_levels_solved * 100 / num_levels_played :0));
+       (num_levels_played ? num_levels_solved * 100 / num_levels_played : 0));
   PrintLine("-", 79);
   Print("Summary (for automatic parsing by scripts):\n");
-  Print("LEVELDIR '%s', SOLVED %d/%d (%d%%)",
-        autoplay_leveldir->identifier, num_levels_solved, num_levels_played,
-        (num_levels_played ? num_levels_solved * 100 / num_levels_played :0));
+  Print("LEVELDIR [%s] '%s', SOLVED %d/%d (%d%%)",
+       (num_levels_played == num_levels_solved ? " OK " : "WARN"),
+       autoplay_leveldir->identifier, num_levels_solved, num_levels_played,
+       (num_levels_played ? num_levels_solved * 100 / num_levels_played : 0));
 
   if (num_levels_played != num_levels_solved)
   {
@@ -1405,9 +1415,6 @@ void RedrawTapeButtons(void)
 
   if (tape.show_game_buttons)
     RedrawGameButtonsOnTape();
-
-  // RedrawGadget() may have set REDRAW_ALL if buttons are defined off-area
-  redraw_mask &= ~REDRAW_ALL;
 }
 
 void RedrawOrRemapTapeButtons(void)