X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ffiles.c;h=95256480249e9e672862aed626d16d9629e8358f;hb=91601455766f1749465cd064b54b8158313c0d51;hp=bc076598094227a1dfece0a6d33d359ff7a2b188;hpb=58ea80c54f5a1e6605e2c33b554dff1fcc0c26b5;p=rocksndiamonds.git diff --git a/src/files.c b/src/files.c index bc076598..95256480 100644 --- a/src/files.c +++ b/src/files.c @@ -768,9 +768,15 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] = &li.android_clone_time, 10 }, { - EL_EMC_ANDROID, -1, + EL_EMC_ANDROID, SAVE_CONF_NEVER, TYPE_ELEMENT_LIST, CONF_VALUE_BYTES(1), &li.android_clone_element[0], EL_EMPTY, NULL, + &li.num_android_clone_elements, 1, MAX_ANDROID_ELEMENTS_OLD + }, + { + EL_EMC_ANDROID, -1, + TYPE_ELEMENT_LIST, CONF_VALUE_BYTES(2), + &li.android_clone_element[0], EL_EMPTY, NULL, &li.num_android_clone_elements, 1, MAX_ANDROID_ELEMENTS }, @@ -809,7 +815,7 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] = { EL_EMC_MAGIC_BALL, -1, TYPE_BOOLEAN, CONF_VALUE_8_BIT(2), - &li.ball_state_initial, FALSE + &li.ball_active_initial, FALSE }, { EL_EMC_MAGIC_BALL, -1, @@ -3548,7 +3554,7 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) cav->android_move_time = level->android_move_time; cav->android_clone_time = level->android_clone_time; cav->ball_random = level->ball_random; - cav->ball_state = level->ball_state_initial; + cav->ball_active = level->ball_active_initial; cav->ball_time = level->ball_time; cav->num_ball_arrays = level->num_ball_contents; @@ -3561,8 +3567,6 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) cav->wind_direction = map_direction_RND_to_EM(level->wind_direction_initial); - cav->wind_cnt = (level->wind_direction_initial != MV_NONE ? - cav->wind_time : 0); for (i = 0; i < MAX_ELEMENT_CONTENTS; i++) for (j = 0; j < 8; j++) @@ -3660,7 +3664,7 @@ static void CopyNativeLevel_EM_to_RND(struct LevelInfo *level) level->android_move_time = cav->android_move_time; level->android_clone_time = cav->android_clone_time; level->ball_random = cav->ball_random; - level->ball_state_initial = cav->ball_state; + level->ball_active_initial = cav->ball_active; level->ball_time = cav->ball_time; level->num_ball_contents = cav->num_ball_arrays; @@ -3982,7 +3986,7 @@ static void CopyNativeTape_SP_to_RND(struct LevelInfo *level) int demo_repeat = (demo->data[i] & 0xf0) >> 4; int tape_action = map_key_SP_to_RND(demo_action); int tape_repeat = demo_repeat + 1; - byte action[MAX_PLAYERS] = { tape_action, 0, 0, 0 }; + byte action[MAX_TAPE_ACTIONS] = { tape_action }; boolean success = 0; int j; @@ -7615,6 +7619,57 @@ static void setTapeInfoToDefaults(void) tape.no_valid_file = FALSE; } +static int getTapePosSize(struct TapeInfo *tape) +{ + int tape_pos_size = 0; + + if (tape->event_mask & GAME_EVENTS_KEYS) + tape_pos_size += tape->num_participating_players; + + 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); @@ -7650,7 +7705,7 @@ static int LoadTape_HEAD(File *file, int chunk_size, struct TapeInfo *tape) } } - tape->use_mouse = (getFile8Bit(file) == 1 ? TRUE : FALSE); + tape->event_mask = getGameEventMaskFromTapeEventValue(getFile8Bit(file)); ReadUnusedBytesFromFile(file, TAPE_CHUNK_HEAD_UNUSED); @@ -7687,8 +7742,7 @@ static int LoadTape_INFO(File *file, int chunk_size, struct TapeInfo *tape) static int LoadTape_BODY(File *file, int chunk_size, struct TapeInfo *tape) { int i, j; - int tape_pos_size = - (tape->use_mouse ? 3 : tape->num_participating_players) + 1; + int tape_pos_size = getTapePosSize(tape); int chunk_size_expected = tape_pos_size * tape->length; if (chunk_size_expected != chunk_size) @@ -7706,20 +7760,12 @@ static int LoadTape_BODY(File *file, int chunk_size, struct TapeInfo *tape) // 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++) { @@ -7730,6 +7776,13 @@ static int LoadTape_BODY(File *file, int chunk_size, struct TapeInfo *tape) } } + 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) @@ -8053,7 +8106,7 @@ static void SaveTape_HEAD(FILE *file, struct TapeInfo *tape) 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); @@ -8080,19 +8133,20 @@ static void SaveTape_BODY(FILE *file, struct TapeInfo *tape) 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); } } @@ -8101,7 +8155,6 @@ void SaveTape(int nr) { char *filename = getTapeFilename(nr); FILE *file; - int num_participating_players = 0; int tape_pos_size; int info_chunk_size; int body_chunk_size; @@ -8118,12 +8171,14 @@ void SaveTape(int nr) tape.file_version = FILE_VERSION_ACTUAL; tape.game_version = GAME_VERSION_ACTUAL; + tape.num_participating_players = 0; + // count number of participating players for (i = 0; i < MAX_PLAYERS; i++) if (tape.player_participates[i]) - num_participating_players++; + tape.num_participating_players++; - tape_pos_size = (tape.use_mouse ? 3 : num_participating_players) + 1; + tape_pos_size = getTapePosSize(&tape); info_chunk_size = 2 + (strlen(tape.level_identifier) + 1) + 2; body_chunk_size = tape_pos_size * tape.length; @@ -8361,6 +8416,10 @@ static struct TokenInfo global_setup_tokens[] = TYPE_SWITCH, &setup.scroll_delay, "scroll_delay" }, + { + TYPE_SWITCH, + &setup.forced_scroll_delay, "forced_scroll_delay" + }, { TYPE_INTEGER, &setup.scroll_delay_value, "scroll_delay_value" @@ -9106,6 +9165,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->sound_simple = TRUE; si->toons = TRUE; si->scroll_delay = TRUE; + si->forced_scroll_delay = FALSE; si->scroll_delay_value = STD_SCROLL_DELAY; si->engine_snapshot_mode = getStringCopy(STR_SNAPSHOT_MODE_DEFAULT); si->engine_snapshot_memory = SNAPSHOT_MEMORY_DEFAULT; @@ -10300,6 +10360,9 @@ int get_parameter_value(char *value_raw, char *suffix, int type) if (string_has_parameter(value, "reverse")) result |= STYLE_REVERSE; + if (string_has_parameter(value, "block_clicks")) + result |= STYLE_BLOCK; + if (string_has_parameter(value, "passthrough_clicks")) result |= STYLE_PASSTHROUGH;