X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Ffiles.c;h=a07ee8af5458f10b60cfe66d431ac2372be1e4a1;hp=2ba8e9e6126e867d8f5c7edc6b92479707e1711f;hb=5c6c42f1;hpb=d01e22a131aef25baab99c9478faf9e94531c4fd diff --git a/src/files.c b/src/files.c index 2ba8e9e6..a07ee8af 100644 --- a/src/files.c +++ b/src/files.c @@ -57,7 +57,7 @@ #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) @@ -839,9 +839,29 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] = }, { - EL_MM_FUSE, -1, + EL_MM_FUSE_ACTIVE, -1, TYPE_INTEGER, CONF_VALUE_16_BIT(1), - &li.mm_time_fuse, 0 + &li.mm_time_fuse, 25 + }, + { + EL_MM_BOMB, -1, + TYPE_INTEGER, CONF_VALUE_16_BIT(1), + &li.mm_time_bomb, 75 + }, + { + EL_MM_GRAY_BALL, -1, + TYPE_INTEGER, CONF_VALUE_16_BIT(1), + &li.mm_time_ball, 75 + }, + { + EL_MM_STEEL_BLOCK, -1, + TYPE_INTEGER, CONF_VALUE_16_BIT(1), + &li.mm_time_block, 75 + }, + { + EL_MM_LIGHTBALL, -1, + TYPE_INTEGER, CONF_VALUE_16_BIT(1), + &li.score[SC_ELEM_BONUS], 10 }, /* ---------- unused values ----------------------------------------------- */ @@ -849,11 +869,6 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] = { EL_UNKNOWN, SAVE_CONF_NEVER, TYPE_INTEGER, CONF_VALUE_16_BIT(1), - &li.score[SC_UNKNOWN_14], 10 - }, - { - EL_UNKNOWN, SAVE_CONF_NEVER, - TYPE_INTEGER, CONF_VALUE_16_BIT(2), &li.score[SC_UNKNOWN_15], 10 }, @@ -3976,10 +3991,6 @@ void CopyNativeLevel_RND_to_MM(struct LevelInfo *level) struct LevelInfo_MM *level_mm = level->native_mm_level; int x, y; - level_mm->file_version = level->file_version; - level_mm->game_version = level->game_version; - level_mm->encoding_16bit_field = level->encoding_16bit_field; - level_mm->fieldx = MIN(level->fieldx, MM_MAX_PLAYFIELD_WIDTH); level_mm->fieldy = MIN(level->fieldy, MM_MAX_PLAYFIELD_HEIGHT); @@ -3994,12 +4005,17 @@ void CopyNativeLevel_RND_to_MM(struct LevelInfo *level) strcpy(level_mm->name, level->name); strcpy(level_mm->author, level->author); + level_mm->score[SC_EMERALD] = level->score[SC_EMERALD]; level_mm->score[SC_PACMAN] = level->score[SC_PACMAN]; - level_mm->score[SC_KEY] = level->score[SC_PACMAN]; + level_mm->score[SC_KEY] = level->score[SC_KEY]; level_mm->score[SC_TIME_BONUS] = level->score[SC_TIME_BONUS]; + level_mm->score[SC_ELEM_BONUS] = level->score[SC_ELEM_BONUS]; level_mm->amoeba_speed = level->amoeba_speed; - level_mm->time_fuse = level->mm_time_fuse; + level_mm->time_fuse = level->mm_time_fuse; + level_mm->time_bomb = level->mm_time_bomb; + level_mm->time_ball = level->mm_time_ball; + level_mm->time_block = level->mm_time_block; for (x = 0; x < level->fieldx; x++) for (y = 0; y < level->fieldy; y++) @@ -4012,10 +4028,6 @@ void CopyNativeLevel_MM_to_RND(struct LevelInfo *level) struct LevelInfo_MM *level_mm = level->native_mm_level; int x, y; - level->file_version = level_mm->file_version; - level->game_version = level_mm->game_version; - level->encoding_16bit_field = level_mm->encoding_16bit_field; - level->fieldx = MIN(level_mm->fieldx, MAX_LEV_FIELDX); level->fieldy = MIN(level_mm->fieldy, MAX_LEV_FIELDY); @@ -4033,12 +4045,17 @@ void CopyNativeLevel_MM_to_RND(struct LevelInfo *level) if (!strEqual(level_mm->author, ANONYMOUS_NAME)) strcpy(level->author, level_mm->author); + level->score[SC_EMERALD] = level_mm->score[SC_EMERALD]; level->score[SC_PACMAN] = level_mm->score[SC_PACMAN]; - level->score[SC_KEY] = level_mm->score[SC_PACMAN]; + level->score[SC_KEY] = level_mm->score[SC_KEY]; level->score[SC_TIME_BONUS] = level_mm->score[SC_TIME_BONUS]; + level->score[SC_ELEM_BONUS] = level_mm->score[SC_ELEM_BONUS]; - level->amoeba_speed = level_mm->amoeba_speed; - level->mm_time_fuse = level_mm->time_fuse; + level->amoeba_speed = level_mm->amoeba_speed; + level->mm_time_fuse = level_mm->time_fuse; + level->mm_time_bomb = level_mm->time_bomb; + level->mm_time_ball = level_mm->time_ball; + level->mm_time_block = level_mm->time_block; for (x = 0; x < level->fieldx; x++) for (y = 0; y < level->fieldy; y++) @@ -7564,6 +7581,8 @@ static int LoadTape_HEAD(File *file, int chunk_size, struct TapeInfo *tape) } } + tape->use_mouse = (getFile8Bit(file) == 1 ? TRUE : FALSE); + ReadUnusedBytesFromFile(file, TAPE_CHUNK_HEAD_UNUSED); engine_version = getFileVersion(file); @@ -7599,8 +7618,9 @@ 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 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) { @@ -7622,12 +7642,23 @@ static int LoadTape_BODY(File *file, int chunk_size, struct TapeInfo *tape) 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); @@ -7684,7 +7715,7 @@ static int LoadTape_BODY(File *file, int chunk_size, struct TapeInfo *tape) } if (i != tape->length) - chunk_size = (tape->num_participating_players + 1) * i; + chunk_size = tape_pos_size * i; return chunk_size; } @@ -7953,6 +7984,8 @@ static void SaveTape_HEAD(FILE *file, struct TapeInfo *tape) 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); @@ -7978,9 +8011,18 @@ static void SaveTape_BODY(FILE *file, struct TapeInfo *tape) 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); } @@ -7991,6 +8033,7 @@ 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; int i; @@ -8011,8 +8054,10 @@ void SaveTape(int nr) 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); @@ -8251,6 +8296,11 @@ void SaveScore(int nr) #define NUM_GLOBAL_SETUP_TOKENS 44 +/* auto setup */ +#define SETUP_TOKEN_AUTO_EDITOR_ZOOM_TILESIZE 0 + +#define NUM_AUTO_SETUP_TOKENS 1 + /* editor setup */ #define SETUP_TOKEN_EDITOR_EL_CLASSIC 0 #define SETUP_TOKEN_EDITOR_EL_CUSTOM 1 @@ -8389,6 +8439,7 @@ void SaveScore(int nr) static struct SetupInfo si; +static struct SetupAutoSetupInfo sasi; static struct SetupEditorInfo sei; static struct SetupEditorCascadeInfo seci; static struct SetupShortcutInfo ssi; @@ -8446,6 +8497,11 @@ static struct TokenInfo global_setup_tokens[] = { TYPE_INTEGER,&si.touch.drop_distance, "touch.drop_distance" }, }; +static struct TokenInfo auto_setup_tokens[] = +{ + { TYPE_INTEGER,&sasi.editor_zoom_tilesize, "editor.zoom_tilesize" }, +}; + static struct TokenInfo editor_setup_tokens[] = { { TYPE_SWITCH, &sei.el_classic, "editor.el_classic" }, @@ -8789,6 +8845,11 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) #endif } +static void setSetupInfoToDefaults_AutoSetup(struct SetupInfo *si) +{ + si->auto_setup.editor_zoom_tilesize = MINI_TILESIZE; +} + static void setSetupInfoToDefaults_EditorCascade(struct SetupInfo *si) { si->editor_cascade.el_bd = TRUE; @@ -8938,6 +8999,22 @@ static void decodeSetupFileHash(SetupFileHash *setup_file_hash) setup.options = soi; } +static void decodeSetupFileHash_AutoSetup(SetupFileHash *setup_file_hash) +{ + int i; + + if (!setup_file_hash) + return; + + /* auto setup */ + sasi = setup.auto_setup; + for (i = 0; i < NUM_AUTO_SETUP_TOKENS; i++) + setSetupInfo(auto_setup_tokens, i, + getHashEntry(setup_file_hash, + auto_setup_tokens[i].text)); + setup.auto_setup = sasi; +} + static void decodeSetupFileHash_EditorCascade(SetupFileHash *setup_file_hash) { int i; @@ -9012,6 +9089,26 @@ void LoadSetup() LoadSetup_SpecialPostProcessing(); } +void LoadSetup_AutoSetup() +{ + char *filename = getPath2(getSetupDir(), AUTOSETUP_FILENAME); + SetupFileHash *setup_file_hash = NULL; + + /* always start with reliable default values */ + setSetupInfoToDefaults_AutoSetup(&setup); + + setup_file_hash = loadSetupFileHash(filename); + + if (setup_file_hash) + { + decodeSetupFileHash_AutoSetup(setup_file_hash); + + freeSetupFileHash(setup_file_hash); + } + + free(filename); +} + void LoadSetup_EditorCascade() { char *filename = getPath2(getSetupDir(), EDITORCASCADE_FILENAME); @@ -9162,6 +9259,34 @@ void SaveSetup() SetFilePermissions(filename, PERMS_PRIVATE); } +void SaveSetup_AutoSetup() +{ + char *filename = getPath2(getSetupDir(), AUTOSETUP_FILENAME); + FILE *file; + int i; + + InitUserDataDirectory(); + + if (!(file = fopen(filename, MODE_WRITE))) + { + Error(ERR_WARN, "cannot write auto setup file '%s'", filename); + free(filename); + return; + } + + fprintFileHeader(file, AUTOSETUP_FILENAME); + + sasi = setup.auto_setup; + for (i = 0; i < NUM_AUTO_SETUP_TOKENS; i++) + fprintf(file, "%s\n", getSetupLine(auto_setup_tokens, "", i)); + + fclose(file); + + SetFilePermissions(filename, PERMS_PRIVATE); + + free(filename); +} + void SaveSetup_EditorCascade() { char *filename = getPath2(getSetupDir(), EDITORCASCADE_FILENAME); @@ -9623,6 +9748,28 @@ static void LoadMenuDesignSettingsFromFilename(char *filename) menu.draw_yoffset_setup[i] = get_integer_from_string(value_2); } + /* special case: initialize with default values that may be overwritten */ + /* (eg, init "menu.line_spacing.INFO[XXX]" from "menu.line_spacing.INFO") */ + for (i = 0; i < NUM_SPECIAL_GFX_INFO_ARGS; i++) + { + char *value_1 = getHashEntry(setup_file_hash,"menu.paragraph_spacing.INFO"); + char *value_2 = getHashEntry(setup_file_hash,"menu.headline1_spacing.INFO"); + char *value_3 = getHashEntry(setup_file_hash,"menu.headline2_spacing.INFO"); + char *value_4 = getHashEntry(setup_file_hash,"menu.line_spacing.INFO"); + char *value_5 = getHashEntry(setup_file_hash,"menu.extra_spacing.INFO"); + + if (value_1 != NULL) + menu.paragraph_spacing_info[i] = get_integer_from_string(value_1); + if (value_2 != NULL) + menu.headline1_spacing_info[i] = get_integer_from_string(value_2); + if (value_3 != NULL) + menu.headline2_spacing_info[i] = get_integer_from_string(value_3); + if (value_4 != NULL) + menu.line_spacing_info[i] = get_integer_from_string(value_4); + if (value_5 != NULL) + menu.extra_spacing_info[i] = get_integer_from_string(value_5); + } + /* special case: initialize with default values that may be overwritten */ /* (eg, init "menu.enter_screen.SCORES.xyz" from "menu.enter_screen.xyz") */ for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++)