rnd-20060518-1-src
[rocksndiamonds.git] / src / files.c
index b23388e9435e212d8e54b9990eaaac52226bc952..e96f86364e3345f5863bd9d4889bb94a0f939b14 100644 (file)
 #define CHUNK_ID_LEN           4       /* IFF style chunk id length  */
 #define CHUNK_SIZE_UNDEFINED   0       /* undefined chunk size == 0  */
 #define CHUNK_SIZE_NONE                -1      /* do not write chunk size    */
-#define FILE_VERS_CHUNK_SIZE   8       /* size of file version chunk */
-#define LEVEL_HEADER_SIZE      80      /* size of level file header  */
-#define LEVEL_HEADER_UNUSED    0       /* unused level header bytes  */
+
+#define LEVEL_CHUNK_VERS_SIZE  8       /* size of file version chunk */
+#define LEVEL_CHUNK_HEAD_SIZE  80      /* size of level file header  */
+#define LEVEL_CHUNK_HEAD_UNUSED        0       /* unused level header bytes  */
 #define LEVEL_CHUNK_CNT2_SIZE  160     /* size of level CNT2 chunk   */
 #define LEVEL_CHUNK_CNT2_UNUSED        11      /* unused CNT2 chunk bytes    */
 #define LEVEL_CHUNK_CNT3_HEADER        16      /* size of level CNT3 header  */
 #define LEVEL_CPART_CUS3_SIZE  134     /* size of CUS3 chunk part    */
 #define LEVEL_CPART_CUS3_UNUSED        15      /* unused CUS3 bytes / part   */
 #define LEVEL_CHUNK_GRP1_SIZE  74      /* size of level GRP1 chunk   */
-#define TAPE_HEADER_SIZE       20      /* size of tape file header   */
-#define TAPE_HEADER_UNUSED     3       /* unused tape header bytes   */
+
+#define TAPE_CHUNK_VERS_SIZE   8       /* size of file version chunk */
+#define TAPE_CHUNK_HEAD_SIZE   20      /* size of tape file header   */
+#define TAPE_CHUNK_HEAD_UNUSED 3       /* unused tape header bytes   */
 
 #define LEVEL_CHUNK_CNT3_SIZE(x)        (LEVEL_CHUNK_CNT3_HEADER + (x))
 #define LEVEL_CHUNK_CUS3_SIZE(x)        (2 + (x) * LEVEL_CPART_CUS3_SIZE)
@@ -72,6 +75,7 @@
 #define CONF_VALUE_32_BIT(x)           CONF_VALUE_4_BYTE(x)
 #define CONF_VALUE_BYTES(x)            CONF_VALUE_MULTI_BYTES(x)
 
+#if 0
 #define CONF_VALUE_INTEGER_1           CONF_VALUE_8_BIT(1)
 #define CONF_VALUE_INTEGER_2           CONF_VALUE_8_BIT(2)
 #define CONF_VALUE_INTEGER_3           CONF_VALUE_8_BIT(3)
 #define CONF_VALUE_ELEMENT_7           CONF_VALUE_16_BIT(7)
 #define CONF_VALUE_ELEMENT_8           CONF_VALUE_16_BIT(8)
 
-#if 0
 #define CONF_VALUE_ELEMENTS            CONF_VALUE_BYTES(1)
 #define CONF_VALUE_CONTENTS            CONF_VALUE_BYTES(2)
 #endif
@@ -154,15 +157,16 @@ static void LoadLevel_InitPlayfield(struct LevelInfo *, char *);
 
 /* temporary variables used to store pointers to structure members */
 static struct LevelInfo li;
-static struct ElementInfo xx_ei;
+static struct ElementInfo xx_ei, yy_ei;
 static struct ElementChangeInfo xx_change;
 static struct ElementGroupInfo xx_group;
-static unsigned int xx_event_bits_0_31, xx_event_bits_32_63;
-static int xx_num_description_bytes;
+static unsigned int xx_event_bits[NUM_CE_BITFIELDS];
+static char xx_default_description[MAX_ELEMENT_NAME_LEN + 1];
+static int xx_default_description_length;
 static int xx_num_contents;
 static int xx_current_change_page;
 
-struct ElementFileConfig
+struct LevelFileConfigInfo
 {
   int element;                 /* element for which data is to be stored */
   int data_type;               /* internal type of data */
@@ -173,302 +177,569 @@ struct ElementFileConfig
   int default_value;           /* initial default value for this variable */
 
   /* (optional) */
+  void *value_copy;            /* variable that holds the data to be copied */
   void *num_entities;          /* number of entities for multi-byte data */
   int default_num_entities;    /* default number of entities for this data */
   int max_num_entities;                /* maximal number of entities for this data */
+  char *default_string;                /* optional default string for string data */
 };
 
