From: Holger Schemel Date: Wed, 9 Apr 2003 21:46:55 +0000 (+0200) Subject: rnd-20030409-1-src X-Git-Tag: 3.0.0^2~106 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=514321a85f7dda02848a3ce78667329f9c891156;p=rocksndiamonds.git rnd-20030409-1-src --- diff --git a/src/conftime.h b/src/conftime.h index 2d881d35..b2cc184e 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-04-07 23:42]" +#define COMPILE_DATE_STRING "[2003-04-09 23:02]" diff --git a/src/editor.c b/src/editor.c index 5d931bd1..1951d1f4 100644 --- a/src/editor.c +++ b/src/editor.c @@ -108,6 +108,9 @@ #define ED_AREA_ELEM_CONTENT_XPOS ( 2 * MINI_TILEX) #define ED_AREA_ELEM_CONTENT_YPOS (22 * MINI_TILEY) +#define ED_AREA_ELEM_CONTENT2_XPOS ( 2 * MINI_TILEX) +#define ED_AREA_ELEM_CONTENT2_YPOS (28 * MINI_TILEY) + /* values for random placement background drawing area */ #define ED_AREA_RANDOM_BACKGROUND_XPOS (29 * MINI_TILEX) #define ED_AREA_RANDOM_BACKGROUND_YPOS (31 * MINI_TILEY) @@ -210,107 +213,124 @@ /* drawing toolbox buttons */ #define GADGET_ID_NONE -1 -#define GADGET_ID_SINGLE_ITEMS 0 -#define GADGET_ID_CONNECTED_ITEMS 1 -#define GADGET_ID_LINE 2 -#define GADGET_ID_ARC 3 -#define GADGET_ID_RECTANGLE 4 -#define GADGET_ID_FILLED_BOX 5 -#define GADGET_ID_WRAP_UP 6 -#define GADGET_ID_TEXT 7 -#define GADGET_ID_FLOOD_FILL 8 -#define GADGET_ID_WRAP_LEFT 9 -#define GADGET_ID_PROPERTIES 10 -#define GADGET_ID_WRAP_RIGHT 11 -#define GADGET_ID_RANDOM_PLACEMENT 12 -#define GADGET_ID_GRAB_BRUSH 13 -#define GADGET_ID_WRAP_DOWN 14 -#define GADGET_ID_PICK_ELEMENT 15 -#define GADGET_ID_UNDO 16 -#define GADGET_ID_INFO 17 -#define GADGET_ID_SAVE 18 -#define GADGET_ID_CLEAR 19 -#define GADGET_ID_TEST 20 -#define GADGET_ID_EXIT 21 +#define GADGET_ID_TOOLBOX_FIRST 0 + +#define GADGET_ID_SINGLE_ITEMS (GADGET_ID_TOOLBOX_FIRST + 0) +#define GADGET_ID_CONNECTED_ITEMS (GADGET_ID_TOOLBOX_FIRST + 1) +#define GADGET_ID_LINE (GADGET_ID_TOOLBOX_FIRST + 2) +#define GADGET_ID_ARC (GADGET_ID_TOOLBOX_FIRST + 3) +#define GADGET_ID_RECTANGLE (GADGET_ID_TOOLBOX_FIRST + 4) +#define GADGET_ID_FILLED_BOX (GADGET_ID_TOOLBOX_FIRST + 5) +#define GADGET_ID_WRAP_UP (GADGET_ID_TOOLBOX_FIRST + 6) +#define GADGET_ID_TEXT (GADGET_ID_TOOLBOX_FIRST + 7) +#define GADGET_ID_FLOOD_FILL (GADGET_ID_TOOLBOX_FIRST + 8) +#define GADGET_ID_WRAP_LEFT (GADGET_ID_TOOLBOX_FIRST + 9) +#define GADGET_ID_PROPERTIES (GADGET_ID_TOOLBOX_FIRST + 10) +#define GADGET_ID_WRAP_RIGHT (GADGET_ID_TOOLBOX_FIRST + 11) +#define GADGET_ID_RANDOM_PLACEMENT (GADGET_ID_TOOLBOX_FIRST + 12) +#define GADGET_ID_GRAB_BRUSH (GADGET_ID_TOOLBOX_FIRST + 13) +#define GADGET_ID_WRAP_DOWN (GADGET_ID_TOOLBOX_FIRST + 14) +#define GADGET_ID_PICK_ELEMENT (GADGET_ID_TOOLBOX_FIRST + 15) +#define GADGET_ID_UNDO (GADGET_ID_TOOLBOX_FIRST + 16) +#define GADGET_ID_INFO (GADGET_ID_TOOLBOX_FIRST + 17) +#define GADGET_ID_SAVE (GADGET_ID_TOOLBOX_FIRST + 18) +#define GADGET_ID_CLEAR (GADGET_ID_TOOLBOX_FIRST + 19) +#define GADGET_ID_TEST (GADGET_ID_TOOLBOX_FIRST + 20) +#define GADGET_ID_EXIT (GADGET_ID_TOOLBOX_FIRST + 21) /* counter button identifiers */ -#define GADGET_ID_ELEM_SCORE_DOWN 22 -#define GADGET_ID_ELEM_SCORE_TEXT 23 -#define GADGET_ID_ELEM_SCORE_UP 24 -#define GADGET_ID_ELEM_CONTENT_DOWN 25 -#define GADGET_ID_ELEM_CONTENT_TEXT 26 -#define GADGET_ID_ELEM_CONTENT_UP 27 -#define GADGET_ID_LEVEL_XSIZE_DOWN 28 -#define GADGET_ID_LEVEL_XSIZE_TEXT 29 -#define GADGET_ID_LEVEL_XSIZE_UP 30 -#define GADGET_ID_LEVEL_YSIZE_DOWN 31 -#define GADGET_ID_LEVEL_YSIZE_TEXT 32 -#define GADGET_ID_LEVEL_YSIZE_UP 33 -#define GADGET_ID_LEVEL_RANDOM_DOWN 34 -#define GADGET_ID_LEVEL_RANDOM_TEXT 35 -#define GADGET_ID_LEVEL_RANDOM_UP 36 -#define GADGET_ID_LEVEL_COLLECT_DOWN 37 -#define GADGET_ID_LEVEL_COLLECT_TEXT 38 -#define GADGET_ID_LEVEL_COLLECT_UP 39 -#define GADGET_ID_LEVEL_TIMELIMIT_DOWN 40 -#define GADGET_ID_LEVEL_TIMELIMIT_TEXT 41 -#define GADGET_ID_LEVEL_TIMELIMIT_UP 42 -#define GADGET_ID_LEVEL_TIMESCORE_DOWN 43 -#define GADGET_ID_LEVEL_TIMESCORE_TEXT 44 -#define GADGET_ID_LEVEL_TIMESCORE_UP 45 -#define GADGET_ID_SELECT_LEVEL_DOWN 46 -#define GADGET_ID_SELECT_LEVEL_TEXT 47 -#define GADGET_ID_SELECT_LEVEL_UP 48 +#define GADGET_ID_COUNTER_FIRST (GADGET_ID_TOOLBOX_FIRST + 22) + +#define GADGET_ID_ELEM_SCORE_DOWN (GADGET_ID_COUNTER_FIRST + 0) +#define GADGET_ID_ELEM_SCORE_TEXT (GADGET_ID_COUNTER_FIRST + 1) +#define GADGET_ID_ELEM_SCORE_UP (GADGET_ID_COUNTER_FIRST + 2) +#define GADGET_ID_ELEM_CONTENT_DOWN (GADGET_ID_COUNTER_FIRST + 3) +#define GADGET_ID_ELEM_CONTENT_TEXT (GADGET_ID_COUNTER_FIRST + 4) +#define GADGET_ID_ELEM_CONTENT_UP (GADGET_ID_COUNTER_FIRST + 5) +#define GADGET_ID_LEVEL_XSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 6) +#define GADGET_ID_LEVEL_XSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 7) +#define GADGET_ID_LEVEL_XSIZE_UP (GADGET_ID_COUNTER_FIRST + 8) +#define GADGET_ID_LEVEL_YSIZE_DOWN (GADGET_ID_COUNTER_FIRST + 9) +#define GADGET_ID_LEVEL_YSIZE_TEXT (GADGET_ID_COUNTER_FIRST + 10) +#define GADGET_ID_LEVEL_YSIZE_UP (GADGET_ID_COUNTER_FIRST + 11) +#define GADGET_ID_LEVEL_RANDOM_DOWN (GADGET_ID_COUNTER_FIRST + 12) +#define GADGET_ID_LEVEL_RANDOM_TEXT (GADGET_ID_COUNTER_FIRST + 13) +#define GADGET_ID_LEVEL_RANDOM_UP (GADGET_ID_COUNTER_FIRST + 14) +#define GADGET_ID_LEVEL_COLLECT_DOWN (GADGET_ID_COUNTER_FIRST + 15) +#define GADGET_ID_LEVEL_COLLECT_TEXT (GADGET_ID_COUNTER_FIRST + 16) +#define GADGET_ID_LEVEL_COLLECT_UP (GADGET_ID_COUNTER_FIRST + 17) +#define GADGET_ID_LEVEL_TIMELIMIT_DOWN (GADGET_ID_COUNTER_FIRST + 18) +#define GADGET_ID_LEVEL_TIMELIMIT_TEXT (GADGET_ID_COUNTER_FIRST + 19) +#define GADGET_ID_LEVEL_TIMELIMIT_UP (GADGET_ID_COUNTER_FIRST + 20) +#define GADGET_ID_LEVEL_TIMESCORE_DOWN (GADGET_ID_COUNTER_FIRST + 21) +#define GADGET_ID_LEVEL_TIMESCORE_TEXT (GADGET_ID_COUNTER_FIRST + 22) +#define GADGET_ID_LEVEL_TIMESCORE_UP (GADGET_ID_COUNTER_FIRST + 23) +#define GADGET_ID_SELECT_LEVEL_DOWN (GADGET_ID_COUNTER_FIRST + 24) +#define GADGET_ID_SELECT_LEVEL_TEXT (GADGET_ID_COUNTER_FIRST + 25) +#define GADGET_ID_SELECT_LEVEL_UP (GADGET_ID_COUNTER_FIRST + 26) /* drawing area identifiers */ -#define GADGET_ID_DRAWING_LEVEL 49 -#define GADGET_ID_ELEM_CONTENT_0 50 -#define GADGET_ID_ELEM_CONTENT_1 51 -#define GADGET_ID_ELEM_CONTENT_2 52 -#define GADGET_ID_ELEM_CONTENT_3 53 -#define GADGET_ID_ELEM_CONTENT_4 54 -#define GADGET_ID_ELEM_CONTENT_5 55 -#define GADGET_ID_ELEM_CONTENT_6 56 -#define GADGET_ID_ELEM_CONTENT_7 57 -#define GADGET_ID_AMOEBA_CONTENT 58 -#define GADGET_ID_RANDOM_BACKGROUND 59 +#define GADGET_ID_DRAWING_AREA_FIRST (GADGET_ID_COUNTER_FIRST + 27) + +#define GADGET_ID_DRAWING_LEVEL (GADGET_ID_DRAWING_AREA_FIRST + 0) +#define GADGET_ID_ELEM_CONTENT_0 (GADGET_ID_DRAWING_AREA_FIRST + 1) +#define GADGET_ID_ELEM_CONTENT_1 (GADGET_ID_DRAWING_AREA_FIRST + 2) +#define GADGET_ID_ELEM_CONTENT_2 (GADGET_ID_DRAWING_AREA_FIRST + 3) +#define GADGET_ID_ELEM_CONTENT_3 (GADGET_ID_DRAWING_AREA_FIRST + 4) +#define GADGET_ID_ELEM_CONTENT_4 (GADGET_ID_DRAWING_AREA_FIRST + 5) +#define GADGET_ID_ELEM_CONTENT_5 (GADGET_ID_DRAWING_AREA_FIRST + 6) +#define GADGET_ID_ELEM_CONTENT_6 (GADGET_ID_DRAWING_AREA_FIRST + 7) +#define GADGET_ID_ELEM_CONTENT_7 (GADGET_ID_DRAWING_AREA_FIRST + 8) +#define GADGET_ID_AMOEBA_CONTENT (GADGET_ID_DRAWING_AREA_FIRST + 9) +#define GADGET_ID_CUSTOM_CHANGED (GADGET_ID_DRAWING_AREA_FIRST + 10) +#define GADGET_ID_RANDOM_BACKGROUND (GADGET_ID_DRAWING_AREA_FIRST + 11) /* text input identifiers */ -#define GADGET_ID_LEVEL_NAME 60 -#define GADGET_ID_LEVEL_AUTHOR 61 +#define GADGET_ID_TEXT_INPUT_FIRST (GADGET_ID_DRAWING_AREA_FIRST + 12) + +#define GADGET_ID_LEVEL_NAME (GADGET_ID_TEXT_INPUT_FIRST + 0) +#define GADGET_ID_LEVEL_AUTHOR (GADGET_ID_TEXT_INPUT_FIRST + 1) /* selectbox identifiers */ -#define GADGET_ID_SELECTBOX_TEST 62 +#define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_INPUT_FIRST + 2) + +#define GADGET_ID_SELECTBOX_TEST (GADGET_ID_SELECTBOX_FIRST + 0) /* gadgets for scrolling of drawing area */ -#define GADGET_ID_SCROLL_UP 63 -#define GADGET_ID_SCROLL_DOWN 64 -#define GADGET_ID_SCROLL_LEFT 65 -#define GADGET_ID_SCROLL_RIGHT 66 -#define GADGET_ID_SCROLL_HORIZONTAL 67 -#define GADGET_ID_SCROLL_VERTICAL 68 +#define GADGET_ID_SCROLLING_FIRST (GADGET_ID_SELECTBOX_FIRST + 1) + +#define GADGET_ID_SCROLL_UP (GADGET_ID_SCROLLING_FIRST + 0) +#define GADGET_ID_SCROLL_DOWN (GADGET_ID_SCROLLING_FIRST + 1) +#define GADGET_ID_SCROLL_LEFT (GADGET_ID_SCROLLING_FIRST + 2) +#define GADGET_ID_SCROLL_RIGHT (GADGET_ID_SCROLLING_FIRST + 3) +#define GADGET_ID_SCROLL_HORIZONTAL (GADGET_ID_SCROLLING_FIRST + 4) +#define GADGET_ID_SCROLL_VERTICAL (GADGET_ID_SCROLLING_FIRST + 5) /* gadgets for scrolling element list */ -#define GADGET_ID_SCROLL_LIST_UP 69 -#define GADGET_ID_SCROLL_LIST_DOWN 70 -#define GADGET_ID_SCROLL_LIST_VERTICAL 71 +#define GADGET_ID_SCROLLING_LIST_FIRST (GADGET_ID_SCROLLING_FIRST + 6) + +#define GADGET_ID_SCROLL_LIST_UP (GADGET_ID_SCROLLING_LIST_FIRST + 0) +#define GADGET_ID_SCROLL_LIST_DOWN (GADGET_ID_SCROLLING_LIST_FIRST + 1) +#define GADGET_ID_SCROLL_LIST_VERTICAL (GADGET_ID_SCROLLING_LIST_FIRST + 2) /* buttons for level/element properties */ -#define GADGET_ID_RANDOM_PERCENTAGE 72 -#define GADGET_ID_RANDOM_QUANTITY 73 -#define GADGET_ID_RANDOM_RESTRICTED 74 -#define GADGET_ID_DOUBLE_SPEED 75 -#define GADGET_ID_GRAVITY 76 -#define GADGET_ID_STICK_ELEMENT 77 -#define GADGET_ID_EM_SLIPPERY_GEMS 78 -#define GADGET_ID_CUSTOM_INDESTRUCTIBLE 79 -#define GADGET_ID_CUSTOM_CAN_FALL 80 -#define GADGET_ID_CUSTOM_CAN_SMASH 81 -#define GADGET_ID_CUSTOM_PUSHABLE 82 -#define GADGET_ID_CUSTOM_SLIPPERY 83 +#define GADGET_ID_CHECKBUTTON_FIRST (GADGET_ID_SCROLLING_LIST_FIRST + 3) + +#define GADGET_ID_RANDOM_PERCENTAGE (GADGET_ID_CHECKBUTTON_FIRST + 0) +#define GADGET_ID_RANDOM_QUANTITY (GADGET_ID_CHECKBUTTON_FIRST + 1) +#define GADGET_ID_RANDOM_RESTRICTED (GADGET_ID_CHECKBUTTON_FIRST + 2) +#define GADGET_ID_DOUBLE_SPEED (GADGET_ID_CHECKBUTTON_FIRST + 3) +#define GADGET_ID_GRAVITY (GADGET_ID_CHECKBUTTON_FIRST + 4) +#define GADGET_ID_STICK_ELEMENT (GADGET_ID_CHECKBUTTON_FIRST + 5) +#define GADGET_ID_EM_SLIPPERY_GEMS (GADGET_ID_CHECKBUTTON_FIRST + 6) +#define GADGET_ID_CUSTOM_INDESTRUCTIBLE (GADGET_ID_CHECKBUTTON_FIRST + 7) +#define GADGET_ID_CUSTOM_CAN_FALL (GADGET_ID_CHECKBUTTON_FIRST + 8) +#define GADGET_ID_CUSTOM_CAN_SMASH (GADGET_ID_CHECKBUTTON_FIRST + 9) +#define GADGET_ID_CUSTOM_PUSHABLE (GADGET_ID_CHECKBUTTON_FIRST + 10) +#define GADGET_ID_CUSTOM_SLIPPERY (GADGET_ID_CHECKBUTTON_FIRST + 11) /* gadgets for buttons in element list */ -#define GADGET_ID_ELEMENTLIST_FIRST 84 +#define GADGET_ID_ELEMENTLIST_FIRST (GADGET_ID_CHECKBUTTON_FIRST + 12) #define GADGET_ID_ELEMENTLIST_LAST (GADGET_ID_ELEMENTLIST_FIRST + \ ED_NUM_ELEMENTLIST_BUTTONS - 1) @@ -2124,7 +2144,7 @@ static void CreateDrawingAreas() level_editor_gadget[id] = gi; } - /* ... one for the amoeba content */ + /* ... one for the amoeba content ... */ id = GADGET_ID_AMOEBA_CONTENT; gi = CreateGadget(GDI_CUSTOM_ID, id, GDI_X, SX + ED_AREA_ELEM_CONTENT_XPOS, @@ -2143,6 +2163,25 @@ static void CreateDrawingAreas() level_editor_gadget[id] = gi; + /* ... one for each custom element change target element ... */ + id = GADGET_ID_CUSTOM_CHANGED; + gi = CreateGadget(GDI_CUSTOM_ID, id, + GDI_X, SX + ED_AREA_ELEM_CONTENT2_XPOS, + GDI_Y, SY + ED_AREA_ELEM_CONTENT2_YPOS, + GDI_WIDTH, MINI_TILEX, + GDI_HEIGHT, MINI_TILEY, + GDI_TYPE, GD_TYPE_DRAWING_AREA, + GDI_ITEM_SIZE, MINI_TILEX, MINI_TILEY, + GDI_EVENT_MASK, event_mask, + GDI_CALLBACK_INFO, HandleDrawingAreaInfo, + GDI_CALLBACK_ACTION, HandleDrawingAreas, + GDI_END); + + if (gi == NULL) + Error(ERR_EXIT, "cannot create gadget"); + + level_editor_gadget[id] = gi; + /* ... and one for random placement background restrictions */ id = GADGET_ID_RANDOM_BACKGROUND; @@ -3050,6 +3089,32 @@ static void DrawAmoebaContentArea() MapDrawingArea(GADGET_ID_AMOEBA_CONTENT); } +static void DrawCustomChangedArea() +{ + int area_x = ED_AREA_ELEM_CONTENT2_XPOS / MINI_TILEX; + int area_y = ED_AREA_ELEM_CONTENT2_YPOS / MINI_TILEY; + int area_sx = SX + ED_AREA_ELEM_CONTENT2_XPOS; + int area_sy = SY + ED_AREA_ELEM_CONTENT2_YPOS; + int i = properties_element - EL_CUSTOM_START; + + if (!IS_CUSTOM_ELEMENT(properties_element)) + { + /* this should never happen */ + Error(ERR_WARN, "element %d is no custom element", properties_element); + + return; + } + + ElementContent[0][0][0] = level.custom_element_successor[i]; + + DrawElementBorder(area_sx, area_sy, MINI_TILEX, MINI_TILEY); + DrawMiniElement(area_x, area_y, ElementContent[0][0][0]); + + DrawText(area_sx + TILEX, area_sy + 1, "Element after change", FONT_TEXT_1); + + MapDrawingArea(GADGET_ID_CUSTOM_CHANGED); +} + static void DrawElementContentAreas() { int counter_id = ED_COUNTER_ID_ELEM_CONTENT; @@ -3250,6 +3315,8 @@ static void DrawPropertiesWindow() else DrawElementContentAreas(); } + else if (IS_CUSTOM_ELEMENT(properties_element)) + DrawCustomChangedArea(); } if (IS_GEM(properties_element)) @@ -4073,6 +4140,13 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) if (id == GADGET_ID_AMOEBA_CONTENT) level.amoeba_content = new_element; + else if (id == GADGET_ID_CUSTOM_CHANGED && + IS_CUSTOM_ELEMENT(properties_element)) + { + int i = properties_element - EL_CUSTOM_START; + + level.custom_element_successor[i] = new_element; + } else if (id == GADGET_ID_RANDOM_BACKGROUND) random_placement_background_element = new_element; else if (id >= GADGET_ID_ELEM_CONTENT_0 && @@ -4859,6 +4933,9 @@ static void HandleDrawingAreaInfo(struct GadgetInfo *gi) else if (id == GADGET_ID_AMOEBA_CONTENT) DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, "Amoeba content"); + else if (id == GADGET_ID_CUSTOM_CHANGED) + DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, + "Next element after change"); else if (id == GADGET_ID_RANDOM_BACKGROUND) DrawTextF(INFOTEXT_XPOS - SX, INFOTEXT_YPOS - SY, FONT_TEXT_2, "Random placement background"); diff --git a/src/files.c b/src/files.c index 588d9404..d13c2871 100644 --- a/src/files.c +++ b/src/files.c @@ -95,7 +95,10 @@ static void setLevelInfoToDefaults() Ur[STD_LEV_FIELDX-1][STD_LEV_FIELDY-1] = EL_EXIT_CLOSED; for (i=0; i < NUM_CUSTOM_ELEMENTS; i++) + { + level.custom_element_successor[i] = EL_EMPTY_SPACE; Properties1[EL_CUSTOM_START + i] = EP_BITMASK_DEFAULT; + } BorderElement = EL_STEELWALL; @@ -342,6 +345,33 @@ static int LoadLevel_CUS1(FILE *file, int chunk_size, struct LevelInfo *level) return chunk_size; } +static int LoadLevel_CUS2(FILE *file, int chunk_size, struct LevelInfo *level) +{ + int num_changed_custom_elements = getFile16BitBE(file); + int chunk_size_expected = 2 + num_changed_custom_elements * 4; + int i; + + if (chunk_size_expected != chunk_size) + { + ReadUnusedBytesFromFile(file, chunk_size - 2); + return chunk_size_expected; + } + + for (i=0; i < num_changed_custom_elements; i++) + { + int element = getFile16BitBE(file); + int custom_element_successor = getFile16BitBE(file); + int i = element - EL_CUSTOM_START; + + if (IS_CUSTOM_ELEMENT(element)) + level->custom_element_successor[i] = custom_element_successor; + else + Error(ERR_WARN, "invalid custom element number %d", element); + } + + return chunk_size; +} + void LoadLevelFromFilename(char *filename) { char cookie[MAX_LINE_LEN]; @@ -421,6 +451,7 @@ void LoadLevelFromFilename(char *filename) { "CONT", -1, LoadLevel_CONT }, { "CNT2", LEVEL_CHUNK_CNT2_SIZE, LoadLevel_CNT2 }, { "CUS1", -1, LoadLevel_CUS1 }, + { "CUS2", -1, LoadLevel_CUS2 }, { NULL, 0, NULL } }; @@ -684,7 +715,8 @@ static void SaveLevel_CNT2(FILE *file, struct LevelInfo *level, int element) putFile16BitBE(file, content_array[i][x][y]); } -static void SaveLevel_CUS1(FILE *file, int num_changed_custom_elements) +static void SaveLevel_CUS1(FILE *file, struct LevelInfo *level, + int num_changed_custom_elements) { int i, check = 0; @@ -710,11 +742,39 @@ static void SaveLevel_CUS1(FILE *file, int num_changed_custom_elements) Error(ERR_WARN, "inconsistent number of custom element properties"); } +static void SaveLevel_CUS2(FILE *file, struct LevelInfo *level, + int num_changed_custom_elements) +{ + int i, check = 0; + + putFile16BitBE(file, num_changed_custom_elements); + + for (i=0; i < NUM_CUSTOM_ELEMENTS; i++) + { + int element = EL_CUSTOM_START + i; + + if (level->custom_element_successor[i] != EL_EMPTY_SPACE) + { + if (check < num_changed_custom_elements) + { + putFile16BitBE(file, element); + putFile16BitBE(file, level->custom_element_successor[i]); + } + + check++; + } + } + + if (check != num_changed_custom_elements) /* should not happen */ + Error(ERR_WARN, "inconsistent number of custom element successors"); +} + void SaveLevel(int level_nr) { char *filename = getLevelFilename(level_nr); int body_chunk_size; - int num_changed_custom_elements = 0; + int num_changed_custom_elements1 = 0; + int num_changed_custom_elements2 = 0; int i, x, y; FILE *file; @@ -754,7 +814,12 @@ void SaveLevel(int level_nr) /* check for non-standard custom elements and calculate "CUS1" chunk size */ for (i=0; i < NUM_CUSTOM_ELEMENTS; i++) if (Properties1[EL_CUSTOM_START + i] != EP_BITMASK_DEFAULT) - num_changed_custom_elements++; + num_changed_custom_elements1++; + + /* check for non-standard custom elements and calculate "CUS2" chunk size */ + for (i=0; i < NUM_CUSTOM_ELEMENTS; i++) + if (level.custom_element_successor[i] != EL_EMPTY_SPACE) + num_changed_custom_elements2++; putFileChunkBE(file, "RND1", CHUNK_SIZE_UNDEFINED); putFileChunkBE(file, "CAVE", CHUNK_SIZE_NONE); @@ -784,10 +849,16 @@ void SaveLevel(int level_nr) SaveLevel_CNT2(file, &level, EL_BD_AMOEBA); } - if (num_changed_custom_elements > 0) + if (num_changed_custom_elements1 > 0) + { + putFileChunkBE(file, "CUS1", 2 + num_changed_custom_elements1 * 6); + SaveLevel_CUS1(file, &level, num_changed_custom_elements1); + } + + if (num_changed_custom_elements2 > 0) { - putFileChunkBE(file, "CUS1", 2 + num_changed_custom_elements * 6); - SaveLevel_CUS1(file, num_changed_custom_elements); + putFileChunkBE(file, "CUS2", 2 + num_changed_custom_elements2 * 4); + SaveLevel_CUS2(file, &level, num_changed_custom_elements2); } fclose(file); diff --git a/src/main.h b/src/main.h index 34e646e5..69d8e51b 100644 --- a/src/main.h +++ b/src/main.h @@ -987,6 +987,8 @@ struct LevelInfo boolean gravity; boolean em_slippery_gems; /* EM style "gems slip from wall" behaviour */ + short custom_element_successor[NUM_CUSTOM_ELEMENTS]; + boolean no_level_file; }; diff --git a/src/screens.c b/src/screens.c index 0737cd79..cb7919fd 100644 --- a/src/screens.c +++ b/src/screens.c @@ -710,9 +710,11 @@ static int helpscreen_action[] = IMG_EXPLOSION, 16, IMG_EMPTY_SPACE, 20, HA_NEXT, - EL_DYNABOMB_INCREASE_NUMBER, -1, HA_NEXT, + IMG_DYNABOMB_INCREASE_NUMBER, -1, HA_NEXT, - EL_DYNABOMB_INCREASE_SIZE, -1, HA_NEXT, + IMG_DYNABOMB_INCREASE_SIZE, -1, HA_NEXT, + + IMG_DYNABOMB_INCREASE_POWER, -1, HA_NEXT, IMG_SPACESHIP_RIGHT, 16, IMG_SPACESHIP_UP, 16, @@ -842,6 +844,7 @@ static char *helpscreen_eltext[][2] = {"Dyna Bomb: Explodes in 4 directions","with variable explosion size"}, {"Dyna Bomb: Increases the number of", "dyna bombs available at a time"}, {"Dyna Bomb: Increases the size of", "explosion of dyna bombs"}, + {"Dyna Bomb: Increases the power of", "explosion of dyna bombs"}, {"Spaceship: Moves at the left side", "of walls; don't touch it!"}, {"Bug: Moves at the right side", "of walls; don't touch it!"}, {"Butterfly: Moves at the right side", "of walls; don't touch it!"},