rnd-20030707-1-src
[rocksndiamonds.git] / src / files.c
index ebdd7afd2ed5970fa84aea0addce539a7511ed58..8fe110f24254cece6bd2d43f606229d665c35da3 100644 (file)
@@ -30,8 +30,8 @@
 #define LEVEL_HEADER_UNUSED    13      /* 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_CPART_CUS3_SIZE  102     /* size of CUS3 chunk part    */
-#define LEVEL_CPART_CUS3_UNUSED        16      /* unused CUS3 bytes / part   */
+#define LEVEL_CPART_CUS3_SIZE  134     /* size of CUS3 chunk part    */
+#define LEVEL_CPART_CUS3_UNUSED        15      /* unused CUS3 bytes / part   */
 #define TAPE_HEADER_SIZE       20      /* size of tape file header   */
 #define TAPE_HEADER_UNUSED     3       /* unused tape header bytes   */
 
@@ -105,6 +105,15 @@ static void setLevelInfoToDefaults()
   {
     int element = EL_CUSTOM_START + i;
 
+    for(j=0; j<MAX_ELEMENT_NAME_LEN + 1; j++)
+      element_info[element].description[j] = '\0';
+    if (element_info[element].custom_description != NULL)
+      strncpy(element_info[element].description,
+             element_info[element].custom_description, MAX_ELEMENT_NAME_LEN);
+    else
+      strcpy(element_info[element].description,
+            element_info[element].editor_description);
+
     element_info[element].use_gfx_element = FALSE;
     element_info[element].gfx_element = EL_EMPTY_SPACE;
 
@@ -120,6 +129,8 @@ static void setLevelInfoToDefaults()
     element_info[element].move_direction_initial = MV_NO_MOVING;
     element_info[element].move_stepsize = TILEX / 8;
 
+    element_info[element].slippery_type = SLIPPERY_ANY_RANDOM;
+
     for(x=0; x<3; x++)
       for(y=0; y<3; y++)
        element_info[element].content[x][y] = EL_EMPTY_SPACE;
@@ -144,6 +155,20 @@ static void setLevelInfoToDefaults()
       for(y=0; y<3; y++)
        element_info[element].change.content[x][y] = EL_EMPTY_SPACE;
 
+    element_info[element].access_type = 0;
+    element_info[element].access_layer = 0;
+    element_info[element].walk_to_action = 0;
+    element_info[element].smash_targets = 0;
+    element_info[element].deadliness = 0;
+    element_info[element].consistency = 0;
+    element_info[element].change_player_action = 0;
+    element_info[element].change_collide_action = 0;
+    element_info[element].change_other_action = 0;
+
+    element_info[element].can_explode_by_fire = FALSE;
+    element_info[element].can_explode_smashed = FALSE;
+    element_info[element].can_explode_impact = FALSE;
+
     /* start with no properties at all */
     for (j=0; j < NUM_EP_BITFIELDS; j++)
       Properties[element][j] = EP_BITMASK_DEFAULT;
@@ -426,7 +451,7 @@ static int LoadLevel_CUS3(FILE *file, int chunk_size, struct LevelInfo *level)
 {
   int num_changed_custom_elements = getFile16BitBE(file);
   int chunk_size_expected = LEVEL_CHUNK_CUS3_SIZE(num_changed_custom_elements);
-  int i, x, y;
+  int i, j, x, y;
 
   if (chunk_size_expected != chunk_size)
   {
@@ -445,6 +470,10 @@ static int LoadLevel_CUS3(FILE *file, int chunk_size, struct LevelInfo *level)
       element = EL_DEFAULT;    /* dummy element used for artwork config */
     }
 
+    for(j=0; j<MAX_ELEMENT_NAME_LEN; j++)
+      element_info[element].description[j] = getFile8Bit(file);
+    element_info[element].description[MAX_ELEMENT_NAME_LEN] = 0;
+
     Properties[element][EP_BITFIELD_BASE] = getFile32BitBE(file);
 
     /* some free bytes for future properties and padding */
@@ -496,6 +525,8 @@ static int LoadLevel_CUS3(FILE *file, int chunk_size, struct LevelInfo *level)
        element_info[element].change.content[x][y] =
          checkLevelElement(getFile16BitBE(file));
 
+    element_info[element].slippery_type = getFile8Bit(file);
+
     /* some free bytes for future properties and padding */
     ReadUnusedBytesFromFile(file, LEVEL_CPART_CUS3_UNUSED);
   }
@@ -911,7 +942,7 @@ static void SaveLevel_CUS2(FILE *file, struct LevelInfo *level,
 static void SaveLevel_CUS3(FILE *file, struct LevelInfo *level,
                           int num_changed_custom_elements)
 {
-  int i, x, y, check = 0;
+  int i, j, x, y, check = 0;
 
   putFile16BitBE(file, num_changed_custom_elements);
 
@@ -924,6 +955,10 @@ static void SaveLevel_CUS3(FILE *file, struct LevelInfo *level,
       if (check < num_changed_custom_elements)
       {
        putFile16BitBE(file, element);
+
+       for(j=0; j<MAX_ELEMENT_NAME_LEN; j++)
+         putFile8Bit(file, element_info[element].description[j]);
+
        putFile32BitBE(file, Properties[element][EP_BITFIELD_BASE]);
 
        /* some free bytes for future properties and padding */
@@ -970,6 +1005,8 @@ static void SaveLevel_CUS3(FILE *file, struct LevelInfo *level,
          for(x=0; x<3; x++)
            putFile16BitBE(file, element_info[element].change.content[x][y]);
 
+       putFile8Bit(file, element_info[element].slippery_type);
+
        /* some free bytes for future properties and padding */
        WriteUnusedBytesToFile(file, LEVEL_CPART_CUS3_UNUSED);
       }