Author: cazfi
Date: Wed Feb 18 07:22:37 2015
New Revision: 28201

URL: http://svn.gna.org/viewcvs/freeciv?rev=28201&view=rev
Log:
Check that unit can ever clean the extra before claiming so in the help.

See patch #5796

Modified:
    branches/S2_6/client/helpdata.c
    branches/S2_6/common/extras.h

Modified: branches/S2_6/client/helpdata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/helpdata.c?rev=28201&r1=28200&r2=28201&view=diff
==============================================================================
--- branches/S2_6/client/helpdata.c     (original)
+++ branches/S2_6/client/helpdata.c     Wed Feb 18 07:22:37 2015
@@ -3315,6 +3315,17 @@
 }
 
 /****************************************************************
+  Is unit type ever able to clean out an extra
+*****************************************************************/
+static bool help_is_extra_cleanable(struct extra_type *pextra,
+                                    struct unit_type *ptype)
+{
+  return are_reqs_active(NULL, NULL, NULL, NULL, NULL,
+                         NULL, ptype, NULL, NULL, &pextra->rmreqs,
+                         RPT_POSSIBLE);
+}
+
+/****************************************************************
   Append misc dynamic text for units.
   Transport capacity, unit flags, fuel.
 
@@ -3753,8 +3764,31 @@
     }
 
     /* Pollution, fallout. */
-    CATLSTR(buf, bufsz, _("* Can clean pollution from tiles.\n"));
-    CATLSTR(buf, bufsz, _("* Can clean nuclear fallout from tiles.\n"));
+    extra_type_by_rmcause_iterate(ERM_CLEANPOLLUTION, pextra) {
+      if (help_is_extra_cleanable(pextra, utype)) {
+        strvec_append(extras_vec, extra_name_translation(pextra));
+     }
+    } extra_type_by_rmcause_iterate_end;
+
+    if (strvec_size(extras_vec) > 0) {
+      strvec_to_and_list(extras_vec, &extras_and);
+      cat_snprintf(buf, bufsz, _("* Can clean %s from tiles.\n"),
+                   astr_str(&extras_and));
+      strvec_clear(extras_vec);
+    }
+    
+    extra_type_by_rmcause_iterate(ERM_CLEANFALLOUT, pextra) {
+      if (help_is_extra_cleanable(pextra, utype)) {
+        strvec_append(extras_vec, extra_name_translation(pextra));
+      }
+    } extra_type_by_rmcause_iterate_end;
+
+    if (strvec_size(extras_vec) > 0) {
+      strvec_to_and_list(extras_vec, &extras_and);
+      cat_snprintf(buf, bufsz, _("* Can clean %s from tiles.\n"),
+                   astr_str(&extras_and));
+      strvec_clear(extras_vec);
+    }
 
     strvec_destroy(extras_vec);
   }

Modified: branches/S2_6/common/extras.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/extras.h?rev=28201&r1=28200&r2=28201&view=diff
==============================================================================
--- branches/S2_6/common/extras.h       (original)
+++ branches/S2_6/common/extras.h       Wed Feb 18 07:22:37 2015
@@ -71,6 +71,12 @@
 
   struct requirement_vector reqs;
   struct requirement_vector rmreqs;
+
+  /* 'buildable' is unclean. Clean solution would be to rely solely on 
extra_cause:
+   * if the extra cannot be built, it's not in the cause's list.
+   * But we currently rely on actually-not-buildable extras to be on the lists,
+   * for example for the editor to list non-buildable but editor-placeable
+   * extras. */
   bool buildable;
   int build_time;
   int build_time_factor;


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

Reply via email to