-static struct ElementFileConfig element_conf[] =
+static struct LevelFileConfigInfo chunk_config_CONF[] =
 {
-  /* ---------- 1-byte values ---------------------------------------------- */
+  {
+    EL_PLAYER_1,
+    TYPE_INTEGER,                      CONF_VALUE_8_BIT(1),
+    &li.initial_player_stepsize,       STEPSIZE_NORMAL
+  },
+  {
+    EL_PLAYER_1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(2),
+    &li.block_last_field,              FALSE   /* default case for EM levels */
+  },
+  {
+    EL_PLAYER_1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(3),
+    &li.sp_block_last_field,           TRUE    /* default case for SP levels */
+  },
+  {
+    EL_PLAYER_1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(4),
+    &li.instant_relocation,            FALSE
+  },
+  {
+    EL_PLAYER_1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(5),
+    &li.can_pass_to_walkable,          FALSE
+  },
+  {
+    EL_PLAYER_1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(6),
+    &li.initial_player_gravity[0],     FALSE
+  },
+  {
+    EL_PLAYER_1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(9),
+    &li.block_snap_field,              TRUE
+  },
+  {
+    EL_PLAYER_1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(10),
+    &li.use_start_element[0],          FALSE
+  },
+  {
+    EL_PLAYER_1,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
+    &li.start_element[0],              EL_PLAYER_1
+  },
+  {
+    EL_PLAYER_1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(11),
+    &li.use_artwork_element[0],                FALSE
+  },
+  {
+    EL_PLAYER_1,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(2),
+    &li.artwork_element[0],            EL_PLAYER_1
+  },
+  {
+    EL_PLAYER_1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(12),
+    &li.use_explosion_element[0],      FALSE
+  },
+  {
+    EL_PLAYER_1,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(3),
+    &li.explosion_element[0],          EL_PLAYER_1
+  },
+  {
+    EL_PLAYER_1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(13),
+    &li.continuous_snapping,           TRUE
+  },
 
   {
-    EL_EMC_ANDROID,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_1,
-    &li.android_move_time,             10
+    EL_PLAYER_2,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(6),
+    &li.initial_player_gravity[1],     FALSE
   },
   {
-    EL_EMC_ANDROID,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_2,
-    &li.android_clone_time,            10
+    EL_PLAYER_2,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(10),
+    &li.use_start_element[1],          FALSE
   },
   {
-    EL_EMC_LENSES,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_1,
-    &li.lenses_score,                  10
+    EL_PLAYER_2,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
+    &li.start_element[1],              EL_PLAYER_2
   },
   {
-    EL_EMC_LENSES,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_2,
-    &li.lenses_time,                   10
+    EL_PLAYER_2,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(11),
+    &li.use_artwork_element[1],                FALSE
   },
   {
-    EL_EMC_MAGNIFIER,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_1,
-    &li.magnify_score,                 10
+    EL_PLAYER_2,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(2),
+    &li.artwork_element[1],            EL_PLAYER_2
   },
   {
-    EL_EMC_MAGNIFIER,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_2,
-    &li.magnify_time,                  10
+    EL_PLAYER_2,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(12),
+    &li.use_explosion_element[1],      FALSE
+  },
+  {
+    EL_PLAYER_2,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(3),
+    &li.explosion_element[1],          EL_PLAYER_2
+  },
+
+  {
+    EL_PLAYER_3,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(6),
+    &li.initial_player_gravity[2],     FALSE
+  },
+  {
+    EL_PLAYER_3,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(10),
+    &li.use_start_element[2],          FALSE
+  },
+  {
+    EL_PLAYER_3,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
+    &li.start_element[2],              EL_PLAYER_3
+  },
+  {
+    EL_PLAYER_3,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(11),
+    &li.use_artwork_element[2],                FALSE
+  },
+  {
+    EL_PLAYER_3,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(2),
+    &li.artwork_element[2],            EL_PLAYER_3
+  },
+  {
+    EL_PLAYER_3,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(12),
+    &li.use_explosion_element[2],      FALSE
+  },
+  {
+    EL_PLAYER_3,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(3),
+    &li.explosion_element[2],          EL_PLAYER_3
+  },
+
+  {
+    EL_PLAYER_4,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(6),
+    &li.initial_player_gravity[3],     FALSE
+  },
+  {
+    EL_PLAYER_4,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(10),
+    &li.use_start_element[3],          FALSE
+  },
+  {
+    EL_PLAYER_4,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
+    &li.start_element[3],              EL_PLAYER_4
   },
+  {
+    EL_PLAYER_4,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(11),
+    &li.use_artwork_element[3],                FALSE
+  },
+  {
+    EL_PLAYER_4,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(2),
+    &li.artwork_element[3],            EL_PLAYER_4
+  },
+  {
+    EL_PLAYER_4,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(12),
+    &li.use_explosion_element[3],      FALSE
+  },
+  {
+    EL_PLAYER_4,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(3),
+    &li.explosion_element[3],          EL_PLAYER_4
+  },
+
+  {
+    EL_EMERALD,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.score[SC_EMERALD],             10
+  },
+
+  {
+    EL_DIAMOND,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.score[SC_DIAMOND],             10
+  },
+
+  {
+    EL_BUG,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.score[SC_BUG],                 10
+  },
+
+  {
+    EL_SPACESHIP,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.score[SC_SPACESHIP],           10
+  },
+
+  {
+    EL_PACMAN,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.score[SC_PACMAN],              10
+  },
+
+  {
+    EL_NUT,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.score[SC_NUT],                 10
+  },
+
+  {
+    EL_DYNAMITE,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.score[SC_DYNAMITE],            10
+  },
+
+  {
+    EL_KEY_1,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.score[SC_KEY],                 10
+  },
+
+  {
+    EL_PEARL,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.score[SC_PEARL],               10
+  },
+
+  {
+    EL_CRYSTAL,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.score[SC_CRYSTAL],             10
+  },
+
+  {
+    EL_BD_AMOEBA,
+    TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
+    &li.amoeba_content,                        EL_DIAMOND
+  },
+  {
+    EL_BD_AMOEBA,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(2),
+    &li.amoeba_speed,                  10
+  },
+  {
+    EL_BD_AMOEBA,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(1),
+    &li.grow_into_diggable,            TRUE
+  },
+
+  {
+    EL_YAMYAM,
+    TYPE_CONTENT_LIST,                 CONF_VALUE_BYTES(1),
+    &li.yamyam_content,                        EL_ROCK, NULL,
+    &li.num_yamyam_contents,           4, MAX_ELEMENT_CONTENTS
+  },
+  {
+    EL_YAMYAM,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.score[SC_YAMYAM],              10
+  },
+
   {
     EL_ROBOT,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_1,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.score[SC_ROBOT],               10
+  },
+  {
+    EL_ROBOT,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(2),
     &li.slurp_score,                   10
   },
+
+  {
+    EL_ROBOT_WHEEL,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.time_wheel,                    10
+  },
+
+  {
+    EL_MAGIC_WALL,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.time_magic_wall,               10
+  },
+
   {
     EL_GAME_OF_LIFE,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_1,
+    TYPE_INTEGER,                      CONF_VALUE_8_BIT(1),
     &li.game_of_life[0],               2
   },
   {
     EL_GAME_OF_LIFE,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_2,
+    TYPE_INTEGER,                      CONF_VALUE_8_BIT(2),
     &li.game_of_life[1],               3
   },
   {
     EL_GAME_OF_LIFE,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_3,
+    TYPE_INTEGER,                      CONF_VALUE_8_BIT(3),
     &li.game_of_life[2],               3
   },
   {
     EL_GAME_OF_LIFE,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_4,
+    TYPE_INTEGER,                      CONF_VALUE_8_BIT(4),
     &li.game_of_life[3],               3
   },
+
   {
     EL_BIOMAZE,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_1,
+    TYPE_INTEGER,                      CONF_VALUE_8_BIT(1),
     &li.biomaze[0],                    2
   },
   {
     EL_BIOMAZE,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_2,
+    TYPE_INTEGER,                      CONF_VALUE_8_BIT(2),
     &li.biomaze[1],                    3
   },
   {
     EL_BIOMAZE,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_3,
+    TYPE_INTEGER,                      CONF_VALUE_8_BIT(3),
     &li.biomaze[2],                    3
   },
   {
     EL_BIOMAZE,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_4,
+    TYPE_INTEGER,                      CONF_VALUE_8_BIT(4),
     &li.biomaze[3],                    3
   },
-  {
-    EL_BALLOON,
-    TYPE_BITFIELD,                     CONF_VALUE_INTEGER_1,
-    &li.wind_direction_initial,                MV_NONE
-  },
+
   {
     EL_TIMEGATE_SWITCH,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_1,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
     &li.time_timegate,                 10
   },
+
   {
     EL_LIGHT_SWITCH_ACTIVE,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_1,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
     &li.time_light,                    10
   },
+
   {
     EL_SHIELD_NORMAL,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_1,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
     &li.shield_normal_time,            10
   },
+  {
+    EL_SHIELD_NORMAL,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(2),
+    &li.score[SC_SHIELD],              10
+  },
+
   {
     EL_SHIELD_DEADLY,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_1,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
     &li.shield_deadly_time,            10
   },
+  {
+    EL_SHIELD_DEADLY,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(2),
+    &li.score[SC_SHIELD],              10
+  },
+
   {
     EL_EXTRA_TIME,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_1,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
     &li.extra_time,                    10
   },
   {
     EL_EXTRA_TIME,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_2,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(2),
     &li.extra_time_score,              10
   },
+
   {
     EL_TIME_ORB_FULL,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_1,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
     &li.time_orb_time,                 10
   },
   {
     EL_TIME_ORB_FULL,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(1),
     &li.use_time_orb_bug,              FALSE
   },
+
   {
-    EL_PLAYER_1,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_1,
-    &li.block_snap_field,              TRUE
-  },
-  {
-    EL_PLAYER_1,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_2,
-    &li.use_start_element[0],          FALSE
-  },
-  {
-    EL_PLAYER_2,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_2,
-    &li.use_start_element[1],          FALSE
-  },
-  {
-    EL_PLAYER_3,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_2,
-    &li.use_start_element[2],          FALSE
-  },
-  {
-    EL_PLAYER_4,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_2,
-    &li.use_start_element[3],          FALSE
-  },
-  {
-    EL_PLAYER_1,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_3,
-    &li.use_artwork_element[0],                FALSE
-  },
-  {
-    EL_PLAYER_2,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_3,
-    &li.use_artwork_element[1],                FALSE
-  },
-  {
-    EL_PLAYER_3,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_3,
-    &li.use_artwork_element[2],                FALSE
+    EL_SPRING,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(1),
+    &li.use_spring_bug,                        FALSE
   },
+
   {
-    EL_PLAYER_4,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_3,
-    &li.use_artwork_element[3],                FALSE
+    EL_EMC_ANDROID,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.android_move_time,             10
   },
   {
-    EL_PLAYER_1,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_4,
-    &li.use_explosion_element[0],      FALSE
+    EL_EMC_ANDROID,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(2),
+    &li.android_clone_time,            10
   },
   {
-    EL_PLAYER_2,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_4,
-    &li.use_explosion_element[1],      FALSE
+    EL_EMC_ANDROID,
+    TYPE_ELEMENT_LIST,                 CONF_VALUE_BYTES(1),
+    &li.android_clone_element[0],      EL_EMPTY, NULL,
+    &li.num_android_clone_elements,    1, MAX_ANDROID_ELEMENTS
   },
+
   {
-    EL_PLAYER_3,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_4,
-    &li.use_explosion_element[2],      FALSE
+    EL_EMC_LENSES,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.lenses_score,                  10
   },
   {
-    EL_PLAYER_4,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_4,
-    &li.use_explosion_element[3],      FALSE
+    EL_EMC_LENSES,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(2),
+    &li.lenses_time,                   10
   },
+
   {
-    EL_PLAYER_1,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_5,
-    &li.continuous_snapping,           TRUE
+    EL_EMC_MAGNIFIER,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.magnify_score,                 10
   },
   {
-    EL_PLAYER_1,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_1,
-    &li.initial_player_stepsize,       STEPSIZE_NORMAL
+    EL_EMC_MAGNIFIER,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(2),
+    &li.magnify_time,                  10
   },
+
   {
     EL_EMC_MAGIC_BALL,
-    TYPE_INTEGER,                      CONF_VALUE_INTEGER_1,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
     &li.ball_time,                     10
   },
   {
     EL_EMC_MAGIC_BALL,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(1),
     &li.ball_random,                   FALSE
   },
   {
     EL_EMC_MAGIC_BALL,
-    TYPE_BOOLEAN,                      CONF_VALUE_BOOLEAN_2,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(2),
     &li.ball_state_initial,            FALSE
   },
+  {
+    EL_EMC_MAGIC_BALL,
+    TYPE_CONTENT_LIST,                 CONF_VALUE_BYTES(1),
+    &li.ball_content,                  EL_EMPTY, NULL,
+    &li.num_ball_contents,             4, MAX_ELEMENT_CONTENTS
+  },
 
-  /* ---------- 2-byte values ---------------------------------------------- */
+  /* ---------- unused values ----------------------------------------------- */
 
   {
-    EL_PLAYER_1,
-    TYPE_ELEMENT,                      CONF_VALUE_ELEMENT_1,
-    &li.start_element[0],              EL_PLAYER_1
+    EL_UNKNOWN,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.score[SC_UNKNOWN_14],          10
   },
   {
-    EL_PLAYER_2,
-    TYPE_ELEMENT,                      CONF_VALUE_ELEMENT_1,
-    &li.start_element[1],              EL_PLAYER_2
+    EL_UNKNOWN,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(2),
+    &li.score[SC_UNKNOWN_15],          10
   },
+
   {
-    EL_PLAYER_3,
-    TYPE_ELEMENT,                      CONF_VALUE_ELEMENT_1,
-    &li.start_element[2],              EL_PLAYER_3
+    -1,
+    -1,                                        -1,
+    NULL,                              -1,
   },
+};
+
+static struct LevelFileConfigInfo chunk_config_INFO[] =
+{
+  /* ---------- values not related to single elements ----------------------- */
+
   {
-    EL_PLAYER_4,
-    TYPE_ELEMENT,                      CONF_VALUE_ELEMENT_1,
-    &li.start_element[3],              EL_PLAYER_4
+    -1,
+    TYPE_INTEGER,                      CONF_VALUE_8_BIT(1),
+    &li.game_engine_type,              GAME_ENGINE_TYPE_RND
   },
+
   {
-    EL_PLAYER_1,
-    TYPE_ELEMENT,                      CONF_VALUE_ELEMENT_2,
-    &li.artwork_element[0],            EL_PLAYER_1
+    -1,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.fieldx,                                STD_LEV_FIELDX
   },
   {
-    EL_PLAYER_2,
-    TYPE_ELEMENT,                      CONF_VALUE_ELEMENT_2,
-    &li.artwork_element[1],            EL_PLAYER_2
+    -1,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(2),
+    &li.fieldy,                                STD_LEV_FIELDY
   },
+
   {
-    EL_PLAYER_3,
-    TYPE_ELEMENT,                      CONF_VALUE_ELEMENT_2,
-    &li.artwork_element[2],            EL_PLAYER_3
+    -1,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(3),
+    &li.time,                          100
   },
+
   {
-    EL_PLAYER_4,
-    TYPE_ELEMENT,                      CONF_VALUE_ELEMENT_2,
-    &li.artwork_element[3],            EL_PLAYER_4
+    -1,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(4),
+    &li.gems_needed,                   0
   },
+
   {
-    EL_PLAYER_1,
-    TYPE_ELEMENT,                      CONF_VALUE_ELEMENT_3,
-    &li.explosion_element[0],          EL_PLAYER_1
+    -1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(2),
+    &li.use_step_counter,              FALSE
   },
+
   {
-    EL_PLAYER_2,
-    TYPE_ELEMENT,                      CONF_VALUE_ELEMENT_3,
-    &li.explosion_element[1],          EL_PLAYER_2
+    -1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(3),
+    &li.initial_gravity,               FALSE
   },
+
   {
-    EL_PLAYER_3,
-    TYPE_ELEMENT,                      CONF_VALUE_ELEMENT_3,
-    &li.explosion_element[2],          EL_PLAYER_3
+    -1,
+    TYPE_BITFIELD,                     CONF_VALUE_8_BIT(4),
+    &li.wind_direction_initial,                MV_NONE
+  },
+
+  {
+    -1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(5),
+    &li.em_slippery_gems,              FALSE
   },
+
   {
-    EL_PLAYER_4,
-    TYPE_ELEMENT,                      CONF_VALUE_ELEMENT_3,
-    &li.explosion_element[3],          EL_PLAYER_4
+    -1,
+    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(6),
+    &li.use_custom_template,           FALSE
   },
 
-  /* ---------- multi-byte values ------------------------------------------ */
+  {
+    -1,
+    TYPE_BITFIELD,                     CONF_VALUE_32_BIT(1),
+    &li.can_move_into_acid_bits,       ~0      /* default: everything can */
+  },
 
   {
-    EL_EMC_ANDROID,
-    TYPE_ELEMENT_LIST,                 CONF_VALUE_BYTES(1),
-    &li.android_clone_element[0],      EL_EMPTY,
-    &li.num_android_clone_elements,    1, MAX_ANDROID_ELEMENTS
+    -1,
+    TYPE_BITFIELD,                     CONF_VALUE_8_BIT(7),
+    &li.dont_collide_with_bits,                ~0      /* default: always deadly */
   },
+
   {
-    EL_EMC_MAGIC_BALL,
-    TYPE_CONTENT_LIST,                 CONF_VALUE_BYTES(2),
-    &li.ball_content,                  EL_EMPTY,
-    &li.num_ball_contents,             4, MAX_ELEMENT_CONTENTS
+    -1,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(5),
+    &li.score[SC_TIME_BONUS],          1
   },
 
   {
@@ -478,167 +749,191 @@ static struct ElementFileConfig element_conf[] =
   },
 };
 
