rnd-20031208-1-src
[rocksndiamonds.git] / src / tape.c
index 69ed9f938039936889111782f35b9a8e722d4ab8..51dcd8a2e0d85e4b47f12267cba9fef24ae118f2 100644 (file)
@@ -177,7 +177,7 @@ void DrawVideoDisplay(unsigned long state, unsigned long value)
               VY + VIDEO_REC_LABEL_YPOS);
   }
 
-  for(i=0;i<10;i++)
+  for (i = 0; i < 10; i++)
   {
     if (state & (1<<i))
     {
@@ -316,7 +316,12 @@ void TapeErase()
   tape.game_version = GAME_VERSION_ACTUAL;
   tape.engine_version = level.game_version;
 
-  for(i=0; i<MAX_PLAYERS; i++)
+#if 0
+  printf("::: tape.engine_version = level.game_version = %d \n",
+        level.game_version);
+#endif
+
+  for (i = 0; i < MAX_PLAYERS; i++)
     tape.player_participates[i] = FALSE;
 }
 
@@ -366,7 +371,7 @@ static void TapeStartGameRecording()
   else
 #endif
   {
-    game_status = PLAYING;
+    game_status = GAME_MODE_PLAYING;
     StopAnimation();
     InitGame();
   }
@@ -428,7 +433,7 @@ void TapeRecordAction(byte action[MAX_PLAYERS])
   {
     boolean changed_events = FALSE;
 
-    for(i=0; i<MAX_PLAYERS; i++)
+    for (i = 0; i < MAX_PLAYERS; i++)
       if (tape.pos[tape.counter].action[i] != action[i])
        changed_events = TRUE;
 
@@ -443,7 +448,7 @@ void TapeRecordAction(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_PLAYERS; i++)
       tape.pos[tape.counter].action[i] = action[i];
 
     tape.pos[tape.counter].delay++;
@@ -511,7 +516,7 @@ static void TapeStartGamePlaying()
 {
   TapeStartPlaying();
 
-  game_status = PLAYING;
+  game_status = GAME_MODE_PLAYING;
   StopAnimation();
   InitGame();
 }
@@ -566,7 +571,7 @@ byte *TapePlayAction()
     return NULL;
   }
 
-  for(i=0; i<MAX_PLAYERS; i++)
+  for (i = 0; i < MAX_PLAYERS; i++)
     action[i] = tape.pos[tape.counter].action[i];
 
   tape.delay_played++;
@@ -591,8 +596,10 @@ void TapeStop()
     DrawVideoDisplay(VIDEO_STATE_TIME_ON, tape.length_seconds);
   }
 
+#if 0
   if (tape.auto_play)
     AutoPlayTape();    /* continue automatically playing next tape */
+#endif
 }
 
 unsigned int GetTapeLength()
@@ -603,7 +610,7 @@ unsigned int GetTapeLength()
   if (TAPE_IS_EMPTY(tape))
     return(0);
 
-  for(i=0;i<tape.length;i++)
+  for (i = 0; i < tape.length; i++)
     tape_length += tape.pos[i].delay;
 
   return(tape_length * GAME_FRAME_DELAY / 1000);
@@ -646,7 +653,7 @@ static void TapeSingleStep()
 
 void TapeQuickSave()
 {
-  if (game_status == PLAYING)
+  if (game_status == GAME_MODE_PLAYING)
   {
     if (tape.recording)
       TapeHaltRecording();     /* prepare tape for saving on-the-fly */
@@ -656,13 +663,13 @@ void TapeQuickSave()
     else
       SaveTape(tape.level_nr);
   }
-  else if (game_status == MAINMENU)
+  else if (game_status == GAME_MODE_MAIN)
     Request("No game that can be saved !", REQ_CONFIRM);
 }
 
 void TapeQuickLoad()
 {
-  if (game_status == PLAYING || game_status == MAINMENU)
+  if (game_status == GAME_MODE_PLAYING || game_status == GAME_MODE_MAIN)
   {
     TapeStop();
     TapeErase();
@@ -680,6 +687,19 @@ void TapeQuickLoad()
   }
 }
 
+void InsertSolutionTape()
+{
+  if (!TAPE_IS_EMPTY(tape))
+    return;
+
+  LoadSolutionTape(level_nr);
+
+  if (TAPE_IS_EMPTY(tape))
+    Request("No solution tape for this level !", REQ_CONFIRM);
+
+  DrawCompleteVideoDisplay();
+}
+
 
 /* ------------------------------------------------------------------------- *
  * tape autoplay functions
@@ -740,7 +760,7 @@ void AutoPlayTape()
     printf_line("=", 79);
     printf("\n");
 
-    for (i=0; i<MAX_NUM_AUTOPLAY_LEVELS; i++)
+    for (i = 0; i < MAX_NUM_AUTOPLAY_LEVELS; i++)
       levels_failed[i] = FALSE;
 
     autoplay_initialized = TRUE;
@@ -761,7 +781,7 @@ void AutoPlayTape()
       continue;
     }
 
-    LoadTape(level_nr);
+    LoadSolutionTape(level_nr);
     if (TAPE_IS_EMPTY(tape))
     {
       printf("(no tape)\n");
@@ -789,7 +809,7 @@ void AutoPlayTape()
   if (num_levels_played != num_levels_solved)
   {
     printf(", FAILED:");
-    for (i=0; i<MAX_NUM_AUTOPLAY_LEVELS; i++)
+    for (i = 0; i < MAX_NUM_AUTOPLAY_LEVELS; i++)
       if (levels_failed[i])
        printf(" %03d", i);
   }
@@ -858,7 +878,7 @@ void CreateTapeButtons()
 {
   int i;
 
-  for (i=0; i<NUM_TAPE_BUTTONS; i++)
+  for (i = 0; i < NUM_TAPE_BUTTONS; i++)
   {
     Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
     struct GadgetInfo *gi;
@@ -903,7 +923,7 @@ void FreeTapeButtons()
 {
   int i;
 
-  for (i=0; i<NUM_TAPE_BUTTONS; i++)
+  for (i = 0; i < NUM_TAPE_BUTTONS; i++)
     FreeGadget(tape_gadget[i]);
 }
 
@@ -923,7 +943,7 @@ void MapTapeButtons()
 {
   int i;
 
-  for (i=0; i<NUM_TAPE_BUTTONS; i++)
+  for (i = 0; i < NUM_TAPE_BUTTONS; i++)
     if (i != TAPE_CTRL_ID_INDEX)
       MapGadget(tape_gadget[i]);
 
@@ -935,7 +955,7 @@ void UnmapTapeButtons()
 {
   int i;
 
-  for (i=0; i<NUM_TAPE_BUTTONS; i++)
+  for (i = 0; i < NUM_TAPE_BUTTONS; i++)
     UnmapGadget(tape_gadget[i]);
 }
 
@@ -943,7 +963,7 @@ static void HandleTapeButtons(struct GadgetInfo *gi)
 {
   int id = gi->custom_id;
 
-  if (game_status != MAINMENU && game_status != PLAYING)
+  if (game_status != GAME_MODE_MAIN && game_status != GAME_MODE_PLAYING)
     return;
 
   switch (id)