Author: cazfi
Date: Wed Apr 13 14:41:56 2016
New Revision: 32376

URL: http://svn.gna.org/viewcvs/freeciv?rev=32376&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:
    branches/S2_5/client/editor.c
    branches/S2_5/client/editor.h
    branches/S2_5/client/packhand.c

Modified: branches/S2_5/client/editor.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/editor.c?rev=32376&r1=32375&r2=32376&view=diff
==============================================================================
--- branches/S2_5/client/editor.c       (original)
+++ branches/S2_5/client/editor.c       Wed Apr 13 14:41:56 2016
@@ -100,6 +100,20 @@
 static struct editor_state *editor = NULL;
 
 /****************************************************************************
+  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) {
+    tool->value = S_IRRIGATION;
+  } else {
+    tool->value = 0;
+  }
+}
+
+/****************************************************************************
   Initialize editor tool data.
 ****************************************************************************/
 static void tool_init(enum editor_tool_type ett, const char *name,
@@ -125,10 +139,18 @@
   tool->count = 1;
   tool->applied_player_no = 0;
 
-  if (ett == ETT_TERRAIN_SPECIAL) {
-    tool->value = S_IRRIGATION;
-  } else {
-    tool->value = 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: branches/S2_5/client/editor.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/editor.h?rev=32376&r1=32375&r2=32376&view=diff
==============================================================================
--- branches/S2_5/client/editor.h       (original)
+++ branches/S2_5/client/editor.h       Wed Apr 13 14:41:56 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: branches/S2_5/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/packhand.c?rev=32376&r1=32375&r2=32376&view=diff
==============================================================================
--- branches/S2_5/client/packhand.c     (original)
+++ branches/S2_5/client/packhand.c     Wed Apr 13 14:41:56 2016
@@ -2984,6 +2984,9 @@
   unit_type_iterate(ptype) {
     set_unit_type_caches(ptype);
   } unit_type_iterate_end;
+
+  /* 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