-static struct ElementFileConfig custom_element_conf[] =
+static struct LevelFileConfigInfo chunk_config_CUSX_base[] =
 {
   {
     -1,
     TYPE_STRING,                       CONF_VALUE_BYTES(1),
-    &xx_ei.description[0],             0,
-    &xx_num_description_bytes, MAX_ELEMENT_NAME_LEN, MAX_ELEMENT_NAME_LEN,
+    &xx_ei.description[0],             -1,
+    &yy_ei.description[0],
+    &xx_default_description_length,    -1, MAX_ELEMENT_NAME_LEN,
+    &xx_default_description[0]
   },
 
   {
     -1,
     TYPE_BITFIELD,                     CONF_VALUE_32_BIT(1),
-    &xx_ei.properties[EP_BITFIELD_BASE],
-#if 0
-    EP_BITMASK_DEFAULT
-#else
-    (1 << EP_CAN_MOVE_INTO_ACID)
-#endif
+    &xx_ei.properties[EP_BITFIELD_BASE_NR], EP_BITMASK_BASE_DEFAULT,
+    &yy_ei.properties[EP_BITFIELD_BASE_NR]
   },
 #if 0
   /* (reserved) */
   {
     -1,
     TYPE_BITFIELD,                     CONF_VALUE_32_BIT(2),
-    &xx_ei.properties[EP_BITFIELD_BASE + 1], EP_BITMASK_DEFAULT
+    &xx_ei.properties[EP_BITFIELD_BASE_NR + 1], EP_BITMASK_DEFAULT,
+    &yy_ei.properties[EP_BITFIELD_BASE_NR + 1]
   },
 #endif
 
   {
     -1,
     TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(1),
-    &xx_ei.use_gfx_element,            FALSE
+    &xx_ei.use_gfx_element,            FALSE,
+    &yy_ei.use_gfx_element
   },
   {
     -1,
     TYPE_ELEMENT,                      CONF_VALUE_16_BIT(1),
-    &xx_ei.gfx_element,                        EL_EMPTY_SPACE
+    &xx_ei.gfx_element,                        EL_EMPTY_SPACE,
+    &yy_ei.gfx_element
   },
 
   {
     -1,
     TYPE_BITFIELD,                     CONF_VALUE_8_BIT(2),
-    &xx_ei.access_direction,           MV_ALL_DIRECTIONS
+    &xx_ei.access_direction,           MV_ALL_DIRECTIONS,
+    &yy_ei.access_direction
   },
 
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_16_BIT(2),
-    &xx_ei.collect_score_initial,      10
+    &xx_ei.collect_score_initial,      10,
+    &yy_ei.collect_score_initial
   },
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_16_BIT(3),
-    &xx_ei.collect_count_initial,      1
+    &xx_ei.collect_count_initial,      1,
+    &yy_ei.collect_count_initial
   },
 
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_16_BIT(4),
-    &xx_ei.ce_value_fixed_initial,     0
+    &xx_ei.ce_value_fixed_initial,     0,
+    &yy_ei.ce_value_fixed_initial
   },
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_16_BIT(5),
-    &xx_ei.ce_value_random_initial,    0
+    &xx_ei.ce_value_random_initial,    0,
+    &yy_ei.ce_value_random_initial
   },
   {
     -1,
     TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(3),
-    &xx_ei.use_last_ce_value,          FALSE
+    &xx_ei.use_last_ce_value,          FALSE,
+    &yy_ei.use_last_ce_value
   },
 
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_16_BIT(6),
     &xx_ei.push_delay_fixed,           8,
+    &yy_ei.push_delay_fixed
   },
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_16_BIT(7),
     &xx_ei.push_delay_random,          8,
+    &yy_ei.push_delay_random
   },
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_16_BIT(8),
-    &xx_ei.drop_delay_fixed,           0
+    &xx_ei.drop_delay_fixed,           0,
+    &yy_ei.drop_delay_fixed
   },
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_16_BIT(9),
-    &xx_ei.drop_delay_random,          0
+    &xx_ei.drop_delay_random,          0,
+    &yy_ei.drop_delay_random
   },
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_16_BIT(10),
-    &xx_ei.move_delay_fixed,           0
+    &xx_ei.move_delay_fixed,           0,
+    &yy_ei.move_delay_fixed
   },
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_16_BIT(11),
-    &xx_ei.move_delay_random,          0
+    &xx_ei.move_delay_random,          0,
+    &yy_ei.move_delay_random
   },
 
   {
     -1,
     TYPE_BITFIELD,                     CONF_VALUE_32_BIT(3),
-    &xx_ei.move_pattern,               MV_ALL_DIRECTIONS
+    &xx_ei.move_pattern,               MV_ALL_DIRECTIONS,
+    &yy_ei.move_pattern
   },
   {
     -1,
     TYPE_BITFIELD,                     CONF_VALUE_8_BIT(4),
-    &xx_ei.move_direction_initial,     MV_START_AUTOMATIC
+    &xx_ei.move_direction_initial,     MV_START_AUTOMATIC,
+    &yy_ei.move_direction_initial
   },
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_8_BIT(5),
-    &xx_ei.move_stepsize,              TILEX / 8
+    &xx_ei.move_stepsize,              TILEX / 8,
+    &yy_ei.move_stepsize
   },
 
   {
     -1,
     TYPE_ELEMENT,                      CONF_VALUE_16_BIT(12),
-    &xx_ei.move_enter_element,         EL_EMPTY_SPACE
+    &xx_ei.move_enter_element,         EL_EMPTY_SPACE,
+    &yy_ei.move_enter_element
   },
   {
     -1,
     TYPE_ELEMENT,                      CONF_VALUE_16_BIT(13),
-    &xx_ei.move_leave_element,         EL_EMPTY_SPACE
+    &xx_ei.move_leave_element,         EL_EMPTY_SPACE,
+    &yy_ei.move_leave_element
   },
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_8_BIT(6),
-    &xx_ei.move_leave_type,            LEAVE_TYPE_UNLIMITED
+    &xx_ei.move_leave_type,            LEAVE_TYPE_UNLIMITED,
+    &yy_ei.move_leave_type
   },
 
   {
     -1,
-    TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(7),
-    &xx_ei.slippery_type,              SLIPPERY_ANY_RANDOM
+    TYPE_INTEGER,                      CONF_VALUE_8_BIT(7),
+    &xx_ei.slippery_type,              SLIPPERY_ANY_RANDOM,
+    &yy_ei.slippery_type
   },
 
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_8_BIT(8),
-    &xx_ei.explosion_type,             EXPLODES_3X3
+    &xx_ei.explosion_type,             EXPLODES_3X3,
+    &yy_ei.explosion_type
   },
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_16_BIT(14),
-    &xx_ei.explosion_delay,            16
+    &xx_ei.explosion_delay,            16,
+    &yy_ei.explosion_delay
   },
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_16_BIT(15),
-    &xx_ei.ignition_delay,             8
+    &xx_ei.ignition_delay,             8,
+    &yy_ei.ignition_delay
   },
 
   {
     -1,
     TYPE_CONTENT_LIST,                 CONF_VALUE_BYTES(2),
     &xx_ei.content,                    EL_EMPTY_SPACE,
+    &yy_ei.content,
     &xx_num_contents,                  1, 1
   },
 
@@ -647,26 +942,30 @@ static struct ElementFileConfig custom_element_conf[] =
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_8_BIT(9),
-    &xx_ei.num_change_pages,           -1      /* always save this value */
+    &xx_ei.num_change_pages,           -1,     /* value must always be saved */
+    &yy_ei.num_change_pages
   },
 
   {
     -1,
     -1,                                        -1,
     NULL,                              -1,
+    NULL
   },
 };
 
-static struct ElementFileConfig custom_element_change_conf[] =
+static struct LevelFileConfigInfo chunk_config_CUSX_change[] =
 {
   /* ---------- "current_change_page" must be the first entry --------------- */
 
   {
     -1,
     TYPE_INTEGER,                      CONF_VALUE_8_BIT(1),
-    &xx_current_change_page,           -1
+    &xx_current_change_page,           -1      /* value must always be saved */
   },
 
+  /* ---------- (the remaining entries can be in any order) ----------------- */
+
   {
     -1,
     TYPE_BOOLEAN,                      CONF_VALUE_8_BIT(2),
@@ -676,27 +975,27 @@ static struct ElementFileConfig custom_element_change_conf[] =
   {
     -1,
     TYPE_BITFIELD,                     CONF_VALUE_32_BIT(1),
-    &xx_event_bits_0_31,               0
+    &xx_event_bits[0],                 0
   },
   {
     -1,
     TYPE_BITFIELD,                     CONF_VALUE_32_BIT(2),
-    &xx_event_bits_32_63,              0
+    &xx_event_bits[1],                 0
   },
 
   {
     -1,
-    TYPE_INTEGER,                      CONF_VALUE_8_BIT(3),
+    TYPE_BITFIELD,                     CONF_VALUE_8_BIT(3),
     &xx_change.trigger_player,         CH_PLAYER_ANY
   },
   {
     -1,
-    TYPE_INTEGER,                      CONF_VALUE_8_BIT(4),
+    TYPE_BITFIELD,                     CONF_VALUE_8_BIT(4),
     &xx_change.trigger_side,           CH_SIDE_ANY
   },
   {
     -1,
-    TYPE_INTEGER,                      CONF_VALUE_8_BIT(5),
+    TYPE_BITFIELD,                     CONF_VALUE_32_BIT(3),
     &xx_change.trigger_page,           CH_PAGE_ANY
   },
 
@@ -783,7 +1082,7 @@ static struct ElementFileConfig custom_element_change_conf[] =
   {
     -1,
     TYPE_CONTENT_LIST,                 CONF_VALUE_BYTES(1),
-    &xx_change.target_content,         EL_EMPTY_SPACE,
+    &xx_change.target_content,         EL_EMPTY_SPACE, NULL,
     &xx_num_contents,                  1, 1
   },
 
@@ -794,13 +1093,14 @@ static struct ElementFileConfig custom_element_change_conf[] =
   },
 };
 
