rnd-19981123-3
authorHolger Schemel <info@artsoft.org>
Mon, 23 Nov 1998 01:02:45 +0000 (02:02 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:32:00 +0000 (10:32 +0200)
src/files.c
src/game.c
src/main.c
src/main.h
src/tape.c

index 80a5e7cb82f256380e227888ea8621d8f84b3cdd..81838cf4efe55b47d602ee5fff45f0dff7a148c3 100644 (file)
@@ -403,7 +403,6 @@ void LoadTape(int level_nr)
   char cookie[MAX_LINE_LEN];
   char chunk[CHUNK_ID_LEN + 1];
   FILE *file;
-  boolean player_participates[MAX_PLAYERS];
   int num_participating_players;
   int file_version = FILE_VERSION_1_2; /* last version of tape files */
   int chunk_length;
@@ -464,11 +463,11 @@ void LoadTape(int level_nr)
     num_participating_players = 0;
     for(i=0; i<MAX_PLAYERS; i++)
     {
-      player_participates[i] = FALSE;
+      tape.player_participates[i] = FALSE;
 
       if (store_participating_players & (1 << i))
       {
-       player_participates[i] = TRUE;
+       tape.player_participates[i] = TRUE;
        num_participating_players++;
       }
     }
@@ -511,7 +510,7 @@ void LoadTape(int level_nr)
       if (file_version == FILE_VERSION_1_0 && j > 0)
        continue;
 
-      if (player_participates[j])
+      if (tape.player_participates[j])
        tape.pos[i].action[j] = fgetc(file);
     }
 
@@ -559,11 +558,10 @@ void LoadTape(int level_nr)
 
 void SaveTape(int level_nr)
 {
-  int i, j;
+  int i;
   char filename[MAX_FILENAME_LEN];
   FILE *file;
   boolean new_tape = TRUE;
-  boolean player_participates[MAX_PLAYERS];
   byte store_participating_players;
   int num_participating_players;
   int chunk_length;
@@ -584,21 +582,12 @@ void SaveTape(int level_nr)
       return;
   }
 
-  for(i=0; i<MAX_PLAYERS; i++)
-    player_participates[i] = FALSE;
-
-  /* check which players participate in this tape recording */
-  for(i=0; i<tape.length; i++)
-    for(j=0; j<MAX_PLAYERS; j++)
-      if (tape.pos[i].action[j] != 0)
-       player_participates[j] = TRUE;
-
   /* count number of players and set corresponding bits for compact storage */
   store_participating_players = 0;
   num_participating_players = 0;
   for(i=0; i<MAX_PLAYERS; i++)
   {
-    if (player_participates[i])
+    if (tape.player_participates[i])
     {
       num_participating_players++;
       store_participating_players |= (1 << i);
@@ -656,7 +645,7 @@ void SaveTape(int level_nr)
     int j;
 
     for(j=0; j<MAX_PLAYERS; j++)
-      if (player_participates[j])
+      if (tape.player_participates[j])
        fputc(tape.pos[i].action[j], file);
 
     fputc(tape.pos[i].delay, file);
index e9f9d041c82b9475046f91eb1b1d7560e27b2006..2cb218582f2d7a39980a7f2b162debf97d6084ce 100644 (file)
@@ -427,20 +427,38 @@ void InitGame()
     }
   }
 
