Author: cazfi
Date: Sat Feb  7 06:56:45 2015
New Revision: 28015

URL: http://svn.gna.org/viewcvs/freeciv?rev=28015&view=rev
Log:
Help lists unit as capable of building an extra only if it fits requirements of
the extra in question.

See patch #5783

Modified:
    branches/S2_6/client/helpdata.c
    branches/S2_6/data/civ2/units.ruleset
    branches/S2_6/data/civ2civ3/units.ruleset
    branches/S2_6/data/classic/units.ruleset
    branches/S2_6/data/experimental/units.ruleset
    branches/S2_6/data/multiplayer/units.ruleset

Modified: branches/S2_6/client/helpdata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/helpdata.c?rev=28015&r1=28014&r2=28015&view=diff
==============================================================================
--- branches/S2_6/client/helpdata.c     (original)
+++ branches/S2_6/client/helpdata.c     Sat Feb  7 06:56:45 2015
@@ -3300,6 +3300,21 @@
 }
 
 /****************************************************************
+  Is unit type ever able to build an extra
+*****************************************************************/
+static bool help_is_extra_buildable(struct extra_type *pextra,
+                                    struct unit_type *ptype)
+{
+  if (!pextra->buildable) {
+    return FALSE;
+  }
+
+  return are_reqs_active(NULL, NULL, NULL, NULL, NULL,
+                         NULL, ptype, NULL, NULL, &pextra->reqs,
+                         RPT_POSSIBLE);
+}
+
+/****************************************************************
   Append misc dynamic text for units.
   Transport capacity, unit flags, fuel.
 
@@ -3669,29 +3684,50 @@
   }
   if (utype_has_flag(utype, UTYF_SETTLERS)) {
     /* Roads, rail, mines, irrigation. */
