X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ffiles.c;h=ab949e18883acad59ac2db75d7f8d8e2e0665952;hb=e3ef41011a3564492d12988716af8fc1f090ac6b;hp=a969861edebc5eca093742203a1ef693fedf7e52;hpb=2919379746c92fd488b83c61b328ef17fe500985;p=rocksndiamonds.git diff --git a/src/files.c b/src/files.c index a969861e..ab949e18 100644 --- a/src/files.c +++ b/src/files.c @@ -1314,6 +1314,22 @@ filetype_id_list[] = /* level file functions */ /* ========================================================================= */ +static boolean check_special_flags(char *flag) +{ +#if 0 + printf("::: '%s', '%s', '%s'\n", + flag, + options.special_flags, + leveldir_current->special_flags); +#endif + + if (strEqual(options.special_flags, flag) || + strEqual(leveldir_current->special_flags, flag)) + return TRUE; + + return FALSE; +} + static struct DateInfo getCurrentDate() { time_t epoch_seconds = time(NULL); @@ -1752,9 +1768,44 @@ static void setFileInfoToDefaults(struct LevelFileInfo *level_file_info) static void ActivateLevelTemplate() { + int x, y; + /* Currently there is no special action needed to activate the template data, because 'element_info' property settings overwrite the original level data, while all other variables do not change. */ + + /* Exception: 'from_level_template' elements in the original level playfield + are overwritten with the corresponding elements at the same position in + playfield from the level template. */ + + for (x = 0; x < level.fieldx; x++) + for (y = 0; y < level.fieldy; y++) + if (level.field[x][y] == EL_FROM_LEVEL_TEMPLATE) + level.field[x][y] = level_template.field[x][y]; + + if (check_special_flags("load_xsb_to_ces")) + { + struct LevelInfo level_backup = level; + + /* overwrite all individual level settings from template level settings */ + level = level_template; + + /* restore playfield size */ + level.fieldx = level_backup.fieldx; + level.fieldy = level_backup.fieldy; + + /* restore playfield content */ + for (x = 0; x < level.fieldx; x++) + for (y = 0; y < level.fieldy; y++) + level.field[x][y] = level_backup.field[x][y]; + + /* restore name and author from individual level */ + strcpy(level.name, level_backup.name); + strcpy(level.author, level_backup.author); + + /* restore flag "use_custom_template" */ + level.use_custom_template = level_backup.use_custom_template; + } } static char *getLevelFilenameFromBasename(char *basename) @@ -6419,40 +6470,6 @@ static void LoadLevelFromFileInfo_DC(struct LevelInfo *level, /* functions for loading SB level */ /* ------------------------------------------------------------------------- */ -#if 1 - -static boolean check_special_flags(char *flag) -{ -#if 0 - printf("::: '%s', '%s', '%s'\n", - flag, - options.special_flags, - leveldir_current->special_flags); -#endif - - if (strEqual(options.special_flags, flag) || - strEqual(leveldir_current->special_flags, flag)) - return TRUE; - - return FALSE; -} - -#else - -#define SPECIAL_FLAG_LOAD_XSB_TO_CES (1 << 0) - -static unsigned long get_special_flags(char *flags_string) -{ - unsigned long flags_value = 0; - - if (strEqual(flags_string, "load_xsb_to_ces")) - flags_value = SPECIAL_FLAG_LOAD_XSB_TO_CES; - - return flags_value; -} - -#endif - int getMappedElement_SB(int element_ascii, boolean use_ces) { static struct @@ -6470,7 +6487,11 @@ int getMappedElement_SB(int element_ascii, boolean use_ces) { '.', EL_SOKOBAN_FIELD_EMPTY, EL_CUSTOM_5 }, /* goal square */ { '*', EL_SOKOBAN_FIELD_FULL, EL_CUSTOM_6 }, /* box on goal square */ { '+', EL_SOKOBAN_FIELD_PLAYER, EL_CUSTOM_7 }, /* player on goal square */ +#if 0 { '_', EL_INVISIBLE_STEELWALL, EL_CUSTOM_8 }, /* floor beyond border */ +#else + { '_', EL_INVISIBLE_STEELWALL, EL_FROM_LEVEL_TEMPLATE }, /* floor beyond border */ +#endif { 0, -1, -1 }, }; @@ -6498,11 +6519,7 @@ static void LoadLevelFromFileInfo_SB(struct LevelInfo *level, boolean reading_playfield = FALSE; boolean got_valid_playfield_line = FALSE; boolean invalid_playfield_char = FALSE; -#if 1 boolean load_xsb_to_ces = check_special_flags("load_xsb_to_ces"); -#else - boolean load_xsb_to_ces = options.special_flags & SPECIAL_FLAG_LOAD_XSB_TO_CES; -#endif int file_level_nr = 0; int line_nr = 0; int x, y; @@ -6754,7 +6771,11 @@ static void LoadLevelFromFileInfo_SB(struct LevelInfo *level, if (load_xsb_to_ces) { +#if 1 + /* !!! special global settings can now be set in level template !!! */ +#else level->initial_player_stepsize[0] = STEPSIZE_SLOW; +#endif /* fill smaller playfields with padding "beyond border wall" elements */ if (level->fieldx < SCR_FIELDX ||