rnd-19981017-1
[rocksndiamonds.git] / src / editor.c
index 85ae127e3f95d4f66f0b6741af5558edebb1759e..c17a4967ef27f6ecf69085bb0069b482169447ff 100644 (file)
@@ -21,8 +21,8 @@
 #define CHOICE_DELAY_VALUE     100
 
 static int level_xpos,level_ypos;
-static BOOL edit_mode;
-static BOOL name_typing;
+static boolean edit_mode;
+static boolean name_typing;
 static int new_element1 = EL_MAUERWERK;
 static int new_element2 = EL_LEERRAUM;
 static int new_element3 = EL_ERDREICH;
@@ -610,24 +610,25 @@ void FloodFill(int from_x, int from_y, int fill_element)
   static int check[4][2] = { {-1,0}, {0,-1}, {1,0}, {0,1} };
   static int safety = 0;
 
+  /* check if starting field still has the desired content */
+  if (Feld[from_x][from_y] == fill_element)
+    return;
+
   safety++;
 
-  if (safety>lev_fieldx*lev_fieldy)
-  {
-    fprintf(stderr,"Something went wrong in 'FloodFill()'. Please debug.\n");
-    exit(-1);
-  }
+  if (safety > lev_fieldx*lev_fieldy)
+    Error(ERR_EXIT, "Something went wrong in 'FloodFill()'. Please debug.");
 
   old_element = Feld[from_x][from_y];
   Feld[from_x][from_y] = fill_element;
 
   for(i=0;i<4;i++)
   {
-    x = from_x+check[i][0];
-    y = from_y+check[i][1];
+    x = from_x + check[i][0];
+    y = from_y + check[i][1];
 
-    if (IN_LEV_FIELD(x,y) && Feld[x][y]==old_element)
-      FloodFill(x,y,fill_element);
+    if (IN_LEV_FIELD(x,y) && Feld[x][y] == old_element)
+      FloodFill(x, y, fill_element);
   }
 
   safety--;
@@ -637,7 +638,7 @@ void LevelEd(int mx, int my, int button)
 {
   static int last_button = 0;
   static int in_field_pressed = FALSE;
-  static BOOL use_floodfill = FALSE;
+  static boolean use_floodfill = FALSE;
   int x = (mx-SX)/MINI_TILEX; 
   int y = (my-SY)/MINI_TILEY;