-static struct ElementFileConfig group_element_conf[] =
+static struct LevelFileConfigInfo chunk_config_GRPX[] =
 {
   {
     -1,
     TYPE_STRING,                       CONF_VALUE_BYTES(1),
-    &xx_ei.description[0],             0,
-    &xx_num_description_bytes, MAX_ELEMENT_NAME_LEN, MAX_ELEMENT_NAME_LEN,
+    &xx_ei.description[0],             -1, NULL,
+    &xx_default_description_length,    -1, MAX_ELEMENT_NAME_LEN,
+    &xx_default_description[0]
   },
 
   {
@@ -823,7 +1123,7 @@ static struct ElementFileConfig group_element_conf[] =
   {
     -1,
     TYPE_ELEMENT_LIST,                 CONF_VALUE_BYTES(2),
-    &xx_group.element[0],              EL_EMPTY_SPACE,
+    &xx_group.element[0],              EL_EMPTY_SPACE, NULL,
     &xx_group.num_elements,            1, MAX_ELEMENTS_IN_GROUP
   },
 
@@ -856,29 +1156,97 @@ filetype_id_list[] =
 /* level file functions                                                      */
 /* ========================================================================= */
 
-static void setLevelInfoToDefaultsFromConfigList(struct LevelInfo *level)
+static void resetEventFlags(struct ElementChangeInfo *change)
 {
   int i;
 
-  li = *level;         /* copy level data into temporary buffer */
+  for (i = 0; i < NUM_CHANGE_EVENTS; i++)
+    change->has_event[i] = FALSE;
+}
+
+static void resetEventBits()
+{
+  int i;
+
+  for (i = 0; i < NUM_CE_BITFIELDS; i++)
+    xx_event_bits[i] = 0;
+}
+
+static void setEventFlagsFromEventBits(struct ElementChangeInfo *change)
+{
+  int i;
+
+  /* important: only change event flag if corresponding event bit is set */
+  for (i = 0; i < NUM_CHANGE_EVENTS; i++)
+    if (xx_event_bits[CH_EVENT_BITFIELD_NR(i)] & CH_EVENT_BIT(i))
+      change->has_event[i] = TRUE;
+}
+
+static void setEventBitsFromEventFlags(struct ElementChangeInfo *change)
+{
+  int i;
+
+  /* important: only change event bit if corresponding event flag is set */
+  for (i = 0; i < NUM_CHANGE_EVENTS; i++)
+    if (change->has_event[i])
+      xx_event_bits[CH_EVENT_BITFIELD_NR(i)] |= CH_EVENT_BIT(i);
+}
+
+static char *getDefaultElementDescription(struct ElementInfo *ei)
+{
+  static char description[MAX_ELEMENT_NAME_LEN + 1];
+  char *default_description = (ei->custom_description != NULL ?
+                              ei->custom_description :
+                              ei->editor_description);
+  int i;
+
+  /* always start with reliable default values */
+  for (i = 0; i < MAX_ELEMENT_NAME_LEN + 1; i++)
+    description[i] = '\0';
+
+  /* truncate element description to MAX_ELEMENT_NAME_LEN bytes */
+  strncpy(description, default_description, MAX_ELEMENT_NAME_LEN);
+
+  return &description[0];
+}
+
+static void setElementDescriptionToDefault(struct ElementInfo *ei)
+{
+  char *default_description = getDefaultElementDescription(ei);
+  int i;
+
+  for (i = 0; i < MAX_ELEMENT_NAME_LEN + 1; i++)
+    ei->description[i] = default_description[i];
+}
 
-  for (i = 0; element_conf[i].data_type != -1; i++)
+static void setConfigToDefaultsFromConfigList(struct LevelFileConfigInfo *conf)
+{
+  int i;
+
+  for (i = 0; conf[i].data_type != -1; i++)
   {
-    int default_value = element_conf[i].default_value;
-    int data_type = element_conf[i].data_type;
-    int conf_type = element_conf[i].conf_type;
+    int default_value = conf[i].default_value;
+    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 default_num_entities = element_conf[i].default_num_entities;
-      int max_num_entities = element_conf[i].max_num_entities;
+      int default_num_entities = conf[i].default_num_entities;
+      int max_num_entities = conf[i].max_num_entities;
+
+      *(int *)(conf[i].num_entities) = default_num_entities;
 
-      *(int *)(element_conf[i].num_entities) = default_num_entities;
+      if (data_type == TYPE_STRING)
+      {
+       char *default_string = conf[i].default_string;
+       char *string = (char *)(conf[i].value);
 
-      if (data_type == TYPE_ELEMENT_LIST)
+       strncpy(string, default_string, max_num_entities);
+      }
+      else if (data_type == TYPE_ELEMENT_LIST)
       {
-       int *element_array = (int *)(element_conf[i].value);
+       int *element_array = (int *)(conf[i].value);
        int j;
 
        for (j = 0; j < max_num_entities; j++)
@@ -886,7 +1254,7 @@ static void setLevelInfoToDefaultsFromConfigList(struct LevelInfo *level)
       }
       else if (data_type == TYPE_CONTENT_LIST)
       {
-       struct Content *content = (struct Content *)(element_conf[i].value);
+       struct Content *content = (struct Content *)(conf[i].value);
        int c, x, y;
 
        for (c = 0; c < max_num_entities; c++)
@@ -898,14 +1266,151 @@ static void setLevelInfoToDefaultsFromConfigList(struct LevelInfo *level)
     else       /* constant size configuration data (1, 2 or 4 bytes) */
     {
       if (data_type == TYPE_BOOLEAN)
-       *(boolean *)(element_conf[i].value) = default_value;
+       *(boolean *)(conf[i].value) = default_value;
       else
-       *(int *)    (element_conf[i].value) = default_value;
+       *(int *)    (conf[i].value) = default_value;
     }
   }
+}
 
-  *level = li;         /* copy temporary buffer back to level data */
+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);
+    }
+  }
+}
+
+#if 1
+void copyElementInfo(struct ElementInfo *ei_from, struct ElementInfo *ei_to)
+{
+#if 1
+  int i;
+#else
+  int i, x, y;
+#endif
+
+#if 1
+  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;
+#endif
+
+#if 0
+  /* ---------- copy element description ---------- */
+  for (i = 0; i < MAX_ELEMENT_NAME_LEN + 1; i++)
+    ei_to->description[i] = ei_from->description[i];
+
+  /* ---------- copy element base properties ---------- */
+  ei_to->properties[EP_BITFIELD_BASE_NR] =
+    ei_from->properties[EP_BITFIELD_BASE_NR];
+
+  /* ---------- copy custom property values ---------- */
+
+  ei_to->use_gfx_element = ei_from->use_gfx_element;
+  ei_to->gfx_element = ei_from->gfx_element;
+
+  ei_to->access_direction = ei_from->access_direction;
+
+  ei_to->collect_score_initial = ei_from->collect_score_initial;
+  ei_to->collect_count_initial = ei_from->collect_count_initial;
+
+  ei_to->ce_value_fixed_initial = ei_from->ce_value_fixed_initial;
+  ei_to->ce_value_random_initial = ei_from->ce_value_random_initial;
+  ei_to->use_last_ce_value = ei_from->use_last_ce_value;
+
+  ei_to->push_delay_fixed = ei_from->push_delay_fixed;
+  ei_to->push_delay_random = ei_from->push_delay_random;
+  ei_to->drop_delay_fixed = ei_from->drop_delay_fixed;
+  ei_to->drop_delay_random = ei_from->drop_delay_random;
+  ei_to->move_delay_fixed = ei_from->move_delay_fixed;
+  ei_to->move_delay_random = ei_from->move_delay_random;
+
+  ei_to->move_pattern = ei_from->move_pattern;
+  ei_to->move_direction_initial = ei_from->move_direction_initial;
+  ei_to->move_stepsize = ei_from->move_stepsize;
+
+  ei_to->move_enter_element = ei_from->move_enter_element;
+  ei_to->move_leave_element = ei_from->move_leave_element;
+  ei_to->move_leave_type = ei_from->move_leave_type;
+
+  ei_to->slippery_type = ei_from->slippery_type;
+
+  ei_to->explosion_type = ei_from->explosion_type;
+  ei_to->explosion_delay = ei_from->explosion_delay;
+  ei_to->ignition_delay = ei_from->ignition_delay;
+
+  for (y = 0; y < 3; y++)
+    for (x = 0; x < 3; x++)
+      ei_to->content.e[x][y] = ei_from->content.e[x][y];
+#endif
+
+  /* ---------- 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;
 }
+#endif
 
 void setElementChangePages(struct ElementInfo *ei, int change_pages)
 {
@@ -922,10 +1427,24 @@ void setElementChangePages(struct ElementInfo *ei, int change_pages)
   ei->change = &ei->change_page[ei->current_change_page];
 }
 
-void setElementChangeInfoToDefaults(struct ElementChangeInfo *change)
-{
-  int i, x, y;
+void setElementChangeInfoToDefaults(struct ElementChangeInfo *change)
+{
+#if 0
+  int i, x, y;
+#endif
+
+#if 1
+  xx_change = *change;         /* copy change data into temporary buffer */
+  xx_num_contents = 1;
+
+  setConfigToDefaultsFromConfigList(chunk_config_CUSX_change);
+
+  *change = xx_change;
+
+  resetEventFlags(change);
+#endif
 
+#if 0
   change->can_change = FALSE;
 
   for (i = 0; i < NUM_CHANGE_EVENTS; i++)
@@ -958,6 +1477,7 @@ void setElementChangeInfoToDefaults(struct ElementChangeInfo *change)
   for (x = 0; x < 3; x++)
     for (y = 0; y < 3; y++)
       change->target_content.e[x][y] = EL_EMPTY_SPACE;
+#endif
 
   change->direct_action = 0;
   change->other_action = 0;
@@ -970,18 +1490,32 @@ void setElementChangeInfoToDefaults(struct ElementChangeInfo *change)
 static void setLevelInfoToDefaults(struct LevelInfo *level)
 {
   static boolean clipboard_elements_initialized = FALSE;
+#if 0
   int i, j, x, y;
+#else
+  int i, x, y;
+#endif
 
 #if 1
   InitElementPropertiesStatic();
 #endif
 
-  setLevelInfoToDefaultsFromConfigList(level);
+#if 1
+  li = *level;         /* copy level data into temporary buffer */
+
+  setConfigToDefaultsFromConfigList(chunk_config_INFO);
+  setConfigToDefaultsFromConfigList(chunk_config_CONF);
+
+  *level = li;         /* copy temporary buffer back to level data */
+#endif
+
   setLevelInfoToDefaults_EM();
 
   level->native_em_level = &native_em_level;
 
+#if 0
   level->game_engine_type = GAME_ENGINE_TYPE_RND;
+#endif
 
   level->file_version = FILE_VERSION_ACTUAL;
   level->game_version = GAME_VERSION_ACTUAL;
@@ -990,13 +1524,16 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
   level->encoding_16bit_yamyam = FALSE;        /* default: only 8-bit elements */
   level->encoding_16bit_amoeba = FALSE;        /* default: only 8-bit elements */
 
+#if 0
   level->fieldx = STD_LEV_FIELDX;
   level->fieldy = STD_LEV_FIELDY;
+#endif
 
   for (x = 0; x < MAX_LEV_FIELDX; x++)
     for (y = 0; y < MAX_LEV_FIELDY; y++)
       level->field[x][y] = EL_SAND;
 
+#if 0
   level->time = 100;
   level->gems_needed = 0;
 
@@ -1004,13 +1541,17 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
 
   level->time_magic_wall = 10;
   level->time_wheel = 10;
+#endif
 #if 0
   level->time_light = 10;
   level->time_timegate = 10;
 #endif
 
+#if 0
   level->amoeba_content = EL_DIAMOND;
+#endif
 
+#if 0
   level->game_of_life[0] = 2;
   level->game_of_life[1] = 3;
   level->game_of_life[2] = 3;
@@ -1020,20 +1561,24 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
   level->biomaze[1] = 3;
   level->biomaze[2] = 3;
   level->biomaze[3] = 3;
+#endif
 
 #if 0
   level->double_speed = FALSE;
 #endif
+#if 0
   level->initial_gravity = FALSE;
   level->em_slippery_gems = FALSE;
   level->instant_relocation = FALSE;
   level->can_pass_to_walkable = FALSE;
   level->grow_into_diggable = TRUE;
+#endif
 
 #if 0
   level->block_snap_field = TRUE;
 #endif
 
+#if 0
   level->block_last_field = FALSE;     /* EM does not block by default */
   level->sp_block_last_field = TRUE;   /* SP blocks the last field */
 
@@ -1044,6 +1589,7 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
   level->use_time_orb_bug = FALSE;
 
   level->use_step_counter = FALSE;
+#endif
 
   /* values for the new EMC elements */
 #if 0
@@ -1058,17 +1604,19 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
   level->wind_direction_initial = MV_NONE;
   level->ball_random = FALSE;
   level->ball_state_initial = FALSE;
+
   for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
     for (x = 0; x < 3; x++)
       for (y = 0; y < 3; y++)
        level->ball_content[i].e[x][y] = EL_EMPTY;
-#endif
-#if 0
+
   for (i = 0; i < 16; i++)
     level->android_array[i] = FALSE;
 #endif
 
+#if 0
   level->use_custom_template = FALSE;
+#endif
 
   for (i = 0; i < MAX_LEVEL_NAME_LEN; i++)
     level->name[i] = '\0';
@@ -1085,15 +1633,19 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
     level->envelope_ysize[i] = MAX_ENVELOPE_YSIZE;
   }
 
+#if 0
   for (i = 0; i < LEVEL_SCORE_ELEMENTS; i++)
     level->score[i] = (i == SC_TIME_BONUS ? 1 : 10);
+#endif
 
+#if 0
   level->num_yamyam_contents = STD_ELEMENT_CONTENTS;
   for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
     for (x = 0; x < 3; x++)
       for (y = 0; y < 3; y++)
        level->yamyam_content[i].e[x][y] =
          (i < STD_ELEMENT_CONTENTS ? EL_ROCK : EL_EMPTY);
+#endif
 
   level->field[0][0] = EL_PLAYER_1;
   level->field[STD_LEV_FIELDX - 1][STD_LEV_FIELDY - 1] = EL_EXIT_CLOSED;
@@ -1103,7 +1655,21 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
     int element = i;
     struct ElementInfo *ei = &element_info[element];
 
+#if 1
+    if (IS_CUSTOM_ELEMENT(element) ||
+       IS_GROUP_ELEMENT(element) ||
+       IS_INTERNAL_ELEMENT(element))
+    {
+      xx_ei = *ei;     /* copy element data into temporary buffer */
+
+      setConfigToDefaultsFromConfigList(chunk_config_CUSX_base);
+
+      *ei = xx_ei;
+    }
+#endif
+
     /* never initialize clipboard elements after the very first time */
+    /* (to be able to use clipboard elements between several levels) */
     if (IS_CLIPBOARD_ELEMENT(element) && clipboard_elements_initialized)
       continue;
 
@@ -1114,6 +1680,9 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
        IS_GROUP_ELEMENT(element) ||
        IS_INTERNAL_ELEMENT(element))
     {
+#if 1
+      setElementDescriptionToDefault(ei);
+#else
       for (j = 0; j < MAX_ELEMENT_NAME_LEN + 1; j++)
        ei->description[j] = '\0';
 
@@ -1121,9 +1690,12 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
        strncpy(ei->description, ei->custom_description,MAX_ELEMENT_NAME_LEN);
       else
        strcpy(ei->description, ei->editor_description);
+#endif
 
+#if 0
       ei->use_gfx_element = FALSE;
       ei->gfx_element = EL_EMPTY_SPACE;
+#endif
 
       ei->modified_settings = FALSE;
     }
