version number set to 4.1.2.1
[rocksndiamonds.git] / src / editor.c
index 3fa42f10eab74c5accddb47ecc8d90872e340f06..5eed006605c50a65ef0d33629739fe6e5018f797 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;
@@ -12059,11 +12063,13 @@ static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
 
     char *clipboard_text = SDL_GetClipboardText();
     char *ptr = clipboard_text;
+    boolean allow_new_row = FALSE;
     boolean stop = FALSE;
 
     while (*ptr && !stop)
     {
       boolean prefix_found = FALSE;
+      boolean start_new_row = FALSE;
 
       // level sketch element number prefixes (may be multi-byte characters)
       char *prefix_list[] = { "`", "ΒΈ" };
@@ -12092,19 +12098,10 @@ static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
        }
       }
 
-      // continue with next character if prefix not found
-      if (!prefix_found)
-      {
-       ptr++;          // !!! FIX THIS for real UTF-8 handling !!!
-
-       continue;
-      }
-
-      // continue with next character if prefix not found
-      if (strlen(ptr) < 3)
-       break;
-
-      if (ptr[0] >= '0' && ptr[0] <= '9' &&
+      // check if prefix found and followed by three numbers
+      if (prefix_found &&
+         strlen(ptr) >= 3 &&
+         ptr[0] >= '0' && ptr[0] <= '9' &&
          ptr[1] >= '0' && ptr[1] <= '9' &&
          ptr[2] >= '0' && ptr[2] <= '9')
       {
@@ -12124,14 +12121,28 @@ static void CopyBrushExt(int from_x, int from_y, int to_x, int to_y,
 
        x++;
 
-       if (x >= MAX_LEV_FIELDX || *ptr == '\n')
-       {
-         x = 0;
-         y++;
+       if (x >= MAX_LEV_FIELDX)
+         start_new_row = TRUE;
 
-         if (y >= MAX_LEV_FIELDY)
-           stop = TRUE;
-       }
+       allow_new_row = TRUE;
+      }
+      else
+      {
+       if ((*ptr == '\n' || *ptr == '\r') && allow_new_row)
+         start_new_row = TRUE;
+
+       ptr++;          // !!! FIX THIS for real UTF-8 handling !!!
+      }
+
+      if (start_new_row)
+      {
+       x = 0;
+       y++;
+
+       if (y >= MAX_LEV_FIELDY)
+         stop = TRUE;
+
+       allow_new_row = FALSE;
       }
     }