rnd-20020314-1-src
authorHolger Schemel <info@artsoft.org>
Thu, 14 Mar 2002 00:51:59 +0000 (01:51 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:36:08 +0000 (10:36 +0200)
src/files.c
src/game.c
src/main.h
src/tape.c

index 8ccb2466eca853ac23df9f22c2b7f09a9a3dc68d..ce7ff2d9a68f318c45f12982965fdea8cc570c3e 100644 (file)
@@ -35,7 +35,7 @@
 /* file identifier strings */
 #define LEVEL_COOKIE           "ROCKSNDIAMONDS_LEVEL_FILE_VERSION_2.0"
 #define SCORE_COOKIE           "ROCKSNDIAMONDS_SCORE_FILE_VERSION_1.2"
-#define TAPE_COOKIE            "ROCKSNDIAMONDS_TAPE_FILE_VERSION_1.2"
+#define TAPE_COOKIE            "ROCKSNDIAMONDS_TAPE_FILE_VERSION_2.0"
 #define SETUP_COOKIE           "ROCKSNDIAMONDS_SETUP_FILE_VERSION_1.2"
 #define LEVELSETUP_COOKIE      "ROCKSNDIAMONDS_LEVELSETUP_FILE_VERSION_1.2"
 #define LEVELINFO_COOKIE       "ROCKSNDIAMONDS_LEVELINFO_FILE_VERSION_1.2"
@@ -44,6 +44,7 @@
 #define LEVEL_COOKIE_12                "ROCKSNDIAMONDS_LEVEL_FILE_VERSION_1.2"
 #define LEVEL_COOKIE_14                "ROCKSNDIAMONDS_LEVEL_FILE_VERSION_1.4"
 #define TAPE_COOKIE_10         "ROCKSNDIAMONDS_LEVELREC_FILE_VERSION_1.0"
+#define TAPE_COOKIE_12         "ROCKSNDIAMONDS_TAPE_FILE_VERSION_1.2"
 
 /* file names and filename extensions */
 #if !defined(PLATFORM_MSDOS)
@@ -1410,6 +1411,10 @@ void LoadTape(int level_nr)
     }
   }
 
+#if DEBUG
+  printf("\nTAPE OF LEVEL %d\n", level_nr);
+#endif
+
   for(i=0; i<tape.length; i++)
   {
     if (i >= MAX_TAPELEN)
@@ -1421,10 +1426,30 @@ void LoadTape(int level_nr)
 
       if (tape.player_participates[j])
        tape.pos[i].action[j] = fgetc(file);
+
+#if DEBUG
+      {
+       int x = tape.pos[i].action[j];
+
+       printf("%d:%02x ", j, x);
+       printf("[%c%c%c%c|%c%c] - ",
+              (x & JOY_LEFT ? '<' : ' '),
+              (x & JOY_RIGHT ? '>' : ' '),
+              (x & JOY_UP ? '^' : ' '),
+              (x & JOY_DOWN ? 'v' : ' '),
+              (x & JOY_BUTTON_1 ? '1' : ' '),
+              (x & JOY_BUTTON_2 ? '2' : ' '));
+      }
+#endif
+
     }
 
     tape.pos[i].delay = fgetc(file);
 
+#if DEBUG
+    printf("[%03d]\n", tape.pos[i].delay);
+#endif
+
     if (file_version == FILE_VERSION_1_0)
     {
       /* eliminate possible diagonal moves in old tapes */
@@ -1452,6 +1477,23 @@ void LoadTape(int level_nr)
        tape.length += num_moves;
       }
     }
+    else if (file_version < FILE_VERSION_2_0)
+    {
+      if (tape.pos[i].delay > 1)
+      {
+       /* action part */
+       tape.pos[i + 1] = tape.pos[i];
+       tape.pos[i + 1].delay = 1;
+
+       /* delay part */
+       for(j=0; j<MAX_PLAYERS; j++)
+         tape.pos[i].action[j] = MV_NO_MOVING;
+       tape.pos[i].delay--;
+
+       i++;
+       tape.length++;
+      }
+    }
 
     if (feof(file))
       break;
index ef2fa469b19eefff66f64d85bb2b3a48ca13d678..50ffaf1662b441fa85bc712a0b9be8239e35326e 100644 (file)
@@ -1022,13 +1022,19 @@ void GameWon()
     game_status = HALLOFFAME;
     DrawHallOfFame(hi_pos);
     if (raise_level)
+    {
       level_nr++;
+      TapeErase();
+    }
   }
   else
   {
     game_status = MAINMENU;
     if (raise_level)
+    {
       level_nr++;
+      TapeErase();
+    }
     DrawMainMenu();
   }
 
@@ -4203,7 +4209,6 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action)
   static int num_stored_actions = 0;
   static boolean save_tape_entry = FALSE;
   boolean moved = FALSE, snapped = FALSE, bombed = FALSE;
