Author: cazfi
Date: Wed Apr 13 14:41:44 2016
New Revision: 32374

URL: http://svn.gna.org/viewcvs/freeciv?rev=32374&view=rev
Log:
Set values of each editor tool to one valid in the changed ruleset when
server sends new ruleset.

See bug #24577

Modified:
    trunk/client/editor.c
    trunk/client/editor.h
    trunk/client/packhand.c

Modified: trunk/client/editor.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/editor.c?rev=32374&r1=32373&r2=32374&view=diff
==============================================================================
--- trunk/client/editor.c       (original)
+++ trunk/client/editor.c       Wed Apr 13 14:41:44 2016
@@ -100,30 +100,11 @@
 static struct editor_state *editor = NULL;
 
 /****************************************************************************
-  Initialize editor tool data.
-****************************************************************************/
-static void tool_init(enum editor_tool_type ett, const char *name,
-                      int flags, const char *tooltip)
-{
-  struct editor_tool *tool;
-
-  if (!editor || !(0 <= ett && ett < NUM_EDITOR_TOOL_TYPES)) {
-    return;
-  }
-
-  tool = editor->tools + ett;
-
-  if (ett == ETT_COPYPASTE) {
-    tool->mode = ETM_COPY;
-  } else {
-    tool->mode = ETM_PAINT;
-  }
-  tool->name = name;
-  tool->flags = flags;
-  tool->tooltip = tooltip;
-  tool->size = 1;
-  tool->count = 1;
-  tool->applied_player_no = 0;
+  Set tool to some value legal under current ruleset.
+****************************************************************************/
+static void tool_set_init_value(enum editor_tool_type ett)
+{
+  struct editor_tool *tool = editor->tools + ett;
 
   if (ett == ETT_TERRAIN_SPECIAL) {
     struct extra_type *first_special = NULL;
@@ -144,6 +125,47 @@
     }
   } else {
     tool->value = 0;
+  }
+}
+
+/****************************************************************************
+  Initialize editor tool data.
+****************************************************************************/
+static void tool_init(enum editor_tool_type ett, const char *name,
+                      int flags, const char *tooltip)
+{
+  struct editor_tool *tool;
+
+  if (!editor || !(0 <= ett && ett < NUM_EDITOR_TOOL_TYPES)) {
+    return;
+  }
+
+  tool = editor->tools + ett;
+
+  if (ett == ETT_COPYPASTE) {
+    tool->mode = ETM_COPY;
+  } else {
+    tool->mode = ETM_PAINT;
+  }
+  tool->name = name;
+  tool->flags = flags;
+  tool->tooltip = tooltip;
+  tool->size = 1;
+  tool->count = 1;
+  tool->applied_player_no = 0;
+
+  tool_set_init_value(ett);
+}
+
+/****************************************************************************
+  Adjust editor for changed ruleset.
+****************************************************************************/
+void editor_ruleset_changed(void)
+{
+  int t;
+
+  for (t = 0; t < NUM_EDITOR_TOOL_TYPES; t++) {
+    tool_set_init_value(t);
   }
 }
 

Modified: trunk/client/editor.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/editor.h?rev=32374&r1=32373&r2=32374&view=diff
==============================================================================
--- trunk/client/editor.h       (original)
+++ trunk/client/editor.h       Wed Apr 13 14:41:44 2016
@@ -20,7 +20,7 @@
 
 #include "fc_types.h"
 
-/* See client/gui-gtk-2.0/editprop.c for instructions
+/* See client/gui-gtk-3.0/editprop.c for instructions
  * on how to add more object types. */
 enum editor_object_type {
   OBJTYPE_TILE = 0,
@@ -61,6 +61,8 @@
 void editor_init(void);
 void editor_clear(void);
 void editor_free(void);
+
+void editor_ruleset_changed(void);
 
 bool editor_is_active(void);
 enum editor_tool_type editor_get_tool(void);
@@ -192,7 +194,7 @@
 
 #define edit_buffer_type_iterate_end \
   }\
-} while (0)
+} while (FALSE)
 
 #ifdef __cplusplus
 }

Modified: trunk/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=32374&r1=32373&r2=32374&view=diff
==============================================================================
--- trunk/client/packhand.c     (original)
+++ trunk/client/packhand.c     Wed Apr 13 14:41:44 2016
@@ -3153,6 +3153,9 @@
 
   /* Cache what city production can receive help from caravans. */
   city_production_caravan_shields_init();
+
+  /* Adjust editor for changed ruleset. */
+  editor_ruleset_changed();
 
   /* We are not going to crop any more sprites from big sprites, free them. */
   finish_loading_sprites(tileset);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to