+static void copyConfigFromConfigList(struct LevelFileConfigInfo *conf)
+{
+ int i;
+
+ for (i = 0; conf[i].data_type != -1; i++)
+ {
+ int data_type = conf[i].data_type;
+ int conf_type = conf[i].conf_type;
+ int byte_mask = conf_type & CONF_MASK_BYTES;
+
+ if (byte_mask == CONF_MASK_MULTI_BYTES)
+ {
+ int max_num_entities = conf[i].max_num_entities;
+
+ if (data_type == TYPE_STRING)
+ {
+ char *string = (char *)(conf[i].value);
+ char *string_copy = (char *)(conf[i].value_copy);
+
+ strncpy(string_copy, string, max_num_entities);
+ }
+ else if (data_type == TYPE_ELEMENT_LIST)
+ {
+ int *element_array = (int *)(conf[i].value);
+ int *element_array_copy = (int *)(conf[i].value_copy);
+ int j;
+
+ for (j = 0; j < max_num_entities; j++)
+ element_array_copy[j] = element_array[j];
+ }
+ else if (data_type == TYPE_CONTENT_LIST)
+ {
+ struct Content *content = (struct Content *)(conf[i].value);
+ struct Content *content_copy = (struct Content *)(conf[i].value_copy);
+ int c, x, y;
+
+ for (c = 0; c < max_num_entities; c++)
+ for (y = 0; y < 3; y++)
+ for (x = 0; x < 3; x++)
+ content_copy[c].e[x][y] = content[c].e[x][y];
+ }
+ }
+ else /* constant size configuration data (1, 2 or 4 bytes) */
+ {
+ if (data_type == TYPE_BOOLEAN)
+ *(boolean *)(conf[i].value_copy) = *(boolean *)(conf[i].value);
+ else
+ *(int *) (conf[i].value_copy) = *(int *) (conf[i].value);
+ }
+ }
+}
+
+void copyElementInfo(struct ElementInfo *ei_from, struct ElementInfo *ei_to)
+{
+ int i;
+
+ xx_ei = *ei_from; /* copy element data into temporary buffer */
+ yy_ei = *ei_to; /* copy element data into temporary buffer */
+
+ copyConfigFromConfigList(chunk_config_CUSX_base);
+
+ *ei_from = xx_ei;
+ *ei_to = yy_ei;
+
+ /* ---------- reinitialize and copy change pages ---------- */
+
+ ei_to->num_change_pages = ei_from->num_change_pages;
+ ei_to->current_change_page = ei_from->current_change_page;
+
+ setElementChangePages(ei_to, ei_to->num_change_pages);
+
+ for (i = 0; i < ei_to->num_change_pages; i++)
+ ei_to->change_page[i] = ei_from->change_page[i];
+
+ /* ---------- copy group element info ---------- */
+ if (ei_from->group != NULL && ei_to->group != NULL) /* group or internal */
+ *ei_to->group = *ei_from->group;
+
+ /* mark this custom element as modified */
+ ei_to->modified_settings = TRUE;