-  int jx = player->jx, jy = player->jy;
   int left     = player_action & JOY_LEFT;
   int right    = player_action & JOY_RIGHT;
   int up       = player_action & JOY_UP;
@@ -4221,7 +4226,9 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action)
 
   if (player_action)
   {
+#if 0
     save_tape_entry = TRUE;
+#endif
     player->frame_reset_delay = 0;
 
     if (button1)
@@ -4233,15 +4240,22 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action)
       moved = MoveFigure(player, dx, dy);
     }
 
+#if 0
     if (tape.recording && (moved || snapped || bombed))
     {
       if (bombed && !moved)
        player_action &= JOY_BUTTON;
 
       stored_player_action[player->index_nr] = player_action;
+#if 1
+      save_tape_entry = TRUE;
+#endif
     }
     else if (tape.playing && snapped)
       SnapField(player, 0, 0);                 /* stop snapping */
+#else
+    stored_player_action[player->index_nr] = player_action;
+#endif
   }
   else
   {
@@ -4274,16 +4288,26 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action)
       player->Frame = 0;
   }
 
+#if 0
   if (tape.recording && num_stored_actions >= MAX_PLAYERS && save_tape_entry)
   {
     TapeRecordAction(stored_player_action);
     num_stored_actions = 0;
     save_tape_entry = FALSE;
   }
+#else
+  if (tape.recording && num_stored_actions >= MAX_PLAYERS)
+  {
+    TapeRecordAction(stored_player_action);
+    num_stored_actions = 0;
+  }
+#endif
 
+#if 0
   if (tape.playing && !tape.pausing && !player_action &&
       tape.counter < tape.length)
   {
+    int jx = player->jx, jy = player->jy;
     int next_joy =
       tape.pos[tape.counter].action[player->index_nr] & (JOY_LEFT|JOY_RIGHT);
 
@@ -4307,6 +4331,7 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action)
       }
     }
   }
+#endif
 }
 
 void GameActions()
@@ -4909,9 +4934,15 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy)
   if (!player->active || (!dx && !dy))
     return FALSE;
 
+#if 0
   if (!FrameReached(&player->move_delay, player->move_delay_value) &&
       !tape.playing)
     return FALSE;
+#else
+  if (!FrameReached(&player->move_delay, player->move_delay_value) &&
+      !(tape.playing && tape.file_version < FILE_VERSION_2_0))
+    return FALSE;
+#endif
 
   /* remove the last programmed player action */
   player->programmed_action = 0;
