{
int tape_pos_size = 0;
- if (!tape->use_mouse)
+ if (tape->event_mask & GAME_EVENTS_KEYS)
tape_pos_size += tape->num_participating_players;
- else
+
+ if (tape->event_mask & GAME_EVENTS_MOUSE)
tape_pos_size += 3; // x and y position and mouse button mask
tape_pos_size += 1; // tape action delay value
return tape_pos_size;
}
+static int getGameEventMaskFromTapeEventValue(int value)
+{
+ switch (value)
+ {
+ case TAPE_EVENTS_KEYS_ONLY:
+ return GAME_EVENTS_KEYS;
+
+ case TAPE_EVENTS_MOUSE_ONLY:
+ return GAME_EVENTS_MOUSE;
+
+ case TAPE_EVENTS_KEYS_AND_MOUSE:
+ return GAME_EVENTS_KEYS | GAME_EVENTS_MOUSE;
+
+ default:
+ return GAME_EVENTS_DEFAULT;
+ }
+}
+
+static int getTapeEventValueFromGameEventMask(int mask)
+{
+ switch (mask)
+ {
+ case GAME_EVENTS_KEYS:
+ return TAPE_EVENTS_KEYS_ONLY;
+
+ case GAME_EVENTS_MOUSE:
+ return TAPE_EVENTS_MOUSE_ONLY;
+
+ case GAME_EVENTS_KEYS | GAME_EVENTS_MOUSE:
+ return TAPE_EVENTS_KEYS_AND_MOUSE;
+
+ default:
+ return TAPE_EVENTS_DEFAULT;
+ }
+}
+
static int LoadTape_VERS(File *file, int chunk_size, struct TapeInfo *tape)
{
tape->file_version = getFileVersion(file);
}
}
- tape->use_mouse = (getFile8Bit(file) == 1 ? TRUE : FALSE);
+ tape->event_mask = getGameEventMaskFromTapeEventValue(getFile8Bit(file));
ReadUnusedBytesFromFile(file, TAPE_CHUNK_HEAD_UNUSED);
// tape too large; read and ignore remaining tape data from this chunk
for (;i < tape->length; i++)
- ReadUnusedBytesFromFile(file, tape->num_participating_players + 1);
+ ReadUnusedBytesFromFile(file, tape_pos_size);
break;
}
- if (tape->use_mouse)
- {
- 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);
-
- tape->pos[i].action[TAPE_ACTION_UNUSED] = 0;
- }
- else
+ if (tape->event_mask & GAME_EVENTS_KEYS)
{
for (j = 0; j < MAX_PLAYERS; j++)
{
}
}
+ if (tape->event_mask & GAME_EVENTS_MOUSE)
+ {
+ 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);
+ }
+
tape->pos[i].delay = getFile8Bit(file);
if (tape->file_version == FILE_VERSION_1_0)
putFile8Bit(file, store_participating_players);
- putFile8Bit(file, (tape->use_mouse ? 1 : 0));
+ putFile8Bit(file, getTapeEventValueFromGameEventMask(tape->event_mask));
// 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++)
{
- 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
+ if (tape->event_mask & GAME_EVENTS_KEYS)
{
for (j = 0; j < MAX_PLAYERS; j++)
if (tape->player_participates[j])
putFile8Bit(file, tape->pos[i].action[j]);
}
+ if (tape->event_mask & GAME_EVENTS_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]);
+ }
+
putFile8Bit(file, tape->pos[i].delay);
}
}