Author: cazfi
Date: Wed Feb 18 07:22:30 2015
New Revision: 28200

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

See patch #5796

Modified:
    trunk/client/helpdata.c
    trunk/common/extras.h

Modified: trunk/client/helpdata.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/helpdata.c?rev=28200&r1=28199&r2=28200&view=diff
==============================================================================
--- trunk/client/helpdata.c     (original)
+++ trunk/client/helpdata.c     Wed Feb 18 07:22:30 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: trunk/common/extras.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/extras.h?rev=28200&r1=28199&r2=28200&view=diff
==============================================================================
--- trunk/common/extras.h       (original)
+++ trunk/common/extras.h       Wed Feb 18 07:22:30 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