changed initializing CE properties to older versions (code cleanup)
[rocksndiamonds.git] / src / init.c
index 884ee541da6d5ca818c5359dd1d0d300404731ed..4bde60f91115bb361ca862c91a67bab34e164d78 100644 (file)
@@ -1717,10 +1717,10 @@ static void InitGraphicInfo()
 
   for (i = 0; i < num_images; i++)
   {
-    Bitmap *src_bitmap;
+    Bitmap *src_bitmap = graphic_info[i].bitmap;
     int src_x, src_y;
     int width, height;
-    int first_frame, last_frame;
+    int last_frame;
     int src_bitmap_width, src_bitmap_height;
 
     /* now check if no animation frames are outside of the loaded image */
@@ -1738,9 +1738,7 @@ static void InitGraphicInfo()
 
     /* check if first animation frame is inside specified bitmap */
 
-    first_frame = 0;
-    getFixedGraphicSource(i, first_frame, &src_bitmap, &src_x, &src_y);
-
+    /* do not use getGraphicSourceXY() here to get position of first frame; */
     /* this avoids calculating wrong start position for out-of-bounds frame */
     src_x = graphic_info[i].src_x;
     src_y = graphic_info[i].src_y;
@@ -1770,12 +1768,15 @@ static void InitGraphicInfo()
       Error(ERR_INFO_LINE, "-");
 
       graphic_info[i] = graphic_info[fallback_graphic];
+
+      /* if first frame out of bounds, do not check last frame anymore */
+      continue;
     }
 
     /* check if last animation frame is inside specified bitmap */
 
     last_frame = graphic_info[i].anim_frames - 1;
-    getFixedGraphicSource(i, last_frame, &src_bitmap, &src_x, &src_y);
+    getGraphicSourceXY(i, last_frame, &src_x, &src_y, FALSE);
 
     if (src_x < 0 || src_y < 0 ||
        src_x + width  > src_bitmap_width ||
@@ -4260,6 +4261,8 @@ void InitElementPropertiesStatic()
     EL_INTERNAL_CASCADE_SP_ACTIVE,
     EL_INTERNAL_CASCADE_DC_ACTIVE,
     EL_INTERNAL_CASCADE_DX_ACTIVE,
+    EL_INTERNAL_CASCADE_MM_ACTIVE,
+    EL_INTERNAL_CASCADE_DF_ACTIVE,
     EL_INTERNAL_CASCADE_CHARS_ACTIVE,
     EL_INTERNAL_CASCADE_STEEL_CHARS_ACTIVE,
     EL_INTERNAL_CASCADE_CE_ACTIVE,
@@ -4281,6 +4284,8 @@ void InitElementPropertiesStatic()
     EL_INTERNAL_CASCADE_SP,
     EL_INTERNAL_CASCADE_DC,
     EL_INTERNAL_CASCADE_DX,
+    EL_INTERNAL_CASCADE_MM,
+    EL_INTERNAL_CASCADE_DF,
     EL_INTERNAL_CASCADE_CHARS,
     EL_INTERNAL_CASCADE_STEEL_CHARS,
     EL_INTERNAL_CASCADE_CE,
@@ -4678,25 +4683,6 @@ void InitElementPropertiesEngine(int engine_version)
     InitElementGraphicInfo();
 }
 
-void InitElementPropertiesAfterLoading(int engine_version)
-{
-  int i;
-
-  /* set some other uninitialized values of custom elements in older levels */
-  if (engine_version < VERSION_IDENT(3,1,0,0))
-  {
-    for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++)
-    {
-      int element = EL_CUSTOM_START + i;
-
-      element_info[element].access_direction = MV_ALL_DIRECTIONS;
-
-      element_info[element].explosion_delay = 17;
-      element_info[element].ignition_delay = 8;
-    }
-  }
-}
-
 void InitElementPropertiesGfxElement()
 {
   int i;
@@ -6039,6 +6025,7 @@ void OpenAll()
 
   em_open_all();
   sp_open_all();
+  mm_open_all();
 
   if (global.autoplay_leveldir)
   {
@@ -6115,7 +6102,7 @@ void CloseAllAndExit(int exit_value)
   CloseVideoDisplay();
   ClosePlatformDependentStuff();
 
-  if (exit_value != 0)
+  if (exit_value != 0 && !options.execute_command)
   {
     /* fall back to default level set (current set may have caused an error) */
     SaveLevelSetup_LastSeries_Deactivate();