changed setup to be initialized before executing commands
[rocksndiamonds.git] / src / init.c
index aea5c31bd576c806c7519a320cd8f7525ab10075..a760cbf51223c3c3a42d8a01bdafb2933cdfa5bf 100644 (file)
@@ -157,10 +157,6 @@ inline void InitElementSmallImagesScaledUp(int graphic)
 
   // create small and game tile sized bitmaps (and scale up, if needed)
   CreateImageWithSmallImages(graphic, g->scale_up_factor, g->tile_size);
-
-  // default (standard sized) bitmap may have changed now -- update it
-  if (g->bitmaps)
-    g->bitmap = g->bitmaps[IMG_BITMAP_STANDARD];
 }
 
 void InitElementSmallImages()
@@ -214,6 +210,17 @@ void InitScaledImages()
     ScaleImage(i, graphic_info[i].scale_up_factor);
 }
 
+void InitBitmapPointers()
+{
+  int num_images = getImageListSize();
+  int i;
+
+  // standard size bitmap may have changed -- update default bitmap pointer
+  for (i = 0; i < num_images; i++)
+    if (graphic_info[i].bitmaps)
+      graphic_info[i].bitmap = graphic_info[i].bitmaps[IMG_BITMAP_STANDARD];
+}
+
 #if 1
 /* !!! FIX THIS (CHANGE TO USING NORMAL ELEMENT GRAPHIC DEFINITIONS) !!! */
 void SetBitmaps_EM(Bitmap **em_bitmap)
@@ -1918,6 +1925,8 @@ static void ReinitializeGraphics()
   print_timestamp_time("InitElementSmallImages");
   InitScaledImages();                  /* scale all other images, if needed */
   print_timestamp_time("InitScaledImages");
+  InitBitmapPointers();                        /* set standard size bitmap pointers */
+  print_timestamp_time("InitBitmapPointers");
   InitFontGraphicInfo();               /* initialize text drawing functions */
   print_timestamp_time("InitFontGraphicInfo");
 
@@ -4725,6 +4734,12 @@ void Execute_Command(char *command)
       Error(ERR_EXIT, "image target directory '%s' not found or not writable",
            global.create_images_dir);
   }
+  else if (strPrefix(command, "create CE image "))
+  {
+    CreateCustomElementImages(&command[16]);
+
+    exit(0);
+  }
 
 #if DEBUG
 #if defined(TARGET_SDL2)
@@ -5005,6 +5020,9 @@ void InitGfxBuffers()
   InitGfxScrollbufferInfo(FXSIZE, FYSIZE);
   InitGfxClipRegion(FALSE, -1, -1, -1, -1);
 
+  /* required if door size definitions have changed */
+  InitGraphicCompatibilityInfo_Doors();
+
   InitGfxBuffers_EM();
   InitGfxBuffers_SP();
 }
@@ -5057,6 +5075,7 @@ void InitGfx()
 
   InitGfxBuffers();
   InitGfxCustomArtworkInfo();
+  InitGfxOtherSettings();
 
   bitmap_font_initial = LoadCustomImage(filename_font_initial);
 
@@ -5654,6 +5673,10 @@ void OpenAll()
 
   print_timestamp_time("[init global stuff]");
 
+  InitSetup();
+
+  print_timestamp_time("[init setup/config stuff (1)]");
+
   if (options.execute_command)
     Execute_Command(options.execute_command);
 
@@ -5668,10 +5691,6 @@ void OpenAll()
     exit(0);                   /* never reached, server loops forever */
   }
 
-  InitSetup();
-
-  print_timestamp_time("[init setup/config stuff (1)]");
-
   InitGameInfo();
   print_timestamp_time("[init setup/config stuff (2)]");
   InitPlayerInfo();