<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40323 >

When the brush size parameter was greater than one,
applying the current editor tool to a selection of
tiles (e.g. by selecting with right-click drag and
pressing space) would affect more tiles than just
those that were selected.

This patch fixes that situation by making the tool only
apply to the selected tiles regardless of the size
parameter (except for the city tool, where the size
parameter means something else).

Also, some functions were given better names and
comments updated.


----------------------------------------------------------------------
火曜日は働く代わりに放火しています。
diff --git a/client/editor.c b/client/editor.c
index e703774..2dc5362 100644
--- a/client/editor.c
+++ b/client/editor.c
@@ -448,7 +448,8 @@ void editor_mouse_button_press(int canvas_x, int canvas_y,
       editor_grab_applied_player(ptile);
     } else if (modifiers == EKM_NONE) {
       editor->tool_active = TRUE;
-      editor_apply_tool_single(ptile);
+      editor_apply_tool(ptile, FALSE);
+      editor_notify_edit_finished();
       editor_set_current_tile(ptile);
     }
     break;
@@ -629,7 +630,8 @@ void editor_mouse_move(int canvas_x, int canvas_y, int modifiers)
   }
 
   if (editor->tool_active && old != NULL && old != ptile) {
-    editor_apply_tool_single(ptile);
+    editor_apply_tool(ptile, FALSE);
+    editor_notify_edit_finished();
     editor_set_current_tile(ptile);
   }
 
@@ -643,27 +645,20 @@ void editor_mouse_move(int canvas_x, int canvas_y, int modifiers)
   a hint for the server to now do any checks it has saved while the batch
   was being processed.
 ****************************************************************************/
-void editor_apply_tool_batch_finished(void)
+void editor_notify_edit_finished(void)
 {
   send_packet_edit_check_tiles(&client.conn);
 }
 
 /****************************************************************************
-  Apply the current tool at the given tile as a single operation rather
-  than in a batch.
-****************************************************************************/
-void editor_apply_tool_single(const struct tile *ptile)
-{
-  editor_apply_tool_batch(ptile);
-  editor_apply_tool_batch_finished();
-}
-
-/****************************************************************************
   Apply the current editor tool to the given tile. This function is
-  suitable to called over multiple tiles at once. One the batch of
-  operations is finished you should call editor_apply_tool_batch_finished.
+  suitable to called over multiple tiles at once. Once the batch of
+  operations is finished you should call editor_notify_edit_finished.
+  The 'part_of_selection' parameter should be TRUE if the tool is
+  being applied to a tile from a selection.
 ****************************************************************************/
-void editor_apply_tool_batch(const struct tile *ptile)
+void editor_apply_tool(const struct tile *ptile,
+                       bool part_of_selection)
 {
   enum editor_tool_type ett;
   int value, size, count, apno;
@@ -695,6 +690,10 @@ void editor_apply_tool_batch(const struct tile *ptile)
     return;
   }
 
+  if (part_of_selection && ett != ETT_CITY) {
+    size = 1;
+  }
+
   switch (ett) {
 
   case ETT_TERRAIN:
@@ -885,10 +884,10 @@ void editor_apply_tool_to_selection(void)
   connection_do_buffer(&client.conn);
   whole_map_iterate(ptile) {
     if (editor_tile_is_selected(ptile)) {
-      editor_apply_tool_batch(ptile);
+      editor_apply_tool(ptile, TRUE);
     }
   } whole_map_iterate_end;
-  editor_apply_tool_batch_finished();
+  editor_notify_edit_finished();
   connection_do_unbuffer(&client.conn);
 }
 
diff --git a/client/editor.h b/client/editor.h
index 02db456..683f0ea 100644
--- a/client/editor.h
+++ b/client/editor.h
@@ -80,9 +80,9 @@ void editor_mouse_button_release(int canvas_x, int canvas_y,
 void editor_mouse_move(int canvas_x, int canvas_y, int modifiers);
 void editor_redraw(void);
 
-void editor_apply_tool_single(const struct tile *ptile);
-void editor_apply_tool_batch(const struct tile *ptile);
-void editor_apply_tool_batch_finished(void);
+void editor_apply_tool(const struct tile *ptile,
+                       bool part_of_selection);
+void editor_notify_edit_finished(void);
 void editor_toggle_erase_mode(void);
 
 void editor_selection_clear(void);
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to