@@ -1131,6 +1703,7 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
     if (IS_CUSTOM_ELEMENT(element) ||
        IS_INTERNAL_ELEMENT(element))
     {
+#if 0
       ei->access_direction = MV_ALL_DIRECTIONS;
 
       ei->collect_score_initial = 10;  /* special default */
@@ -1140,8 +1713,12 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
       ei->ce_value_random_initial = 0;
       ei->use_last_ce_value = FALSE;
 
+#endif
+#if 0
       ei->push_delay_fixed = -1;       /* initialize later */
       ei->push_delay_random = -1;      /* initialize later */
+#endif
+#if 0
       ei->drop_delay_fixed = 0;
       ei->drop_delay_random = 0;
       ei->move_delay_fixed = 0;
@@ -1164,6 +1741,9 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
       for (x = 0; x < 3; x++)
        for (y = 0; y < 3; y++)
          ei->content.e[x][y] = EL_EMPTY_SPACE;
+#endif
+
+      /* internal values used in level editor */
 
       ei->access_type = 0;
       ei->access_layer = 0;
@@ -1191,8 +1771,10 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
 #endif
 #endif
 
+#if 0
       /* now set default properties */
       SET_PROPERTY(element, EP_CAN_MOVE_INTO_ACID, TRUE);
+#endif
     }
 
     if (IS_GROUP_ELEMENT(element) ||
@@ -1206,6 +1788,15 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
 
       group = ei->group;
 
+#if 1
+      xx_group = *group;       /* copy group data into temporary buffer */
+
+      setConfigToDefaultsFromConfigList(chunk_config_GRPX);
+
+      *group = xx_group;
+#endif
+
+#if 0
       for (j = 0; j < MAX_ELEMENTS_IN_GROUP; j++)
        group->element[j] = EL_EMPTY_SPACE;
 
@@ -1213,6 +1804,7 @@ static void setLevelInfoToDefaults(struct LevelInfo *level)
       group->num_elements = 1;
 
       group->choice_mode = ANIM_RANDOM;
+#endif
     }
   }
 
@@ -1678,7 +2270,7 @@ static int LoadLevel_HEAD(FILE *file, int chunk_size, struct LevelInfo *level)
 
   level->game_engine_type      = getFile8Bit(file);
 
-  ReadUnusedBytesFromFile(file, LEVEL_HEADER_UNUSED);
+  ReadUnusedBytesFromFile(file, LEVEL_CHUNK_HEAD_UNUSED);
 
   return chunk_size;
 }
@@ -1858,15 +2450,21 @@ static int LoadLevel_CUS1(FILE *file, int chunk_size, struct LevelInfo *level)
 
 #if 1
     if (IS_CUSTOM_ELEMENT(element))
-      element_info[element].properties[EP_BITFIELD_BASE] = properties;
+      element_info[element].properties[EP_BITFIELD_BASE_NR] = properties;
     else
       Error(ERR_WARN, "invalid custom element number %d", element);
 #else
     if (IS_CUSTOM_ELEMENT(element))
-      Properties[element][EP_BITFIELD_BASE] = properties;
+      Properties[element][EP_BITFIELD_BASE_NR] = properties;
     else
       Error(ERR_WARN, "invalid custom element number %d", element);
 #endif
+
+#if 1
+    /* needed for older levels (see src/init.c for details) */
+    element_info[element].push_delay_fixed = -1;       /* initialize later */
+    element_info[element].push_delay_random = -1;      /* initialize later */
+#endif
   }
 
   return chunk_size;
@@ -1928,9 +2526,9 @@ static int LoadLevel_CUS3(FILE *file, int chunk_size, struct LevelInfo *level)
     ei->description[MAX_ELEMENT_NAME_LEN] = 0;
 
 #if 1
-    ei->properties[EP_BITFIELD_BASE] = getFile32BitBE(file);
+    ei->properties[EP_BITFIELD_BASE_NR] = getFile32BitBE(file);
 #else
-    Properties[element][EP_BITFIELD_BASE] = getFile32BitBE(file);
+    Properties[element][EP_BITFIELD_BASE_NR] = getFile32BitBE(file);
 #endif
 
     /* some free bytes for future properties and padding */
@@ -2019,9 +2617,9 @@ static int LoadLevel_CUS4(FILE *file, int chunk_size, struct LevelInfo *level)
   ei->description[MAX_ELEMENT_NAME_LEN] = 0;
 
 #if 1
-  ei->properties[EP_BITFIELD_BASE] = getFile32BitBE(file);
+  ei->properties[EP_BITFIELD_BASE_NR] = getFile32BitBE(file);
 #else
-  Properties[element][EP_BITFIELD_BASE] = getFile32BitBE(file);
+  Properties[element][EP_BITFIELD_BASE_NR] = getFile32BitBE(file);
 #endif
   ReadUnusedBytesFromFile(file, 4);    /* reserved for more base properties */
 
@@ -2188,8 +2786,8 @@ static int LoadLevel_GRP1(FILE *file, int chunk_size, struct LevelInfo *level)
   return chunk_size;
 }
 
