static struct ElementChangeInfo custom_element_change;
static struct ElementGroupInfo group_element_info;
static struct ElementInfo custom_element;
-static struct ElementInfo group_element;
static struct
{
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)
{
static void CopyGroupElementPropertiesToEditor(int element)
{
- group_element = element_info[element];
group_element_info = *element_info[element].group;
}
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;
}
case ED_COUNTER_ID_GROUP_CONTENT:
DrawGroupElementArea(properties_element);
+ CopyGroupElementPropertiesToGame(properties_element);
break;
case ED_COUNTER_ID_ENVELOPE_XSIZE:
#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"
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)
{
{ "CUS2", -1, LoadLevel_CUS2 },
{ "CUS3", -1, LoadLevel_CUS3 },
{ "CUS4", -1, LoadLevel_CUS4 },
+ { "GRP1", -1, LoadLevel_GRP1 },
{ NULL, 0, NULL }
};
}
}
+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;
}
}
+ /* 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);