#define TAPE_CHUNK_VERS_SIZE 8 /* size of file version chunk */
#define TAPE_CHUNK_HEAD_SIZE 20 /* size of tape file header */
-#define TAPE_CHUNK_HEAD_UNUSED 3 /* unused tape header bytes */
+#define TAPE_CHUNK_HEAD_UNUSED 2 /* unused tape header bytes */
#define LEVEL_CHUNK_CNT3_SIZE(x) (LEVEL_CHUNK_CNT3_HEADER + (x))
#define LEVEL_CHUNK_CUS3_SIZE(x) (2 + (x) * LEVEL_CPART_CUS3_SIZE)
}
}
+ tape->use_mouse = (getFile8Bit(file) == 1 ? TRUE : FALSE);
+
ReadUnusedBytesFromFile(file, TAPE_CHUNK_HEAD_UNUSED);
engine_version = getFileVersion(file);
static int LoadTape_BODY(File *file, int chunk_size, struct TapeInfo *tape)
{
int i, j;
- int chunk_size_expected =
- (tape->num_participating_players + 1) * tape->length;
+ int tape_pos_size =
+ (tape->use_mouse ? 3 : tape->num_participating_players) + 1;
+ int chunk_size_expected = tape_pos_size * tape->length;
if (chunk_size_expected != chunk_size)
{
break;
}
- for (j = 0; j < MAX_PLAYERS; j++)
+ if (tape->use_mouse)
{
- tape->pos[i].action[j] = MV_NONE;
+ tape->pos[i].action[TAPE_ACTION_LX] = getFile8Bit(file);
+ tape->pos[i].action[TAPE_ACTION_LY] = getFile8Bit(file);
+ tape->pos[i].action[TAPE_ACTION_BUTTON] = getFile8Bit(file);
- if (tape->player_participates[j])
- tape->pos[i].action[j] = getFile8Bit(file);
+ tape->pos[i].action[TAPE_ACTION_UNUSED] = 0;
+ }
+ else
+ {
+ for (j = 0; j < MAX_PLAYERS; j++)
+ {
+ tape->pos[i].action[j] = MV_NONE;
+
+ if (tape->player_participates[j])
+ tape->pos[i].action[j] = getFile8Bit(file);
+ }
}
tape->pos[i].delay = getFile8Bit(file);
}
if (i != tape->length)
- chunk_size = (tape->num_participating_players + 1) * i;
+ chunk_size = tape_pos_size * i;
return chunk_size;
}
putFile8Bit(file, store_participating_players);
+ putFile8Bit(file, (tape->use_mouse ? 1 : 0));
+
/* unused bytes not at the end here for 4-byte alignment of engine_version */
WriteUnusedBytesToFile(file, TAPE_CHUNK_HEAD_UNUSED);
for (i = 0; i < tape->length; i++)
{
- for (j = 0; j < MAX_PLAYERS; j++)
- if (tape->player_participates[j])
- putFile8Bit(file, tape->pos[i].action[j]);
+ if (tape->use_mouse)
+ {
+ putFile8Bit(file, tape->pos[i].action[TAPE_ACTION_LX]);
+ putFile8Bit(file, tape->pos[i].action[TAPE_ACTION_LY]);
+ putFile8Bit(file, tape->pos[i].action[TAPE_ACTION_BUTTON]);
+ }
+ else
+ {
+ for (j = 0; j < MAX_PLAYERS; j++)
+ if (tape->player_participates[j])
+ putFile8Bit(file, tape->pos[i].action[j]);
+ }
putFile8Bit(file, tape->pos[i].delay);
}
char *filename = getTapeFilename(nr);
FILE *file;
int num_participating_players = 0;
+ int tape_pos_size;
int info_chunk_size;
int body_chunk_size;
int i;
if (tape.player_participates[i])
num_participating_players++;
+ tape_pos_size = (tape.use_mouse ? 3 : num_participating_players) + 1;
+
info_chunk_size = 2 + (strlen(tape.level_identifier) + 1) + 2;
- body_chunk_size = (num_participating_players + 1) * tape.length;
+ body_chunk_size = tape_pos_size * tape.length;
putFileChunkBE(file, "RND1", CHUNK_SIZE_UNDEFINED);
putFileChunkBE(file, "TAPE", CHUNK_SIZE_NONE);
}
}
+static void SetMouseActionFromTapeAction(struct MouseActionInfo *mouse_action,
+ byte *tape_action)
+{
+ mouse_action->lx = tape_action[TAPE_ACTION_LX];
+ mouse_action->ly = tape_action[TAPE_ACTION_LY];
+ mouse_action->button = tape_action[TAPE_ACTION_BUTTON];
+}
+
+static void SetTapeActionFromMouseAction(byte *tape_action,
+ struct MouseActionInfo *mouse_action)
+{
+ tape_action[TAPE_ACTION_LX] = mouse_action->lx;
+ tape_action[TAPE_ACTION_LY] = mouse_action->ly;
+ tape_action[TAPE_ACTION_BUTTON] = mouse_action->button;
+}
+
static void CheckLevelTime()
{
int i;
/* when playing tape, read previously recorded player input from tape data */
recorded_player_action = (tape.playing ? TapePlayAction() : NULL);
+ if (recorded_player_action != NULL)
+ SetMouseActionFromTapeAction(&local_player->mouse_action,
+ recorded_player_action);
+
/* TapePlayAction() may return NULL when toggling to "pause before death" */
if (tape.pausing)
return;
tape.player_participates[i] = TRUE;
}
+ SetTapeActionFromMouseAction(tape_action, &local_player->mouse_action);
+
/* only record actions from input devices, but not programmed actions */
if (tape.recording)
TapeRecordAction(tape_action);
tape.centered_player_nr_next = -1;
tape.set_centered_player = FALSE;
+
+ tape.use_mouse = (level.game_engine_type == GAME_ENGINE_TYPE_MM);
}
static void TapeRewind()
for (i = 0; i < MAX_PLAYERS; i++)
action[i] = action_raw[i];
- if (tape.set_centered_player)
+ if (!tape.use_mouse && tape.set_centered_player)
{
for (i = 0; i < MAX_PLAYERS; i++)
if (tape.centered_player_nr_next == i ||
tape.set_centered_player = FALSE;
tape.centered_player_nr_next = -999;
- for (i = 0; i < MAX_PLAYERS; i++)
+ if (!tape.use_mouse)
{
- if (action[i] & KEY_SET_FOCUS)
+ for (i = 0; i < MAX_PLAYERS; i++)
{
- tape.set_centered_player = TRUE;
- tape.centered_player_nr_next =
- (tape.centered_player_nr_next == -999 ? i : -1);
- }
+ if (action[i] & KEY_SET_FOCUS)
+ {
+ tape.set_centered_player = TRUE;
+ tape.centered_player_nr_next =
+ (tape.centered_player_nr_next == -999 ? i : -1);
+ }
- action[i] &= ~KEY_SET_FOCUS;
+ action[i] &= ~KEY_SET_FOCUS;
+ }
}
tape.delay_played++;
/* values for tape properties */
#define MAX_TAPE_LEN (1000 * FRAMES_PER_SECOND) /* max.time x fps */
+/* values for tape mouse actions */
+#define TAPE_ACTION_LX 0
+#define TAPE_ACTION_LY 1
+#define TAPE_ACTION_BUTTON 2
+#define TAPE_ACTION_UNUSED 3
+
/* some positions in the video tape control window */
#define VIDEO_DISPLAY1_XPOS 5
#define VIDEO_DISPLAY1_YPOS 5
int centered_player_nr_next;
boolean set_centered_player;
+ boolean use_mouse;
+
struct
{
byte action[MAX_PLAYERS];