rnd-20031231-1-src
[rocksndiamonds.git] / src / init.c
index be4422c67d1f580231e60ee05ad543311c49747e..864d0b3b6395753964fb40a791ac7403ab269247 100644 (file)
@@ -413,6 +413,9 @@ void InitElementGraphicInfo()
   int num_property_mappings = getImageListPropertyMappingSize();
   int i, act, dir;
 
+  if (graphic_info == NULL)            /* still at startup phase */
+    return;
+
   /* set values to -1 to identify later as "uninitialized" values */
   for (i = 0; i < MAX_NUM_ELEMENTS; i++)
   {
@@ -641,6 +644,15 @@ void InitElementGraphicInfo()
       if (IS_SB_ELEMENT(i) && element_info[EL_SB_DEFAULT].crumbled[act] != -1)
        default_action_crumbled = element_info[EL_SB_DEFAULT].crumbled[act];
 
+#if 1
+      /* !!! make this better !!! */
+      if (i == EL_EMPTY_SPACE)
+      {
+       default_action_graphic = element_info[EL_DEFAULT].graphic[act];
+       default_action_crumbled = element_info[EL_DEFAULT].crumbled[act];
+      }
+#endif
+
       if (default_action_graphic == -1)
        default_action_graphic = default_graphic;
       if (default_action_crumbled == -1)
@@ -967,8 +979,7 @@ static void InitGraphicInfo()
   GC copy_clipmask_gc = None;
 #endif
 
-  if (graphic_info != NULL)
-    free(graphic_info);
+  checked_free(graphic_info);
 
   graphic_info = checked_calloc(num_images * sizeof(struct GraphicInfo));
 
@@ -1192,9 +1203,12 @@ static void InitElementSoundInfo()
       if (IS_SB_ELEMENT(i) && element_info[EL_SB_DEFAULT].sound[act] != -1)
        default_action_sound = element_info[EL_SB_DEFAULT].sound[act];
 
+      /* !!! there's no such thing as a "default action sound" !!! */
+#if 0
       /* look for element specific default sound (independent from action) */
       if (element_info[i].sound[ACTION_DEFAULT] != -1)
        default_action_sound = element_info[i].sound[ACTION_DEFAULT];
+#endif
 
       /* no sound for this specific action -- use default action sound */
       if (element_info[i].sound[act] == -1)
@@ -1262,8 +1276,7 @@ static void InitSoundInfo()
   int num_sounds = getSoundListSize();
   int i, j;
 
-  if (sound_info != NULL)
-    free(sound_info);
+  checked_free(sound_info);
 
   sound_effect_properties = checked_calloc(num_sounds * sizeof(int));
   sound_info = checked_calloc(num_sounds * sizeof(struct SoundInfo));
@@ -1494,8 +1507,7 @@ static void InitMusicInfo()
   int num_music = getMusicListSize();
   int i, j;
 
-  if (music_info != NULL)
-    free(music_info);
+  checked_free(music_info);
 
   music_info = checked_calloc(num_music * sizeof(struct MusicInfo));
 
@@ -2068,6 +2080,11 @@ void InitElementPropertiesStatic()
     -1
   };
 
+  static int ep_can_explode_dyna[] =
+  {
+    -1
+  };
+
   static int ep_player[] =
   {
     EL_PLAYER_1,
@@ -2839,6 +2856,7 @@ void InitElementPropertiesStatic()
     { ep_droppable,            EP_DROPPABLE            },
     { ep_can_explode_1x1,      EP_CAN_EXPLODE_1X1      },
     { ep_pushable,             EP_PUSHABLE             },
+    { ep_can_explode_dyna,     EP_CAN_EXPLODE_DYNA     },
 
     { ep_player,               EP_PLAYER               },
     { ep_can_pass_magic_wall,  EP_CAN_PASS_MAGIC_WALL  },
@@ -3100,7 +3118,16 @@ void InitElementPropertiesEngine(int engine_version)
 
     /* ---------- CAN_EXPLODE_3X3 ------------------------------------------ */
     SET_PROPERTY(i, EP_CAN_EXPLODE_3X3, (CAN_EXPLODE(i) &&
-                                        !CAN_EXPLODE_1X1(i)));
+                                        !CAN_EXPLODE_1X1(i) &&
+                                        !CAN_EXPLODE_DYNA(i)));
+#if 0
+    if (i == EL_CUSTOM_START + 253)
+      printf("::: %d, %d, %d -> %d\n",
+            CAN_EXPLODE_1X1(i),
+            CAN_EXPLODE_3X3(i),
+            CAN_EXPLODE_DYNA(i),
+            CAN_EXPLODE(i));
+#endif
 
     /* ---------- CAN_CHANGE ----------------------------------------------- */
     SET_PROPERTY(i, EP_CAN_CHANGE, FALSE);     /* default: cannot change */
@@ -3180,6 +3207,9 @@ void InitElementPropertiesEngine(int engine_version)
       element_info[element].push_delay_random = game.default_push_delay_random;
   }
 #endif
+
+  /* this is needed because some graphics depend on element properties */
+  InitElementGraphicInfo();
 }
 
 static void InitGlobal()