From: Holger Schemel Date: Sun, 10 Jan 2010 20:34:07 +0000 (+0100) Subject: rnd-20100110-1-src X-Git-Tag: 3.3.0.0^2~48 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=7fbc29937c69f42e609080ddd29595e01750ec4c;p=rocksndiamonds.git rnd-20100110-1-src * added new element "from_level_template" that is replaced by element 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") --- diff --git a/ChangeLog b/ChangeLog index 17c8df15..5eb677f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-01-10 + * added new element "from_level_template" that is replaced by element + 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") + 2010-01-07 * added handling of gravity ports when converting Supaplex style R'n'D levels to native Supaplex levels for playing with Supaplex engine diff --git a/src/conftime.h b/src/conftime.h index 587a3c61..973143a8 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-01-07 17:02" +#define COMPILE_DATE_STRING "2010-01-10 21:27" diff --git a/src/editor.c b/src/editor.c index a75d1285..73971344 100644 --- a/src/editor.c +++ b/src/editor.c @@ -10792,12 +10792,21 @@ static void HandleTextbuttonGadgets(struct GadgetInfo *gi) char *template_filename = getDefaultLevelFilename(-1); boolean new_template = !fileExists(template_filename); + /* backup original "level.field" (needed to track playfield changes) */ + CopyPlayfield(level.field, FieldBackup); + + /* "SaveLevelTemplate()" uses "level.field", so copy editor playfield */ + CopyPlayfield(Feld, level.field); + if (new_template || Request("Save this template and kill the old ?", REQ_ASK)) SaveLevelTemplate(); if (new_template) Request("Template saved !", REQ_CONFIRM); + + /* restore original "level.field" (needed to track playfield changes) */ + CopyPlayfield(FieldBackup, level.field); } else if (type_id == ED_TEXTBUTTON_ID_ADD_CHANGE_PAGE && custom_element.num_change_pages < MAX_CHANGE_PAGES) diff --git a/src/files.c b/src/files.c index a969861e..317266f8 100644 --- a/src/files.c +++ b/src/files.c @@ -1752,9 +1752,26 @@ 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 0 + printf("::: found EL_FROM_LEVEL_TEMPLATE at %d, %d\n", x, y); +#endif + } } static char *getLevelFilenameFromBasename(char *basename) @@ -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 }, }; diff --git a/src/main.c b/src/main.c index f1ea104e..d3ecc942 100644 --- a/src/main.c +++ b/src/main.c @@ -4460,6 +4460,11 @@ struct ElementNameInfo element_name_info[MAX_NUM_ELEMENTS + 1] = "quicksand", "fast quicksand (with rock)" }, + { + "from_level_template", + "from_level_template", + "element taken from level template" + }, /* ----------------------------------------------------------------------- */ /* "real" (and therefore drawable) runtime elements */ diff --git a/src/main.h b/src/main.h index e826e6d8..7b345be7 100644 --- a/src/main.h +++ b/src/main.h @@ -1518,7 +1518,9 @@ #define EL_QUICKSAND_FAST_EMPTY 861 #define EL_QUICKSAND_FAST_FULL 862 -#define NUM_FILE_ELEMENTS 863 +#define EL_FROM_LEVEL_TEMPLATE 863 + +#define NUM_FILE_ELEMENTS 864 /* "real" (and therefore drawable) runtime elements */