-static int LoadLevel_MicroChunk(FILE *file, struct ElementFileConfig *config,
-                               int element)
+static int LoadLevel_MicroChunk(FILE *file, struct LevelFileConfigInfo *conf,
+                               int element, int real_element)
 {
   int micro_chunk_size = 0;
   int conf_type = getFile8Bit(file);
@@ -2204,20 +2802,20 @@ static int LoadLevel_MicroChunk(FILE *file, struct ElementFileConfig *config,
     int num_bytes = getFile16BitBE(file);
     byte *buffer = checked_malloc(num_bytes);
 
-#if 1
+#if 0
     printf("::: - found multi bytes\n");
 #endif
 
     ReadBytesFromFile(file, buffer, num_bytes);
 
-    for (i = 0; config[i].data_type != -1; i++)
+    for (i = 0; conf[i].data_type != -1; i++)
     {
-      if (config[i].element == element &&
-         config[i].conf_type == conf_type)
+      if (conf[i].element == element &&
+         conf[i].conf_type == conf_type)
       {
-       int data_type = config[i].data_type;
+       int data_type = conf[i].data_type;
        int num_entities = num_bytes / CONF_ENTITY_NUM_BYTES(data_type);
-       int max_num_entities = config[i].max_num_entities;
+       int max_num_entities = conf[i].max_num_entities;
 
        if (num_entities > max_num_entities)
        {
@@ -2228,13 +2826,21 @@ static int LoadLevel_MicroChunk(FILE *file, struct ElementFileConfig *config,
          num_entities = max_num_entities;
        }
 
-       *(int *)(config[i].num_entities) = num_entities;
+       *(int *)(conf[i].num_entities) = num_entities;
 
        element_found = TRUE;
 
-       if (data_type == TYPE_ELEMENT_LIST)
+       if (data_type == TYPE_STRING)
+       {
+         char *string = (char *)(conf[i].value);
+         int j;
+
+         for (j = 0; j < max_num_entities; j++)
+           string[j] = (j < num_entities ? buffer[j] : '\0');
+       }
+       else if (data_type == TYPE_ELEMENT_LIST)
        {
-         int *element_array = (int *)(config[i].value);
+         int *element_array = (int *)(conf[i].value);
          int j;
 
          for (j = 0; j < num_entities; j++)
@@ -2243,7 +2849,7 @@ static int LoadLevel_MicroChunk(FILE *file, struct ElementFileConfig *config,
        }
        else if (data_type == TYPE_CONTENT_LIST)
        {
-         struct Content *content= (struct Content *)(config[i].value);
+         struct Content *content= (struct Content *)(conf[i].value);
          int c, x, y;
 
          for (c = 0; c < num_entities; c++)
@@ -2269,21 +2875,21 @@ static int LoadLevel_MicroChunk(FILE *file, struct ElementFileConfig *config,
                 byte_mask == CONF_MASK_2_BYTE ? getFile16BitBE(file) :
                 byte_mask == CONF_MASK_4_BYTE ? getFile32BitBE(file) : 0);
 
-#if 1
+#if 0
     printf("::: - found single bytes\n");
 #endif
 
-    for (i = 0; config[i].data_type != -1; i++)
+    for (i = 0; conf[i].data_type != -1; i++)
     {
-      if (config[i].element == element &&
-         config[i].conf_type == conf_type)
+      if (conf[i].element == element &&
+         conf[i].conf_type == conf_type)
       {
-       int data_type = config[i].data_type;
+       int data_type = conf[i].data_type;
 
        if (data_type == TYPE_BOOLEAN)
-         *(boolean *)(config[i].value) = value;
+         *(boolean *)(conf[i].value) = value;
        else
-         *(int *)    (config[i].value) = value;
+         *(int *)    (conf[i].value) = value;
 
        element_found = TRUE;
 
@@ -2295,11 +2901,41 @@ static int LoadLevel_MicroChunk(FILE *file, struct ElementFileConfig *config,
   }
 
   if (!element_found)
-    Error(ERR_WARN, "cannot load micro chunk value for element %d", element);
+  {
+    char *error_conf_chunk_bytes =
+      (byte_mask == CONF_MASK_1_BYTE ? "CONF_VALUE_8_BIT" :
+       byte_mask == CONF_MASK_2_BYTE ? "CONF_VALUE_16_BIT" :
+       byte_mask == CONF_MASK_4_BYTE ? "CONF_VALUE_32_BIT" :"CONF_VALUE_BYTES");
+    int error_conf_chunk_token = conf_type & CONF_MASK_TOKEN;
+    int error_element = real_element;
+
+    Error(ERR_WARN, "cannot load micro chunk '%s(%d)' value for element %d ['%s']",
+         error_conf_chunk_bytes, error_conf_chunk_token,
+         error_element, EL_NAME(error_element));
+  }
 
   return micro_chunk_size;
 }
 
+static int LoadLevel_INFO(FILE *file, int chunk_size, struct LevelInfo *level)
+{
+  int real_chunk_size = 0;
+
+  li = *level;         /* copy level data into temporary buffer */
+
+  while (!feof(file))
+  {
+    real_chunk_size += LoadLevel_MicroChunk(file, chunk_config_INFO, -1, -1);
+
+    if (real_chunk_size >= chunk_size)
+      break;
+  }
+
+  *level = li;         /* copy temporary buffer back to level data */
+
+  return real_chunk_size;
+}
+
 static int LoadLevel_CONF(FILE *file, int chunk_size, struct LevelInfo *level)
 {
   int real_chunk_size = 0;
@@ -2313,7 +2949,8 @@ static int LoadLevel_CONF(FILE *file, int chunk_size, struct LevelInfo *level)
     int element = getFile16BitBE(file);
 #if 1
     real_chunk_size += 2;
-    real_chunk_size += LoadLevel_MicroChunk(file, element_conf, element);
+    real_chunk_size += LoadLevel_MicroChunk(file, chunk_config_CONF,
+                                           element, element);
 #else
     int conf_type = getFile8Bit(file);
     int byte_mask = conf_type & CONF_MASK_BYTES;
@@ -2333,14 +2970,14 @@ static int LoadLevel_CONF(FILE *file, int chunk_size, struct LevelInfo *level)
 
       ReadBytesFromFile(file, buffer, num_bytes);
 
-      for (i = 0; element_conf[i].data_type != -1; i++)
+      for (i = 0; chunk_config_CONF[i].data_type != -1; i++)
       {
-       if (element_conf[i].element == element &&
-           element_conf[i].conf_type == conf_type)
+       if (chunk_config_CONF[i].element == element &&
+           chunk_config_CONF[i].conf_type == conf_type)
        {
-         int data_type = element_conf[i].data_type;
+         int data_type = chunk_config_CONF[i].data_type;
          int num_entities = num_bytes / CONF_ENTITY_NUM_BYTES(data_type);
-         int max_num_entities = element_conf[i].max_num_entities;
+         int max_num_entities = chunk_config_CONF[i].max_num_entities;
 
          if (num_entities > max_num_entities)
          {
@@ -2351,13 +2988,13 @@ static int LoadLevel_CONF(FILE *file, int chunk_size, struct LevelInfo *level)
            num_entities = max_num_entities;
          }
 
-         *(int *)(element_conf[i].num_entities) = num_entities;
+         *(int *)(chunk_config_CONF[i].num_entities) = num_entities;
 
          element_found = TRUE;
 
          if (data_type == TYPE_ELEMENT_LIST)
          {
-           int *element_array = (int *)(element_conf[i].value);
+           int *element_array = (int *)(chunk_config_CONF[i].value);
            int j;
 
            for (j = 0; j < num_entities; j++)
@@ -2366,7 +3003,7 @@ static int LoadLevel_CONF(FILE *file, int chunk_size, struct LevelInfo *level)
          }
          else if (data_type == TYPE_CONTENT_LIST)
          {
-           struct Content *content= (struct Content *)(element_conf[i].value);
+           struct Content *content= (struct Content *)(chunk_config_CONF[i].value);
            int c, x, y;
 
            for (c = 0; c < num_entities; c++)
@@ -2392,17 +3029,17 @@ static int LoadLevel_CONF(FILE *file, int chunk_size, struct LevelInfo *level)
                   byte_mask == CONF_MASK_2_BYTE ? getFile16BitBE(file) :
                   byte_mask == CONF_MASK_4_BYTE ? getFile32BitBE(file) : 0);
 
-      for (i = 0; element_conf[i].data_type != -1; i++)
+      for (i = 0; chunk_config_CONF[i].data_type != -1; i++)
       {
-       if (element_conf[i].element == element &&
-           element_conf[i].conf_type == conf_type)
+       if (chunk_config_CONF[i].element == element &&
+           chunk_config_CONF[i].conf_type == conf_type)
        {
-         int data_type = element_conf[i].data_type;
+         int data_type = chunk_config_CONF[i].data_type;
 
          if (data_type == TYPE_BOOLEAN)
-           *(boolean *)(element_conf[i].value) = value;
+           *(boolean *)(chunk_config_CONF[i].value) = value;
          else
-           *(int *)    (element_conf[i].value) = value;
+           *(int *)    (chunk_config_CONF[i].value) = value;
 
          element_found = TRUE;
 
@@ -2442,8 +3079,9 @@ static int LoadLevel_CUSX(FILE *file, int chunk_size, struct LevelInfo *level)
   int element = getFile16BitBE(file);
   int real_chunk_size = 2;
   struct ElementInfo *ei = &element_info[element];
+  int i;
 
-#if 1
+#if 0
   printf("::: CUSX: loading element '%s' ...\n", EL_NAME(element));
 #endif
 
@@ -2453,9 +3091,10 @@ static int LoadLevel_CUSX(FILE *file, int chunk_size, struct LevelInfo *level)
 
   while (!feof(file))
   {
-    real_chunk_size += LoadLevel_MicroChunk(file, custom_element_conf, -1);
+    real_chunk_size += LoadLevel_MicroChunk(file, chunk_config_CUSX_base,
+                                           -1, element);
 
-#if 1
+#if 0
     printf("::: - real_chunk_size now %d\n", real_chunk_size);
 #endif
 
@@ -2474,36 +3113,35 @@ static int LoadLevel_CUSX(FILE *file, int chunk_size, struct LevelInfo *level)
          EL_NAME(element));
 
     ei->num_change_pages = 1;
+
     setElementChangePages(ei, 1);
+    setElementChangeInfoToDefaults(ei->change);
 
     return real_chunk_size;
   }
 
+  /* initialize number of change pages stored for this custom element */
   setElementChangePages(ei, ei->num_change_pages);
+  for (i = 0; i < ei->num_change_pages; i++)
+    setElementChangeInfoToDefaults(&ei->change_page[i]);
 
+  /* start with reading properties for the first change page */
   xx_current_change_page = 0;
 
-  xx_event_bits_0_31 = 0;
-  xx_event_bits_32_63 = 0;
-
   while (!feof(file))
   {
     struct ElementChangeInfo *change = &ei->change_page[xx_current_change_page];
-    int i;
 
     xx_change = *change;       /* copy change data into temporary buffer */
 
-    real_chunk_size += LoadLevel_MicroChunk(file,custom_element_change_conf,-1);
+    resetEventBits();          /* reset bits; change page might have changed */
 
-    *change = xx_change;
+    real_chunk_size += LoadLevel_MicroChunk(file, chunk_config_CUSX_change,
+                                           -1, element);
 
-    for (i = 0; i < NUM_CHANGE_EVENTS; i++)
-      if ((i <  32 && xx_event_bits_0_31  & (1 << i)) ||
-         (i >= 32 && xx_event_bits_32_63 & (1 << (i - 32))))
-       change->has_event[i] = TRUE;
+    *change = xx_change;
 
-    xx_event_bits_0_31 = 0;
-    xx_event_bits_32_63 = 0;
+    setEventFlagsFromEventBits(change);
 
     if (real_chunk_size >= chunk_size)
       break;
@@ -2524,7 +3162,8 @@ static int LoadLevel_GRPX(FILE *file, int chunk_size, struct LevelInfo *level)
 
   while (!feof(file))
   {
-    real_chunk_size += LoadLevel_MicroChunk(file, group_element_conf, -1);
+    real_chunk_size += LoadLevel_MicroChunk(file, chunk_config_GRPX,
+                                           -1, element);
 
     if (real_chunk_size >= chunk_size)
       break;
@@ -2602,7 +3241,7 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level,
   if (level->file_version < FILE_VERSION_1_2)
   {
     /* level files from versions before 1.2.0 without chunk structure */
-    LoadLevel_HEAD(file, LEVEL_HEADER_SIZE,             level);
+    LoadLevel_HEAD(file, LEVEL_CHUNK_HEAD_SIZE,         level);
     LoadLevel_BODY(file, level->fieldx * level->fieldy, level);
   }
   else
@@ -2615,8 +3254,8 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level,
     }
     chunk_info[] =
     {
-      { "VERS", FILE_VERS_CHUNK_SIZE,  LoadLevel_VERS },
-      { "HEAD", LEVEL_HEADER_SIZE,     LoadLevel_HEAD },
+      { "VERS", LEVEL_CHUNK_VERS_SIZE, LoadLevel_VERS },
+      { "HEAD", LEVEL_CHUNK_HEAD_SIZE, LoadLevel_HEAD },
       { "AUTH", MAX_LEVEL_AUTHOR_LEN,  LoadLevel_AUTH },
       { "BODY", -1,                    LoadLevel_BODY },
       { "CONT", -1,                    LoadLevel_CONT },
@@ -2627,11 +3266,10 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level,
       { "CUS3", -1,                    LoadLevel_CUS3 },
       { "CUS4", -1,                    LoadLevel_CUS4 },
       { "GRP1", -1,                    LoadLevel_GRP1 },
+      { "INFO", -1,                    LoadLevel_INFO },
       { "CONF", -1,                    LoadLevel_CONF },
-#if 1
       { "CUSX", -1,                    LoadLevel_CUSX },
       { "GRPX", -1,                    LoadLevel_GRPX },
-#endif
 
       {  NULL,  0,                     NULL }
     };
@@ -4325,7 +4963,7 @@ static void SaveLevel_HEAD(FILE *file, struct LevelInfo *level)
 
   putFile8Bit(file, level->game_engine_type);
 
-  WriteUnusedBytesToFile(file, LEVEL_HEADER_UNUSED);
+  WriteUnusedBytesToFile(file, LEVEL_CHUNK_HEAD_UNUSED);
 }
 
 static void SaveLevel_AUTH(FILE *file, struct LevelInfo *level)
@@ -4336,6 +4974,16 @@ static void SaveLevel_AUTH(FILE *file, struct LevelInfo *level)
     putFile8Bit(file, level->author[i]);
 }
 
+#if 0
+static void SaveLevel_TITL(FILE *file, struct LevelInfo *level)
+{
+  int i;
+
+  for (i = 0; i < MAX_LEVEL_NAME_LEN; i++)
+    putFile8Bit(file, level->name[i]);
+}
+#endif
+
 static void SaveLevel_BODY(FILE *file, struct LevelInfo *level)
 {
   int x, y;
@@ -4368,6 +5016,7 @@ static void SaveLevel_CONT(FILE *file, struct LevelInfo *level)
 }
 #endif
 
+#if 0
 static void SaveLevel_CNT2(FILE *file, struct LevelInfo *level, int element)
 {
   int i, x, y;
@@ -4418,6 +5067,7 @@ static void SaveLevel_CNT2(FILE *file, struct LevelInfo *level, int element)
       for (x = 0; x < 3; x++)
        putFile16BitBE(file, content_array[i][x][y]);
 }
+#endif
 
 static void SaveLevel_CNT3(FILE *file, struct LevelInfo *level, int element)
 {
@@ -4451,23 +5101,23 @@ static void SaveLevel_CUS1(FILE *file, struct LevelInfo *level,
 #if 1
     struct ElementInfo *ei = &element_info[element];
 
-    if (ei->properties[EP_BITFIELD_BASE] != EP_BITMASK_DEFAULT)
+    if (ei->properties[EP_BITFIELD_BASE_NR] != EP_BITMASK_DEFAULT)
     {
       if (check < num_changed_custom_elements)
       {
        putFile16BitBE(file, element);
-       putFile32BitBE(file, ei->properties[EP_BITFIELD_BASE]);
+       putFile32BitBE(file, ei->properties[EP_BITFIELD_BASE_NR]);
       }
 
       check++;
     }
 #else
-    if (Properties[element][EP_BITFIELD_BASE] != EP_BITMASK_DEFAULT)
+    if (Properties[element][EP_BITFIELD_BASE_NR] != EP_BITMASK_DEFAULT)
     {
       if (check < num_changed_custom_elements)
       {
        putFile16BitBE(file, element);
-       putFile32BitBE(file, Properties[element][EP_BITFIELD_BASE]);
+       putFile32BitBE(file, Properties[element][EP_BITFIELD_BASE_NR]);
       }
 
       check++;
@@ -4532,9 +5182,9 @@ static void SaveLevel_CUS3(FILE *file, struct LevelInfo *level,
          putFile8Bit(file, ei->description[j]);
 
 #if 1
-       putFile32BitBE(file, ei->properties[EP_BITFIELD_BASE]);
+       putFile32BitBE(file, ei->properties[EP_BITFIELD_BASE_NR]);
 #else
-       putFile32BitBE(file, Properties[element][EP_BITFIELD_BASE]);
+       putFile32BitBE(file, Properties[element][EP_BITFIELD_BASE_NR]);
 #endif
 
        /* some free bytes for future properties and padding */
@@ -4596,6 +5246,7 @@ static void SaveLevel_CUS3(FILE *file, struct LevelInfo *level,
 }
 #endif
 
+#if 0
 static void SaveLevel_CUS4(FILE *file, struct LevelInfo *level, int element)
 {
   struct ElementInfo *ei = &element_info[element];
@@ -4609,9 +5260,9 @@ static void SaveLevel_CUS4(FILE *file, struct LevelInfo *level, int element)
     putFile8Bit(file, ei->description[i]);
 
 #if 1
-  putFile32BitBE(file, ei->properties[EP_BITFIELD_BASE]);
+  putFile32BitBE(file, ei->properties[EP_BITFIELD_BASE_NR]);
 #else
-  putFile32BitBE(file, Properties[element][EP_BITFIELD_BASE]);
+  putFile32BitBE(file, Properties[element][EP_BITFIELD_BASE_NR]);
 #endif
   WriteUnusedBytesToFile(file, 4);     /* reserved for more base properties */
 
@@ -4716,7 +5367,9 @@ static void SaveLevel_CUS4(FILE *file, struct LevelInfo *level, int element)
     putFile8Bit(file, event_bits);
   }
 }
+#endif
 
+#if 0
 static void SaveLevel_GRP1(FILE *file, struct LevelInfo *level, int element)
 {
   struct ElementInfo *ei = &element_info[element];
@@ -4741,9 +5394,130 @@ static void SaveLevel_GRP1(FILE *file, struct LevelInfo *level, int element)
   for (i = 0; i < MAX_ELEMENTS_IN_GROUP; i++)
     putFile16BitBE(file, group->element[i]);
 }
+#endif
+
+static int SaveLevel_MicroChunk(FILE *file, struct LevelFileConfigInfo *entry,
+                               boolean write_element)
+{
+  int data_type = entry->data_type;
+  int conf_type = entry->conf_type;
+  int byte_mask = conf_type & CONF_MASK_BYTES;
+  int element = entry->element;
+  int default_value = entry->default_value;
+  int num_bytes = 0;
+  boolean modified = FALSE;
+
+  if (byte_mask != CONF_MASK_MULTI_BYTES)
+  {
+    void *value_ptr = entry->value;
+    int value = (data_type == TYPE_BOOLEAN ? *(boolean *)value_ptr :
+                *(int *)value_ptr);
+
+    /* check if any settings have been modified before saving them */
+    if (value != default_value)
+      modified = TRUE;
+
+    if (!modified)             /* do not save unmodified default settings */
+      return 0;
+
+    if (write_element)
+      num_bytes += putFile16BitBE(file, element);
+
+    num_bytes += putFile8Bit(file, conf_type);
+    num_bytes += (byte_mask == CONF_MASK_1_BYTE ? putFile8Bit   (file, value) :
+                 byte_mask == CONF_MASK_2_BYTE ? putFile16BitBE(file, value) :
+                 byte_mask == CONF_MASK_4_BYTE ? putFile32BitBE(file, value) :
+                 0);
+
+    return num_bytes;
+  }
+  else if (data_type == TYPE_STRING)
+  {
+    char *default_string = entry->default_string;
+    char *string = (char *)(entry->value);
+    int string_length = strlen(string);
+    int i;
+
+    /* check if any settings have been modified before saving them */
+    if (!strEqual(string, default_string))
+      modified = TRUE;
+
+    if (!modified)             /* do not save unmodified default settings */
+      return 0;
+
+    if (write_element)
+      num_bytes += putFile16BitBE(file, element);
+
+    num_bytes += putFile8Bit(file, conf_type);
+    num_bytes += putFile16BitBE(file, string_length);
+
+    for (i = 0; i < string_length; i++)
+      num_bytes += putFile8Bit(file, string[i]);
+
+    return num_bytes;
+  }
+  else if (data_type == TYPE_ELEMENT_LIST)
+  {
+    int *element_array = (int *)(entry->value);
+    int num_elements = *(int *)(entry->num_entities);
+    int i;
+
+    /* check if any settings have been modified before saving them */
+    for (i = 0; i < num_elements; i++)
+      if (element_array[i] != default_value)
+       modified = TRUE;
+
+    if (!modified)             /* do not save unmodified default settings */
+      return 0;
+
+    if (write_element)
+      num_bytes += putFile16BitBE(file, element);
+
+    num_bytes += putFile8Bit(file, conf_type);
+    num_bytes += putFile16BitBE(file, num_elements * CONF_ELEMENT_NUM_BYTES);
+
+    for (i = 0; i < num_elements; i++)
+      num_bytes += putFile16BitBE(file, element_array[i]);
+
+    return num_bytes;
+  }
+  else if (data_type == TYPE_CONTENT_LIST)
+  {
+    struct Content *content = (struct Content *)(entry->value);
+    int num_contents = *(int *)(entry->num_entities);
+    int i, x, y;
+
+    /* check if any settings have been modified before saving them */
+    for (i = 0; i < num_contents; i++)
+      for (y = 0; y < 3; y++)
+       for (x = 0; x < 3; x++)
+         if (content[i].e[x][y] != default_value)
+           modified = TRUE;
+
+    if (!modified)             /* do not save unmodified default settings */
+      return 0;
+
+    if (write_element)
+      num_bytes += putFile16BitBE(file, element);
+
+    num_bytes += putFile8Bit(file, conf_type);
+    num_bytes += putFile16BitBE(file, num_contents * CONF_CONTENT_NUM_BYTES);
+
+    for (i = 0; i < num_contents; i++)
+      for (y = 0; y < 3; y++)
+       for (x = 0; x < 3; x++)
+         num_bytes += putFile16BitBE(file, content[i].e[x][y]);
+
+    return num_bytes;
+  }
+
+  return 0;
+}
+
+#if 0
 
 static int SaveLevel_MicroChunk_SingleValue(FILE *file,
-                                           struct ElementFileConfig *entry)
+                                           struct LevelFileConfigInfo *entry)
 {
   int default_value = entry->default_value;
   int element = entry->element;
@@ -4781,7 +5555,7 @@ static int SaveLevel_MicroChunk_SingleValue(FILE *file,
 }
 
 static int SaveLevel_MicroChunk_ElementList(FILE *file,
-                                           struct ElementFileConfig *entry)
+                                           struct LevelFileConfigInfo *entry)
 {
   int *element_array = (int *)(entry->value);
   int num_elements = *(int *)(entry->num_entities);
@@ -4813,7 +5587,7 @@ static int SaveLevel_MicroChunk_ElementList(FILE *file,
 }
 
 static int SaveLevel_MicroChunk_ContentList(FILE *file,
-                                           struct ElementFileConfig *entry)
+                                           struct LevelFileConfigInfo *entry)
 {
   struct Content *content = (struct Content *)(entry->value);
   int num_contents = *(int *)(entry->num_entities);
@@ -4848,6 +5622,21 @@ static int SaveLevel_MicroChunk_ContentList(FILE *file,
   return num_bytes;
 }
 
+#endif
+
+static int SaveLevel_INFO(FILE *file, struct LevelInfo *level)
+{
+  int chunk_size = 0;
+  int i;
+
+  li = *level;         /* copy level data into temporary buffer */
+
+  for (i = 0; chunk_config_INFO[i].data_type != -1; i++)
+    chunk_size += SaveLevel_MicroChunk(file, &chunk_config_INFO[i], FALSE);
+
+  return chunk_size;
+}
+
 static int SaveLevel_CONF(FILE *file, struct LevelInfo *level)
 {
   int chunk_size = 0;
@@ -4855,19 +5644,23 @@ static int SaveLevel_CONF(FILE *file, struct LevelInfo *level)
 
   li = *level;         /* copy level data into temporary buffer */
 
-  for (i = 0; element_conf[i].data_type != -1; i++)
+  for (i = 0; chunk_config_CONF[i].data_type != -1; i++)
   {
-    struct ElementFileConfig *config = &element_conf[i];
-    int data_type = config->data_type;
-    int conf_type = config->conf_type;
+#if 1
+    chunk_size += SaveLevel_MicroChunk(file, &chunk_config_CONF[i], TRUE);
+#else
+    struct LevelFileConfigInfo *conf = &chunk_config_CONF[i];
+    int data_type = conf->data_type;
+    int conf_type = conf->conf_type;
     int byte_mask = conf_type & CONF_MASK_BYTES;
 
     if (byte_mask != CONF_MASK_MULTI_BYTES)
-      chunk_size += SaveLevel_MicroChunk_SingleValue(file, config);
+      chunk_size += SaveLevel_MicroChunk_SingleValue(file, conf);
     else if (data_type == TYPE_ELEMENT_LIST)
-      chunk_size += SaveLevel_MicroChunk_ElementList(file, config);
+      chunk_size += SaveLevel_MicroChunk_ElementList(file, conf);
     else if (data_type == TYPE_CONTENT_LIST)
-      chunk_size += SaveLevel_MicroChunk_ContentList(file, config);
+      chunk_size += SaveLevel_MicroChunk_ContentList(file, conf);
+#endif
   }
 
   return chunk_size;
@@ -4877,33 +5670,24 @@ static int SaveLevel_CUSX(FILE *file, struct LevelInfo *level, int element)
 {
   struct ElementInfo *ei = &element_info[element];
   int chunk_size = 0;
-  int i;
+  int i, j;
 
   chunk_size += putFile16BitBE(file, element);
 
   xx_ei = *ei;         /* copy element data into temporary buffer */
 
-  xx_num_description_bytes = MAX_ELEMENT_NAME_LEN;
+  /* set default description string for this specific element */
+  strcpy(xx_default_description, getDefaultElementDescription(ei));
+
+  /* set (fixed) number of content areas (may have been overwritten earlier) */
   xx_num_contents = 1;
 
 #if 0
   printf("::: - element config\n");
 #endif
 
-  for (i = 0; custom_element_conf[i].data_type != -1; i++)
-  {
-    struct ElementFileConfig *config = &custom_element_conf[i];
-    int data_type = config->data_type;
-    int conf_type = config->conf_type;
-    int byte_mask = conf_type & CONF_MASK_BYTES;
-
-    if (byte_mask != CONF_MASK_MULTI_BYTES)
-      chunk_size += SaveLevel_MicroChunk_SingleValue(file, config);
-    else if (data_type == TYPE_ELEMENT_LIST)
-      chunk_size += SaveLevel_MicroChunk_ElementList(file, config);
-    else if (data_type == TYPE_CONTENT_LIST)
-      chunk_size += SaveLevel_MicroChunk_ContentList(file, config);
-  }
+  for (i = 0; chunk_config_CUSX_base[i].data_type != -1; i++)
+    chunk_size += SaveLevel_MicroChunk(file, &chunk_config_CUSX_base[i], FALSE);
 
 #if 0
   printf("::: - change pages\n");
@@ -4924,34 +5708,18 @@ static int SaveLevel_CUSX(FILE *file, struct LevelInfo *level, int element)
           i, xx_change.action_arg);
 #endif
 
-    xx_event_bits_0_31 = 0;
-    xx_event_bits_32_63 = 0;
-
-    for (i = 0; i < NUM_CHANGE_EVENTS; i++)
-    {
-      if (change->has_event[i])
-      {
-       if (i < 32)
-         xx_event_bits_0_31 |= (1 << i);
-       else
-         xx_event_bits_32_63 |= (1 << (i - 32));
-      }
-    }
+    resetEventBits();
+    setEventBitsFromEventFlags(change);
 
-    for (i = 0; custom_element_change_conf[i].data_type != -1; i++)
-    {
-      struct ElementFileConfig *config = &custom_element_change_conf[i];
-      int data_type = config->data_type;
-      int conf_type = config->conf_type;
-      int byte_mask = conf_type & CONF_MASK_BYTES;
+    for (j = 0; chunk_config_CUSX_change[j].data_type != -1; j++)
+      chunk_size += SaveLevel_MicroChunk(file, &chunk_config_CUSX_change[j],
+                                        FALSE);
 
-      if (byte_mask != CONF_MASK_MULTI_BYTES)
-       chunk_size += SaveLevel_MicroChunk_SingleValue(file, config);
-      else if (data_type == TYPE_ELEMENT_LIST)
-       chunk_size += SaveLevel_MicroChunk_ElementList(file, config);
-      else if (data_type == TYPE_CONTENT_LIST)
-       chunk_size += SaveLevel_MicroChunk_ContentList(file, config);
-    }
+#if 0
+    if (element == EL_CUSTOM_START)
+      printf("::: - saving change page %d / %d (%d bytes)\n",
+            i, ei->num_change_pages, chunk_size);
+#endif
   }
 
   return chunk_size;
@@ -4969,30 +5737,18 @@ static int SaveLevel_GRPX(FILE *file, struct LevelInfo *level, int element)
   xx_ei = *ei;         /* copy element data into temporary buffer */
   xx_group = *group;   /* copy group data into temporary buffer */
 
-  xx_num_description_bytes = MAX_ELEMENT_NAME_LEN;
-  xx_num_contents = 1;
-
-  for (i = 0; group_element_conf[i].data_type != -1; i++)
-  {
-    struct ElementFileConfig *config = &group_element_conf[i];
-    int data_type = config->data_type;
-    int conf_type = config->conf_type;
-    int byte_mask = conf_type & CONF_MASK_BYTES;
+  /* set default description string for this specific element */
+  strcpy(xx_default_description, getDefaultElementDescription(ei));
 
-    if (byte_mask != CONF_MASK_MULTI_BYTES)
-      chunk_size += SaveLevel_MicroChunk_SingleValue(file, config);
-    else if (data_type == TYPE_ELEMENT_LIST)
-      chunk_size += SaveLevel_MicroChunk_ElementList(file, config);
-    else if (data_type == TYPE_CONTENT_LIST)
-      chunk_size += SaveLevel_MicroChunk_ContentList(file, config);
-  }
+  for (i = 0; chunk_config_GRPX[i].data_type != -1; i++)
+    chunk_size += SaveLevel_MicroChunk(file, &chunk_config_GRPX[i], FALSE);
 
   return chunk_size;
 }
 
 static void SaveLevelFromFilename(struct LevelInfo *level, char *filename)
 {
-  int body_chunk_size, conf_chunk_size;
+  int body_chunk_size, info_chunk_size, conf_chunk_size;
   int i, x, y;
   FILE *file;
 
@@ -5032,10 +5788,10 @@ static void SaveLevelFromFilename(struct LevelInfo *level, char *filename)
   putFileChunkBE(file, "RND1", CHUNK_SIZE_UNDEFINED);
   putFileChunkBE(file, "CAVE", CHUNK_SIZE_NONE);
 
-  putFileChunkBE(file, "VERS", FILE_VERS_CHUNK_SIZE);
+  putFileChunkBE(file, "VERS", LEVEL_CHUNK_VERS_SIZE);
   SaveLevel_VERS(file, level);
 
-  putFileChunkBE(file, "HEAD", LEVEL_HEADER_SIZE);
+  putFileChunkBE(file, "HEAD", LEVEL_CHUNK_HEAD_SIZE);
   SaveLevel_HEAD(file, level);
 
   putFileChunkBE(file, "AUTH", MAX_LEVEL_AUTHOR_LEN);
@@ -5044,6 +5800,7 @@ static void SaveLevelFromFilename(struct LevelInfo *level, char *filename)
   putFileChunkBE(file, "BODY", body_chunk_size);
   SaveLevel_BODY(file, level);
 
+#if 0
   if (level->encoding_16bit_yamyam ||
       level->num_yamyam_contents != STD_ELEMENT_CONTENTS)
   {
@@ -5056,6 +5813,7 @@ static void SaveLevelFromFilename(struct LevelInfo *level, char *filename)
     putFileChunkBE(file, "CNT2", LEVEL_CHUNK_CNT2_SIZE);
     SaveLevel_CNT2(file, level, EL_BD_AMOEBA);
   }
+#endif
 
   /* check for envelope content */
   for (i = 0; i < 4; i++)
@@ -5072,7 +5830,7 @@ static void SaveLevelFromFilename(struct LevelInfo *level, char *filename)
   /* if not using template level, check for non-default custom/group elements */
   if (!level->use_custom_template)
   {
-#if 1
+#if 0
     for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++)
     {
       int element = EL_CUSTOM_START + i;
@@ -5085,9 +5843,7 @@ static void SaveLevelFromFilename(struct LevelInfo *level, char *filename)
        SaveLevel_CUS4(file, level, element);
       }
     }
-#endif
 
-#if 1
     for (i = 0; i < NUM_GROUP_ELEMENTS; i++)
     {
       int element = EL_GROUP_START + i;
@@ -5101,6 +5857,15 @@ static void SaveLevelFromFilename(struct LevelInfo *level, char *filename)
 #endif
   }
 
+  info_chunk_size = SaveLevel_INFO(NULL, level);
+
+  /* check if non-default level settings need to be saved */
+  if (info_chunk_size > 0)
+  {
+    putFileChunkBE(file, "INFO", info_chunk_size);
+    SaveLevel_INFO(file, level);
+  }
+
   conf_chunk_size = SaveLevel_CONF(NULL, level);
 
   /* check if non-default element settings need to be saved */
@@ -5127,22 +5892,15 @@ static void SaveLevelFromFilename(struct LevelInfo *level, char *filename)
       /* check if non-default element settings need to be saved */
       if (cusx_chunk_size > cusx_chunk_size_no_changes)
       {
-#if 1
+#if 0
        printf("::: SAVING CE %d\n", i + 1);
 #endif
 
        putFileChunkBE(file, "CUSX", cusx_chunk_size);
        SaveLevel_CUSX(file, level, element);
       }
-
-#if 0
-      if (i == 1)
-       break;
-#endif
     }
-#endif
 
-#if 1
     for (i = 0; i < NUM_GROUP_ELEMENTS; i++)
     {
       int element = EL_GROUP_START + i;
@@ -5151,18 +5909,13 @@ static void SaveLevelFromFilename(struct LevelInfo *level, char *filename)
       /* check if non-default element settings need to be saved */
       if (grpx_chunk_size > grpx_chunk_size_no_changes)
       {
-#if 1
+#if 0
        printf("::: SAVING GE %d\n", i + 1);
 #endif
 
        putFileChunkBE(file, "GRPX", grpx_chunk_size);
        SaveLevel_GRPX(file, level, element);
       }
-
-#if 0
-      if (i == 1)
-       break;
-#endif
     }
 #endif
   }
@@ -5292,7 +6045,7 @@ static int LoadTape_HEAD(FILE *file, int chunk_size, struct TapeInfo *tape)
       }
     }
 
-    ReadUnusedBytesFromFile(file, TAPE_HEADER_UNUSED);
+    ReadUnusedBytesFromFile(file, TAPE_CHUNK_HEAD_UNUSED);
 
     engine_version = getFileVersion(file);
     if (engine_version > 0)
@@ -5472,8 +6225,8 @@ void LoadTapeFromFilename(char *filename)
   if (tape.file_version < FILE_VERSION_1_2)
   {
     /* tape files from versions before 1.2.0 without chunk structure */
-    LoadTape_HEAD(file, TAPE_HEADER_SIZE, &tape);
-    LoadTape_BODY(file, 2 * tape.length,  &tape);
+    LoadTape_HEAD(file, TAPE_CHUNK_HEAD_SIZE, &tape);
+    LoadTape_BODY(file, 2 * tape.length,      &tape);
   }
   else
   {
@@ -5485,8 +6238,8 @@ void LoadTapeFromFilename(char *filename)
     }
     chunk_info[] =
     {
-      { "VERS", FILE_VERS_CHUNK_SIZE,  LoadTape_VERS },
-      { "HEAD", TAPE_HEADER_SIZE,      LoadTape_HEAD },
+      { "VERS", TAPE_CHUNK_VERS_SIZE,  LoadTape_VERS },
+      { "HEAD", TAPE_CHUNK_HEAD_SIZE,  LoadTape_HEAD },
       { "INFO", -1,                    LoadTape_INFO },
       { "BODY", -1,                    LoadTape_BODY },
       {  NULL,  0,                     NULL }
@@ -5578,7 +6331,7 @@ static void SaveTape_HEAD(FILE *file, struct TapeInfo *tape)
   putFile8Bit(file, store_participating_players);
 
   /* unused bytes not at the end here for 4-byte alignment of engine_version */
-  WriteUnusedBytesToFile(file, TAPE_HEADER_UNUSED);
+  WriteUnusedBytesToFile(file, TAPE_CHUNK_HEAD_UNUSED);
 
   putFileVersion(file, tape->engine_version);
 }
@@ -5650,10 +6403,10 @@ void SaveTape(int nr)
   putFileChunkBE(file, "RND1", CHUNK_SIZE_UNDEFINED);
   putFileChunkBE(file, "TAPE", CHUNK_SIZE_NONE);
 
-  putFileChunkBE(file, "VERS", FILE_VERS_CHUNK_SIZE);
+  putFileChunkBE(file, "VERS", TAPE_CHUNK_VERS_SIZE);
   SaveTape_VERS(file, &tape);
 
-  putFileChunkBE(file, "HEAD", TAPE_HEADER_SIZE);
+  putFileChunkBE(file, "HEAD", TAPE_CHUNK_HEAD_SIZE);
   SaveTape_HEAD(file, &tape);
 
   putFileChunkBE(file, "INFO", info_chunk_size);