Author: cazfi
Date: Sat Feb  7 06:56:35 2015
New Revision: 28014

URL: http://svn.gna.org/viewcvs/freeciv?rev=28014&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:
    trunk/client/helpdata.c
    trunk/data/civ2/units.ruleset
    trunk/data/civ2civ3/units.ruleset
    trunk/data/classic/units.ruleset
    trunk/data/experimental/units.ruleset
    trunk/data/multiplayer/units.ruleset

Modified: trunk/client/helpdata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/helpdata.c?rev=28014&r1=28013&r2=28014&view=diff
==============================================================================
--- trunk/client/helpdata.c     (original)
+++ trunk/client/helpdata.c     Sat Feb  7 06:56:35 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: trunk/data/civ2/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2/units.ruleset?rev=28014&r1=28013&r2=28014&view=diff
==============================================================================
--- trunk/data/civ2/units.ruleset       (original)
+++ trunk/data/civ2/units.ruleset       Sat Feb  7 06:56:35 2015
@@ -21,7 +21,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: trunk/data/civ2civ3/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2civ3/units.ruleset?rev=28014&r1=28013&r2=28014&view=diff
==============================================================================
--- trunk/data/civ2civ3/units.ruleset   (original)
+++ trunk/data/civ2civ3/units.ruleset   Sat Feb  7 06:56:35 2015
@@ -26,7 +26,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: trunk/data/classic/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/classic/units.ruleset?rev=28014&r1=28013&r2=28014&view=diff
==============================================================================
--- trunk/data/classic/units.ruleset    (original)
+++ trunk/data/classic/units.ruleset    Sat Feb  7 06:56:35 2015
@@ -26,7 +26,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: trunk/data/experimental/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/experimental/units.ruleset?rev=28014&r1=28013&r2=28014&view=diff
==============================================================================
--- trunk/data/experimental/units.ruleset       (original)
+++ trunk/data/experimental/units.ruleset       Sat Feb  7 06:56:35 2015
@@ -29,7 +29,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: trunk/data/multiplayer/units.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/multiplayer/units.ruleset?rev=28014&r1=28013&r2=28014&view=diff
==============================================================================
--- trunk/data/multiplayer/units.ruleset        (original)
+++ trunk/data/multiplayer/units.ruleset        Sat Feb  7 06:56:35 2015
@@ -26,7 +26,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