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;
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++;
}
}
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);
}
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;
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);
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);
}
}
- /* 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;
}
}
+ /* 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++)
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;
boolean readonly;
};
-struct RecordingInfo
+struct TapeInfo
{
int level_nr;
unsigned long random_seed;
boolean recording, playing, pausing;
boolean fast_forward;
boolean changed;
+ boolean player_participates[MAX_PLAYERS];
struct
{
byte action[MAX_PLAYERS];
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;
{
time_t zeit1 = time(NULL);
struct tm *zeit2 = localtime(&zeit1);
+ int i;
if (!TAPE_IS_STOPPED(tape))
TapeStop();
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);