-  /* when in single player mode, eliminate all but the first active player */
-  if (!options.network && !setup.team_mode)
+  if (tape.playing)
+  {
+    /* when playing a tape, eliminate all players who do not participate */
+
+    for (i=0; i<MAX_PLAYERS; i++)
+    {
+      if (stored_player[i].active && !tape.player_participates[i])
+      {
+       struct PlayerInfo *player = &stored_player[i];
+       int jx = player->jx, jy = player->jy;
+
+       player->active = FALSE;
+       StorePlayer[jx][jy] = 0;
+       Feld[jx][jy] = EL_LEERRAUM;
+      }
+    }
+  }
+  else if (!options.network && !setup.team_mode)       /* && !tape.playing */
   {
+    /* when in single player mode, eliminate all but the first active player */
+
     for (i=0; i<MAX_PLAYERS; i++)
     {
       if (stored_player[i].active)
       {
        for (j=i+1; j<MAX_PLAYERS; j++)
        {
-         struct PlayerInfo *player = &stored_player[j];
-         int jx = player->jx, jy = player->jy;
-
-         if (player->active)
+         if (stored_player[j].active)
          {
+           struct PlayerInfo *player = &stored_player[j];
+           int jx = player->jx, jy = player->jy;
+
            player->active = FALSE;
            StorePlayer[jx][jy] = 0;
            Feld[jx][jy] = EL_LEERRAUM;
@@ -450,6 +468,14 @@ void InitGame()
     }
   }
 
+  /* when recording the game, store which players take part in the game */
+  if (tape.recording)
+  {
+    for (i=0; i<MAX_PLAYERS; i++)
+      if (stored_player[i].active)
+       tape.player_participates[i] = TRUE;
+  }
+
   if (options.verbose)
   {
     for (i=0; i<MAX_PLAYERS; i++)
index 47c9100837c23fd051c26c47a2f7112425335a18..462be9b4d47d6d107af0bb02df499b37e530ef9f 100644 (file)
@@ -105,7 +105,7 @@ struct LevelInfo    level;
 struct PlayerInfo      stored_player[MAX_PLAYERS], *local_player = NULL;
 struct HiScore         highscore[MAX_SCORE_ENTRIES];
 struct SoundInfo       Sound[NUM_SOUNDS];
-struct RecordingInfo   tape;
+struct TapeInfo                tape;
 struct OptionInfo      options;
 struct SetupInfo       setup;
 struct SetupFileList   *setup_list = NULL;
index 7a7484549d3e30956c66e9cb3f92f8c668ad72b0..47bc20fa879c22e7d2fbe4926bcbb7c3738f5d4c 100644 (file)
@@ -345,7 +345,7 @@ struct LevelDirInfo
   boolean readonly;
 };
 
-struct RecordingInfo
+struct TapeInfo
 {
   int level_nr;
   unsigned long random_seed;
@@ -358,6 +358,7 @@ struct RecordingInfo
   boolean recording, playing, pausing;
   boolean fast_forward;
   boolean changed;
+  boolean player_participates[MAX_PLAYERS];
   struct
   {
     byte action[MAX_PLAYERS];
@@ -438,7 +439,7 @@ extern struct LevelDirInfo  leveldir[];
 extern struct LevelInfo                level;
 extern struct PlayerInfo       stored_player[], *local_player;
 extern struct HiScore          highscore[];
-extern struct RecordingInfo    tape;
+extern struct TapeInfo         tape;
 extern struct SoundInfo                Sound[];
 extern struct JoystickInfo     joystick[];
 extern struct OptionInfo       options;
index 2c600226716fcdb2988c5f7381b5dcbeb0116078..2cc0b39962eba632c9606af412956264e3a64f64 100644 (file)
@@ -20,6 +20,7 @@ void TapeStartRecording()
 {
   time_t zeit1 = time(NULL);
   struct tm *zeit2 = localtime(&zeit1);
+  int i;
 
   if (!TAPE_IS_STOPPED(tape))
     TapeStop();
@@ -35,6 +36,9 @@ void TapeStartRecording()
   tape.date = 10000*(zeit2->tm_year%100) + 100*zeit2->tm_mon + zeit2->tm_mday;
   tape.random_seed = InitRND(NEW_RANDOMIZE);
 
+  for(i=0; i<MAX_PLAYERS; i++)
+    tape.player_participates[i] = FALSE;
+
   DrawVideoDisplay(VIDEO_STATE_REC_ON, 0);
   DrawVideoDisplay(VIDEO_STATE_DATE_ON, tape.date);
   DrawVideoDisplay(VIDEO_STATE_TIME_ON, 0);