-    CATLSTR(buf, bufsz, _("* Can build roads and railroads.\n"));
+    extra_type_by_cause_iterate(EC_ROAD, pextra) {
+      if (help_is_extra_buildable(pextra, utype)) {
+        cat_snprintf(buf, bufsz, _("* Can build %s on tiles.\n"),
+                     extra_name_translation(pextra));
+      }
+    } extra_type_by_cause_iterate_end;
 
     /* TODO: Check also that specific unit fulfills the requirements of the 
effects */
     if (effect_cumulative_max(EFT_MINING_POSSIBLE) > 0) {
-      CATLSTR(buf, bufsz, _("* Can build mines on tiles.\n"));
+      extra_type_by_cause_iterate(EC_MINE, pextra) {
+        if (help_is_extra_buildable(pextra, utype)) {
+          cat_snprintf(buf, bufsz, _("* Can build %s on tiles.\n"),
+                       extra_name_translation(pextra));
+        }
+      } extra_type_by_cause_iterate_end;
     }
     if (effect_cumulative_max(EFT_MINING_TF_POSSIBLE) > 0) {
       CATLSTR(buf, bufsz, _("* Can mine terrain to another.\n"));
     }
 
     if (effect_cumulative_max(EFT_IRRIG_POSSIBLE) > 0) {
-      CATLSTR(buf, bufsz, _("* Can build irrigation and farmland on 
tiles.\n"));
+      extra_type_by_cause_iterate(EC_IRRIGATION, pextra) {
+        if (help_is_extra_buildable(pextra, utype)) {
+          cat_snprintf(buf, bufsz, _("* Can build %s on tiles.\n"),
+                       extra_name_translation(pextra));
+        }
+      } extra_type_by_cause_iterate_end;
     }
     if (effect_cumulative_max(EFT_IRRIG_TF_POSSIBLE) > 0) {
       CATLSTR(buf, bufsz, _("* Can irrigate terrain to another.\n"));
     }
+
+    extra_type_by_cause_iterate(EC_BASE, pextra) {
+      if (help_is_extra_buildable(pextra, utype)) {
+        cat_snprintf(buf, bufsz, _("* Can build %s on tiles.\n"),
+                     extra_name_translation(pextra));
+      }
+    } extra_type_by_cause_iterate_end;
 
     /* Pollution, fallout. */
     CATLSTR(buf, bufsz, _("* Can clean pollution from tiles.\n"));
     CATLSTR(buf, bufsz, _("* Can clean nuclear fallout from tiles.\n"));
   }
-  /* FIXME: bases -- but there is no good way to find out which bases a unit
-   * can conceivably build currently, so we have to remain silent. */
+
   if (utype_has_flag(utype, UTYF_SPY)) {
     CATLSTR(buf, bufsz, _("* Performs better diplomatic actions.\n"));
   }

Modified: branches/S2_6/data/civ2/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/civ2/units.ruleset?rev=28015&r1=28014&r2=28015&view=diff
==============================================================================
--- branches/S2_6/data/civ2/units.ruleset       (original)
+++ branches/S2_6/data/civ2/units.ruleset       Sat Feb  7 06:56:45 2015
@@ -20,7 +20,7 @@
 ; helptxt       = displayed in the help for units with this flag (optional)
 flags =
   { "name", "helptxt"
-    _("Airbase"), _("Can build airbases.") 
+    _("Airbase")
     _("Transform"), _("Can transform terrain.")
     _("AirAttacker"), _("Very bad at attacking AEGIS.")
     _("Horse"), _("Attack value halved when attacking Pikemen.")

Modified: branches/S2_6/data/civ2civ3/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/civ2civ3/units.ruleset?rev=28015&r1=28014&r2=28015&view=diff
==============================================================================
--- branches/S2_6/data/civ2civ3/units.ruleset   (original)
+++ branches/S2_6/data/civ2civ3/units.ruleset   Sat Feb  7 06:56:45 2015
@@ -25,7 +25,7 @@
 ; helptxt       = displayed in the help for units with this flag (optional)
 flags =
   { "name", "helptxt"
-    _("Airbase"), _("Can build airbases and buoys.")
+    _("Airbase")
     _("Transform"), _("Can transform terrain.")
     _("AirAttacker"), _("Very bad at attacking AEGIS.")
     _("Submarine"), _("Attack value halved when attacking Destroyer.")

Modified: branches/S2_6/data/classic/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/classic/units.ruleset?rev=28015&r1=28014&r2=28015&view=diff
==============================================================================
--- branches/S2_6/data/classic/units.ruleset    (original)
+++ branches/S2_6/data/classic/units.ruleset    Sat Feb  7 06:56:45 2015
@@ -25,7 +25,7 @@
 ; helptxt       = displayed in the help for units with this flag (optional)
 flags =
   { "name", "helptxt"
-    _("Airbase"), _("Can build airbases and buoys.")
+    _("Airbase")
     _("Transform"), _("Can transform terrain.")
     _("AirAttacker"), _("Very bad at attacking AEGIS.")
     _("Horse"), _("Attack value halved when attacking Pikemen.")

Modified: branches/S2_6/data/experimental/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/experimental/units.ruleset?rev=28015&r1=28014&r2=28015&view=diff
==============================================================================
--- branches/S2_6/data/experimental/units.ruleset       (original)
+++ branches/S2_6/data/experimental/units.ruleset       Sat Feb  7 06:56:45 2015
@@ -28,7 +28,7 @@
 ; helptxt       = displayed in the help for units with this flag (optional)
 flags =
   { "name", "helptxt"
-    _("Airbase"), _("Can build airbases and buoys.")
+    _("Airbase")
     _("Transform"), _("Can transform terrain.")
     _("AirAttacker"), _("Very bad at attacking AEGIS.")
     _("Horse"), _("Attack value halved when attacking Pikemen.")

Modified: branches/S2_6/data/multiplayer/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/multiplayer/units.ruleset?rev=28015&r1=28014&r2=28015&view=diff
==============================================================================
--- branches/S2_6/data/multiplayer/units.ruleset        (original)
+++ branches/S2_6/data/multiplayer/units.ruleset        Sat Feb  7 06:56:45 2015
@@ -25,7 +25,7 @@
 ; helptxt       = displayed in the help for units with this flag (optional)
 flags =
   { "name", "helptxt"
-    _("Airbase"), _("Can build airbases.")
+    _("Airbase")
     _("Transform"), _("Can transform terrain.")
     _("AirAttacker"), _("Very bad at attacking AEGIS.")
     _("Horse"), _("Attack value halved when attacking Pikemen.")


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

Reply via email to