@@ -5761,9 +5792,16 @@ int DigField(struct PlayerInfo *player,
 
       if (player->push_delay == 0)
        player->push_delay = FrameCounter;
+#if 0
       if (!FrameReached(&player->push_delay, player->push_delay_value) &&
          !tape.playing && element != EL_SPRING)
        return MF_NO_ACTION;
+#else
+      if (!FrameReached(&player->push_delay, player->push_delay_value) &&
+         !(tape.playing && tape.file_version < FILE_VERSION_2_0) &&
+         element != EL_SPRING)
+       return MF_NO_ACTION;
+#endif
 
       RemoveField(x, y);
       Feld[x+dx][y+dy] = element;
@@ -5996,9 +6034,16 @@ int DigField(struct PlayerInfo *player,
 
       if (player->push_delay == 0)
        player->push_delay = FrameCounter;
+#if 0
       if (!FrameReached(&player->push_delay, player->push_delay_value) &&
          !tape.playing && element != EL_BALLOON)
        return MF_NO_ACTION;
+#else
+      if (!FrameReached(&player->push_delay, player->push_delay_value) &&
+         !(tape.playing && tape.file_version < FILE_VERSION_2_0) &&
+         element != EL_BALLOON)
+       return MF_NO_ACTION;
+#endif
 
       if (IS_SB_ELEMENT(element))
       {
index 803f0a0e53db82d8dc8375f61f374595acb469d3..72524c393d0593bd61be051f52cd61065060d8f4 100644 (file)
@@ -278,7 +278,7 @@ struct PlayerInfo
   int index_nr, client_nr, element_nr;
 
   byte action;                 /* action from local input device */
-  byte effective_action;       /* action aknowledged from network server
+  byte effective_action;       /* action acknowledged from network server
                                   or summarized over all configured input
                                   devices when in single player mode */
   byte programmed_action;      /* action forced by game itself (like moving
index 8771feddef94b86889ce4d2bcb7fc8fbf762a4b3..44bbc57bcbe440274f30575c61e5f462207c19ce 100644 (file)
@@ -18,6 +18,7 @@
 #include "tools.h"
 #include "files.h"
 #include "network.h"
+#include "cartoons.h"
 
 /* tape button identifiers */
 #define TAPE_CTRL_ID_EJECT             0
@@ -315,13 +316,17 @@ void TapeStartRecording()
 
 void TapeStopRecording()
 {
+#if 0
   int i;
+#endif
 
   if (!tape.recording)
     return;
 
+#if 0
   for(i=0; i<MAX_PLAYERS; i++)
     tape.pos[tape.counter].action[i] = 0;
+#endif
 
   tape.counter++;
   tape.length = tape.counter;
@@ -331,6 +336,7 @@ void TapeStopRecording()
   DrawVideoDisplay(VIDEO_STATE_REC_OFF, 0);
 }
 
+#if 0
 void TapeRecordAction(byte joy[MAX_PLAYERS])
 {
   int i;
@@ -351,6 +357,49 @@ void TapeRecordAction(byte joy[MAX_PLAYERS])
   tape.pos[tape.counter].delay = 0;
 }
 
+#else
+
+void TapeRecordAction(byte action[MAX_PLAYERS])
+{
+  int i;
+
+  if (!tape.recording || tape.pausing)
+    return;
+
+  if (tape.counter >= MAX_TAPELEN-1)
+  {
+    TapeStopRecording();
+    return;
+  }
+
+  if (tape.pos[tape.counter].delay > 0)                /* already stored action */
+  {
+    boolean changed_events = FALSE;
+
+    for(i=0; i<MAX_PLAYERS; i++)
+      if (tape.pos[tape.counter].action[i] != action[i])
+       changed_events = TRUE;
+
+    if (changed_events || tape.pos[tape.counter].delay >= 255)
+    {
+      tape.counter++;
+      tape.pos[tape.counter].delay = 0;
+    }
+    else
+      tape.pos[tape.counter].delay++;
+  }
+
+  if (tape.pos[tape.counter].delay == 0)       /* store new action */
+  {
+    for(i=0; i<MAX_PLAYERS; i++)
+      tape.pos[tape.counter].action[i] = action[i];
+
+    tape.pos[tape.counter].delay++;
+  }
+}
+#endif
+
+#if 0
 void TapeRecordDelay()
 {
   int i;
@@ -376,6 +425,13 @@ void TapeRecordDelay()
   }
 }
 
+#else
+
+void TapeRecordDelay()
+{
+}
+#endif
+
 void TapeTogglePause()
 {
   unsigned long state;
@@ -426,6 +482,7 @@ void TapeStopPlaying()
   DrawVideoDisplay(VIDEO_STATE_PLAY_OFF, 0);
 }
 
+#if 0
 byte *TapePlayAction()
 {
   static byte joy[MAX_PLAYERS];
@@ -457,6 +514,54 @@ byte *TapePlayAction()
   return(joy);
 }
 
+#else
+
+byte *TapePlayAction()
+{
+  static byte action[MAX_PLAYERS];
+  int i;
+
+  if (!tape.playing || tape.pausing)
+    return NULL;
+
+  if (tape.pause_before_death) /* STOP 10s BEFORE PLAYER GETS KILLED... */
+  {
+    if (!(FrameCounter % 20))
+    {
+      if ((FrameCounter / 20) % 2)
+       DrawVideoDisplay(VIDEO_STATE_PBEND_ON, VIDEO_DISPLAY_LABEL_ONLY);
+      else
+       DrawVideoDisplay(VIDEO_STATE_PBEND_OFF, VIDEO_DISPLAY_LABEL_ONLY);
+    }
+
+    if (TimePlayed > tape.length_seconds - TAPE_PAUSE_SECONDS_BEFORE_DEATH)
+    {
+      TapeTogglePause();
+      return NULL;
+    }
+  }
+
+  if (tape.counter >= tape.length)
+  {
+    TapeStop();
+    return NULL;
+  }
+
+  for(i=0; i<MAX_PLAYERS; i++)
+    action[i] = tape.pos[tape.counter].action[i];
+
+  tape.delay_played++;
+  if (tape.delay_played >= tape.pos[tape.counter].delay)
+  {
+    tape.counter++;
+    tape.delay_played = 0;
+  }
+
+  return action;
+}
+#endif
+
+#if 0
 boolean TapePlayDelay()
 {
   if (!tape.playing || tape.pausing)
@@ -494,6 +599,14 @@ boolean TapePlayDelay()
     return(FALSE);
 }
 
+#else
+
+boolean TapePlayDelay()
+{
+  return TRUE|FALSE;   /* ...it doesn't matter at all */
+}
+#endif
+
 void TapeStop()
 {
   TapeStopRecording();
@@ -675,6 +788,7 @@ static void HandleTapeButtons(struct GadgetInfo *gi)
 #endif
        {
          game_status = PLAYING;
+         StopAnimation();
          InitGame();
        }
       }
@@ -703,6 +817,7 @@ static void HandleTapeButtons(struct GadgetInfo *gi)
        TapeStartPlaying();
 
        game_status = PLAYING;
+       StopAnimation();
        InitGame();
       }
       else if (tape.playing)