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

In the gtk2 client, "Add to city" is shown when you can build cities
and "build city" when you can add the settler to a city.. this is both
in 2.1 branch and trunk.

The attached patch fixes this, and an additional bug: It is assumed
that F_CITIES assumes F_ADD_TO_CITY. These should be treated
differently, so the code restructures a bit to test those cases. The
logic should be very clear.

Attached patch to trunk r13054. The patch also applies to the 2.1
branch. Tested lightly with 2.1 branch.

Attached is also a patch to units.ruleset that adds "Settlers no add"
and "Settlers no cit", which are units with only Cities and "Add to
city" flags respectively. The patch can be used to test the attached
savegame on trunk, where I tested all the combinations of flags were
tested -> both, or one of the two.

Index: client/gui-gtk-2.0/menu.c
===================================================================
--- client/gui-gtk-2.0/menu.c	(revision 13054)
+++ client/gui-gtk-2.0/menu.c	(arbetskopia)
@@ -1441,26 +1441,27 @@
       menus_set_sensitive("<main>/_Orders/Explode Nuclear",
 			  units_have_flag(punits, F_NUCLEAR, TRUE));
       if (units_have_flag(punits, F_HELP_WONDER, TRUE))
-	menus_rename("<main>/_Orders/_Build City", _("Help _Build Wonder"));
-      else if (units_have_flag(punits, F_CITIES, TRUE)) {
-	bool can_build = FALSE;
+        menus_rename("<main>/_Orders/_Build City", _("Help _Build Wonder"));
+      else {
+        bool city_on_tile = FALSE;
 
-	/* FIXME: this overloading doesn't work well with multiple focus
-	 * units. */
-	unit_list_iterate(punits, punit) {
-	  if (!punit->tile->city) {
-	    can_build = TRUE;
-	    break;
-	  }
-	} unit_list_iterate_end;
-
-	if (can_build)
-	  menus_rename("<main>/_Orders/_Build City", _("Add to City (_B)"));
-	else
-	  menus_rename("<main>/_Orders/_Build City", _("_Build City"));
+        /* FIXME: this overloading doesn't work well with multiple focus
+         * units. */
+        unit_list_iterate(punits, punit) {
+          if (punit->tile->city) {
+            city_on_tile = TRUE;
+            break;
+          }
+        } unit_list_iterate_end;
+        
+        if (!city_on_tile && units_have_flag(punits, F_CITIES, TRUE))
+          menus_rename("<main>/_Orders/_Build City", _("_Build City"));
+        else if (city_on_tile && 
+                   units_have_flag(punits, F_ADD_TO_CITY, TRUE))
+          menus_rename("<main>/_Orders/_Build City", _("Add to City (_B)"));
+        else 
+          menus_rename("<main>/_Orders/_Build City", _("_Build City"));
       }
-      else 
-	menus_rename("<main>/_Orders/_Build City", _("_Build City"));
  
       if (units_have_flag(punits, F_TRADE_ROUTE, TRUE))
 	menus_rename("<main>/_Orders/Build _Road", _("Make Trade _Route"));

Attachment: settlers-buildcity-addtocity2.sav.gz
Description: GNU Zip compressed data

Index: data/default/units.ruleset
===================================================================
--- data/default/units.ruleset	(revision 13054)
+++ data/default/units.ruleset	(arbetskopia)
@@ -306,6 +306,67 @@
  Engineers is highly vulnerable to enemy attacks.\
 ")
 
+
+[unit_settlers_no_add]
+name          = _("Settlers No add")
+class         = "Land"
+tech_req      = "None"
+obsolete_by   = "None"
+graphic       = "u.settlers"
+graphic_alt   = "-"
+sound_move    = "m_settlers"
+sound_move_alt = "m_generic"
+sound_fight   = "f_settlers"
+sound_fight_alt = "f_generic"
+build_cost    = 40
+pop_cost      = 1
+attack        = 0
+defense       = 1
+hitpoints     = 20
+firepower     = 1
+move_rate     = 1
+vision_radius_sq = 2
+transport_cap = 0
+fuel          = 0
+uk_happy      = 0
+uk_shield     = 1
+uk_food       = 1
+uk_gold       = 0
+flags         = "Settlers", "NonMil", "Cities", "NoVeteran"
+roles         = "Cities"
+helptext      = _("\
+")
+
+[unit_settlers_no_cit]
+name          = _("Settlers No Cit")
+class         = "Land"
+tech_req      = "None"
+obsolete_by   = "None"
+graphic       = "u.settlers"
+graphic_alt   = "-"
+sound_move    = "m_settlers"
+sound_move_alt = "m_generic"
+sound_fight   = "f_settlers"
+sound_fight_alt = "f_generic"
+build_cost    = 40
+pop_cost      = 1
+attack        = 0
+defense       = 1
+hitpoints     = 20
+firepower     = 1
+move_rate     = 1
+vision_radius_sq = 2
+transport_cap = 0
+fuel          = 0
+uk_happy      = 0
+uk_shield     = 1
+uk_food       = 1
+uk_gold       = 0
+flags         = "Settlers", "NonMil", "AddToCity", "NoVeteran"
+roles         = "Cities"
+helptext      = _("\
+")
+
 [unit_worker]
 name          = _("Workers")
 class         = "Land"
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to