X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ffiles.c;h=c07043450023b9650e5102c5d9a9cb45b4e29f55;hp=51fd5b2ed313a22967001afe6eeeb477b3ec1c15;hb=b641818c787e48bbf03ce2a0cd5b542c4c21e523;hpb=4ab02221fe6e75f25e1e0ca9b069802b2d9da4bc diff --git a/src/files.c b/src/files.c index 51fd5b2e..c0704345 100644 --- a/src/files.c +++ b/src/files.c @@ -4,7 +4,7 @@ // (c) 1995-2014 by Artsoft Entertainment // Holger Schemel // info@artsoft.org -// http://www.artsoft.org/ +// https://www.artsoft.org/ // ---------------------------------------------------------------------------- // files.c // ============================================================================ @@ -3541,6 +3541,8 @@ static void CopyNativeLevel_RND_to_EM(struct LevelInfo *level) cav->key_score = level->score[SC_KEY]; cav->exit_score = level->score[SC_TIME_BONUS]; + cav->num_eater_arrays = level->num_yamyam_contents; + for (i = 0; i < MAX_ELEMENT_CONTENTS; i++) for (y = 0; y < 3; y++) for (x = 0; x < 3; x++) @@ -3649,9 +3651,9 @@ static void CopyNativeLevel_EM_to_RND(struct LevelInfo *level) level->score[SC_KEY] = cav->key_score; level->score[SC_TIME_BONUS] = cav->exit_score; - level->num_yamyam_contents = MAX_ELEMENT_CONTENTS; + level->num_yamyam_contents = cav->num_eater_arrays; - for (i = 0; i < level->num_yamyam_contents; i++) + for (i = 0; i < MAX_ELEMENT_CONTENTS; i++) for (y = 0; y < 3; y++) for (x = 0; x < 3; x++) level->yamyam_content[i].e[x][y] = @@ -6792,8 +6794,8 @@ static int SaveLevel_BODY(FILE *file, struct LevelInfo *level) int chunk_size = 0; int x, y; - for (y = 0; y < level->fieldy; y++) - for (x = 0; x < level->fieldx; x++) + for (y = 0; y < level->fieldy; y++) + for (x = 0; x < level->fieldx; x++) if (level->encoding_16bit_field) chunk_size += putFile16BitBE(file, level->field[x][y]); else @@ -7623,9 +7625,10 @@ static int getTapePosSize(struct TapeInfo *tape) { int tape_pos_size = 0; - if (!tape->use_mouse) + if (tape->use_key_actions) tape_pos_size += tape->num_participating_players; - else + + if (tape->use_mouse_actions) tape_pos_size += 3; // x and y position and mouse button mask tape_pos_size += 1; // tape action delay value @@ -7633,6 +7636,27 @@ static int getTapePosSize(struct TapeInfo *tape) return tape_pos_size; } +static void setTapeActionFlags(struct TapeInfo *tape, int value) +{ + tape->use_key_actions = FALSE; + tape->use_mouse_actions = FALSE; + + if (value != TAPE_USE_MOUSE_ACTIONS_ONLY) + tape->use_key_actions = TRUE; + + if (value != TAPE_USE_KEY_ACTIONS_ONLY) + tape->use_mouse_actions = TRUE; +} + +static int getTapeActionValue(struct TapeInfo *tape) +{ + return (tape->use_key_actions && + tape->use_mouse_actions ? TAPE_USE_KEY_AND_MOUSE_ACTIONS : + tape->use_key_actions ? TAPE_USE_KEY_ACTIONS_ONLY : + tape->use_mouse_actions ? TAPE_USE_MOUSE_ACTIONS_ONLY : + TAPE_ACTIONS_DEFAULT); +} + static int LoadTape_VERS(File *file, int chunk_size, struct TapeInfo *tape) { tape->file_version = getFileVersion(file); @@ -7668,7 +7692,7 @@ static int LoadTape_HEAD(File *file, int chunk_size, struct TapeInfo *tape) } } - tape->use_mouse = (getFile8Bit(file) == 1 ? TRUE : FALSE); + setTapeActionFlags(tape, getFile8Bit(file)); ReadUnusedBytesFromFile(file, TAPE_CHUNK_HEAD_UNUSED); @@ -7723,20 +7747,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->use_key_actions) { for (j = 0; j < MAX_PLAYERS; j++) { @@ -7747,6 +7763,13 @@ static int LoadTape_BODY(File *file, int chunk_size, struct TapeInfo *tape) } } + if (tape->use_mouse_actions) + { + 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) @@ -8070,7 +8093,7 @@ static void SaveTape_HEAD(FILE *file, struct TapeInfo *tape) putFile8Bit(file, store_participating_players); - putFile8Bit(file, (tape->use_mouse ? 1 : 0)); + putFile8Bit(file, getTapeActionValue(tape)); // unused bytes not at the end here for 4-byte alignment of engine_version WriteUnusedBytesToFile(file, TAPE_CHUNK_HEAD_UNUSED); @@ -8097,19 +8120,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->use_key_actions) { for (j = 0; j < MAX_PLAYERS; j++) if (tape->player_participates[j]) putFile8Bit(file, tape->pos[i].action[j]); } + if (tape->use_mouse_actions) + { + 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); } } @@ -8483,6 +8507,10 @@ static struct TokenInfo global_setup_tokens[] = TYPE_SWITCH, &setup.prefer_aga_graphics, "prefer_aga_graphics" }, + { + TYPE_SWITCH, + &setup.prefer_lowpass_sounds, "prefer_lowpass_sounds" + }, { TYPE_SWITCH, &setup.game_speed_extended, "game_speed_extended" @@ -9154,6 +9182,7 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->quick_switch = FALSE; si->input_on_focus = FALSE; si->prefer_aga_graphics = TRUE; + si->prefer_lowpass_sounds = FALSE; si->game_speed_extended = FALSE; si->game_frame_delay = GAME_FRAME_DELAY; si->sp_show_border_elements = FALSE;