fixed using (manually changed) invalid values for editor zoom tile size
[rocksndiamonds.git] / src / editor.c
index 3fa42f10eab74c5accddb47ecc8d90872e340f06..dc1b528f90daf8ebaa38ee3d5c06c7420e7a2009 100644 (file)
@@ -8402,6 +8402,9 @@ static void InitZoomLevelSettings(int zoom_tilesize)
     ed_tilesize = setup.auto_setup.editor_zoom_tilesize;
     ed_tilesize_default = DEFAULT_EDITOR_TILESIZE;
 
+    // make sure that tile size is always a power of 2
+    ed_tilesize = (1 << log_2(ed_tilesize));
+
     if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
     {
       ed_tilesize = DEFAULT_EDITOR_TILESIZE_MM;
@@ -10876,7 +10879,6 @@ static void SetElementIntelliDraw(int x, int y, int new_element,
   };
   static int last_x = -1;
   static int last_y = -1;
-  int old_element = IntelliDrawBuffer[x][y];
 
   if (new_element == EL_UNDEFINED)
   {
@@ -10886,6 +10888,8 @@ static void SetElementIntelliDraw(int x, int y, int new_element,
     return;
   }
 
+  int old_element = IntelliDrawBuffer[x][y];
+
   if (IS_TUBE(new_element))
   {
     int last_element_new = EL_UNDEFINED;