X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ffiles.c;h=2ca9976684473f08bf0f9cbf1fe4954e79b0b1c5;hb=5ac5eb15bb34f4c10a7146f05eae315d2b7cc12f;hp=fa807e8f323dd0161959467fb6553ca5a703da52;hpb=90cd4dc88df3f891ecaa0ee9b9010fe432154503;p=rocksndiamonds.git diff --git a/src/files.c b/src/files.c index fa807e8f..2ca99766 100644 --- a/src/files.c +++ b/src/files.c @@ -1733,9 +1733,6 @@ static void setLevelInfoToDefaults_Level(struct LevelInfo *level) // set all bug compatibility flags to "false" => do not emulate this bug level->use_action_after_change_bug = FALSE; - // other flags that may be set due to certain level properties - level->has_mouse_events = FALSE; - if (leveldir_current) { // try to determine better author name than 'anonymous' @@ -3989,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; @@ -6564,18 +6561,6 @@ static void LoadLevel_InitCustomElements(struct LevelInfo *level) element_info[element].ignition_delay = 8; } } - - // check for custom elements which have mouse click events defined - for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++) - { - int element = EL_CUSTOM_START + i; - - if (HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) || - HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) || - HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) || - HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X)) - level->has_mouse_events = TRUE; - } } static void LoadLevel_InitElements(struct LevelInfo *level) @@ -7634,6 +7619,20 @@ static void setTapeInfoToDefaults(void) tape.no_valid_file = FALSE; } +static int getTapePosSize(struct TapeInfo *tape) +{ + int tape_pos_size = 0; + + if (!tape->use_mouse) + tape_pos_size += tape->num_participating_players; + else + 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 LoadTape_VERS(File *file, int chunk_size, struct TapeInfo *tape) { tape->file_version = getFileVersion(file); @@ -7706,8 +7705,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) @@ -7725,7 +7723,7 @@ 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; } @@ -8120,7 +8118,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; @@ -8137,12 +8134,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;