From: Holger Schemel Date: Sun, 11 Jan 2004 18:22:33 +0000 (+0100) Subject: rnd-20040111-3-src X-Git-Tag: 3.1.0^2~101 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=7892cce9f39489a779f8fad4a3e756b0bb8dbee5;p=rocksndiamonds.git rnd-20040111-3-src --- diff --git a/src/conftime.h b/src/conftime.h index d2c2aa41..79da32aa 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2004-01-11 17:40]" +#define COMPILE_DATE_STRING "[2004-01-11 19:16]" diff --git a/src/editor.c b/src/editor.c index 289967ac..f098b1f5 100644 --- a/src/editor.c +++ b/src/editor.c @@ -806,7 +806,6 @@ static boolean custom_element_change_events[NUM_CHANGE_EVENTS]; static struct ElementChangeInfo custom_element_change; static struct ElementGroupInfo group_element_info; static struct ElementInfo custom_element; -static struct ElementInfo group_element; static struct { @@ -3395,13 +3394,9 @@ static void DrawDrawingArea(int id) DrawMiniGraphicExt(drawto, gi->x, gi->y, el2edimg(custom_element_change.trigger_element)); else if (id == ED_DRAWING_ID_GROUP_CONTENT) - { - int nr = group_element_info.num_elements; - - for (x = 0; x < nr; x++) + for (x = 0; x < group_element_info.num_elements; x++) DrawMiniGraphicExt(drawto, gi->x + x * MINI_TILEX, gi->y, - el2edimg(group_element_info.element[nr])); - } + el2edimg(group_element_info.element[x])); else if (id >= ED_DRAWING_ID_ELEMENT_CONTENT_0 && id <= ED_DRAWING_ID_ELEMENT_CONTENT_7) { @@ -5148,7 +5143,6 @@ static void CopyCustomElementPropertiesToEditor(int element) static void CopyGroupElementPropertiesToEditor(int element) { - group_element = element_info[element]; group_element_info = *element_info[element].group; } @@ -5289,9 +5283,8 @@ static void CopyCustomElementPropertiesToGame(int element) static void CopyGroupElementPropertiesToGame(int element) { /* mark that this group element has been modified */ - group_element.modified_settings = TRUE; + element_info[element].modified_settings = TRUE; - element_info[element] = group_element; *element_info[element].group = group_element_info; } @@ -7320,6 +7313,7 @@ static void HandleCounterButtons(struct GadgetInfo *gi) case ED_COUNTER_ID_GROUP_CONTENT: DrawGroupElementArea(properties_element); + CopyGroupElementPropertiesToGame(properties_element); break; case ED_COUNTER_ID_ENVELOPE_XSIZE: diff --git a/src/files.c b/src/files.c index 955c6973..135920b8 100644 --- a/src/files.c +++ b/src/files.c @@ -41,6 +41,7 @@ #define LEVEL_CHUNK_CUS3_SIZE(x) (2 + (x) * LEVEL_CPART_CUS3_SIZE) #define LEVEL_CHUNK_CUS4_SIZE(x) (48 + 48 + (x) * 48) +#define LEVEL_CHUNK_GRP1_SIZE(x) (2 + 8 + (x) * 2) /* file identifier strings */ #define LEVEL_COOKIE_TMPL "ROCKSNDIAMONDS_LEVEL_FILE_VERSION_x.x" @@ -918,6 +919,46 @@ static int LoadLevel_CUS4(FILE *file, int chunk_size, struct LevelInfo *level) return chunk_size; } +static int LoadLevel_GRP1(FILE *file, int chunk_size, struct LevelInfo *level) +{ + struct ElementGroupInfo *group; + int chunk_size_expected; + int element; + int i; + + element = getFile16BitBE(file); + + if (!IS_GROUP_ELEMENT(element)) + { + Error(ERR_WARN, "invalid group element number %d", element); + + ReadUnusedBytesFromFile(file, chunk_size - 2); + return chunk_size; + } + + group = element_info[element].group; + + group->num_elements = getFile8Bit(file); + + /* some free bytes for future values and padding */ + ReadUnusedBytesFromFile(file, 7); + + chunk_size_expected = LEVEL_CHUNK_GRP1_SIZE(group->num_elements); + if (chunk_size_expected != chunk_size) + { + ReadUnusedBytesFromFile(file, chunk_size - 10); + return chunk_size_expected; + } + + for (i = 0; i < group->num_elements; i++) + group->element[i] = checkLevelElement(getFile16BitBE(file)); + + /* mark this group element as modified */ + element_info[element].modified_settings = TRUE; + + return chunk_size; +} + static void LoadLevelFromFileInfo_RND(struct LevelInfo *level, struct LevelFileInfo *level_file_info) { @@ -1005,6 +1046,7 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level, { "CUS2", -1, LoadLevel_CUS2 }, { "CUS3", -1, LoadLevel_CUS3 }, { "CUS4", -1, LoadLevel_CUS4 }, + { "GRP1", -1, LoadLevel_GRP1 }, { NULL, 0, NULL } }; @@ -2026,6 +2068,22 @@ static void SaveLevel_CUS4(FILE *file, struct LevelInfo *level, int element) } } +static void SaveLevel_GRP1(FILE *file, struct LevelInfo *level, int element) +{ + struct ElementGroupInfo *group = element_info[element].group; + int i; + + putFile16BitBE(file, element); + + putFile8Bit(file, group->num_elements); + + /* some free bytes for future values and padding */ + WriteUnusedBytesToFile(file, 7); + + for (i = 0; i < group->num_elements; i++) + putFile16BitBE(file, group->element[i]); +} + static void SaveLevelFromFilename(struct LevelInfo *level, char *filename) { int body_chunk_size; @@ -2122,6 +2180,23 @@ static void SaveLevelFromFilename(struct LevelInfo *level, char *filename) } } + /* check for non-default group elements (unless using template level) */ + if (!level->use_custom_template) + { + for (i = 0; i < NUM_GROUP_ELEMENTS; i++) + { + int element = EL_GROUP_START + i; + + if (element_info[element].modified_settings) + { + int num_elements = element_info[element].group->num_elements; + + putFileChunkBE(file, "GRP1", LEVEL_CHUNK_GRP1_SIZE(num_elements)); + SaveLevel_GRP1(file, level, element); + } + } + } + fclose(file); SetFilePermissions(filename, PERMS_PRIVATE);