From: Holger Schemel Date: Sun, 10 Jan 2010 23:22:24 +0000 (+0100) Subject: rnd-20100111-1-src X-Git-Tag: 3.3.0.0^2~47 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=0e9667dbd99ad85fd554c571a9b0e63d7c552551;p=rocksndiamonds.git rnd-20100111-1-src * added special behaviour for "special_flags: load_xsb_to_ces": global settings of individual level files are overwritten by template level --- diff --git a/ChangeLog b/ChangeLog index 5eb677f1..0ba17267 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,8 @@ from level template at same playfield position when loaded (currently not accessible from level editor, but only used for special Sokoban level conversion when using "special_flags: load_xsb_to_ces") + * added special behaviour for "special_flags: load_xsb_to_ces": global + settings of individual level files are overwritten by template level 2010-01-07 * added handling of gravity ports when converting Supaplex style R'n'D diff --git a/src/conftime.h b/src/conftime.h index 973143a8..77c9dec9 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-01-10 21:27" +#define COMPILE_DATE_STRING "2010-01-11 00:22" diff --git a/src/files.c b/src/files.c index 317266f8..792d2cdd 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); @@ -1765,13 +1781,25 @@ static void ActivateLevelTemplate() 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 0 - printf("::: found EL_FROM_LEVEL_TEMPLATE at %d, %d\n", x, y); -#endif - } + if (check_special_flags("load_xsb_to_ces")) + { + short FieldBackup[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; + + /* backup playfield from individual level */ + for (x = 0; x < level.fieldx; x++) + for (y = 0; y < level.fieldy; y++) + FieldBackup[x][y] = level.field[x][y]; + + /* set all individual level settings to template level settings */ + level = level_template; + + /* restore playfield from individual level */ + for (x = 0; x < level.fieldx; x++) + for (y = 0; y < level.fieldy; y++) + level.field[x][y] = FieldBackup[x][y]; + } } static char *getLevelFilenameFromBasename(char *basename) @@ -6436,40 +6464,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 @@ -6519,11 +6513,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; @@ -6775,7 +6765,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 ||