Author: sveinung
Date: Wed Oct  5 02:24:54 2016
New Revision: 33997

URL: http://svn.gna.org/viewcvs/freeciv?rev=33997&view=rev
Log:
List who can act from non livable tile...

when explaining that the non livable terrain at the actor unit's tile is the
reason why it can't act.

See patch #7756

Modified:
    trunk/server/unithand.c

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=33997&r1=33996&r2=33997&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Wed Oct  5 02:24:54 2016
@@ -1088,9 +1088,40 @@
                   unit_name_translation(punit));
     break;
   case ANEK_BAD_TERRAIN_ACT:
-    notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
-                  _("Unit cannot act from %s."),
-                  terrain_name_translation(explnat->no_act_terrain));
+    {
+      const char *types[utype_count()];
+      int i = 0;
+
+      if (!utype_can_do_act_when_ustate(unit_type_get(punit),
+                                        ACTION_ANY, USP_LIVABLE_TILE,
+                                        FALSE)
+          && !can_unit_exist_at_tile(punit, unit_tile(punit))) {
+        unit_type_iterate(utype) {
+          if (utype_can_do_act_when_ustate(utype, ACTION_ANY,
+                                           USP_LIVABLE_TILE, FALSE)) {
+            types[i++] = utype_name_translation(utype);
+          }
+        } unit_type_iterate_end;
+      }
+
+      if (0 < i) {
+        struct astring astr = ASTRING_INIT;
+
+        notify_player(pplayer, unit_tile(punit),
+                      E_BAD_COMMAND, ftc_server,
+                      _("Your %s cannot act from %s. "
+                        "Only %s can act from a non livable tile."),
+                      unit_name_translation(punit),
+                      terrain_name_translation(explnat->no_act_terrain),
+                      astr_build_or_list(&astr, types, i));
+
+        astr_free(&astr);
+      } else {
+        notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
+                      _("Unit cannot act from %s."),
+                      terrain_name_translation(explnat->no_act_terrain));
+      }
+    }
     break;
   case ANEK_BAD_TERRAIN_TGT:
     notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
@@ -1466,12 +1497,45 @@
                   action_get_ui_name(stopped_action));
     break;
   case ANEK_BAD_TERRAIN_ACT:
-    notify_player(pplayer, unit_tile(actor),
-                  event, ftc_server,
-                  _("Your %s can't do %s from %s."),
-                  unit_name_translation(actor),
-                  action_get_ui_name(stopped_action),
-                  terrain_name_translation(explnat->no_act_terrain));
+    {
+      const char *types[utype_count()];
+      int i = 0;
+
+      if (!utype_can_do_act_when_ustate(unit_type_get(actor),
+                                        stopped_action, USP_LIVABLE_TILE,
+                                        FALSE)
+          && !can_unit_exist_at_tile(actor, unit_tile(actor))) {
+        unit_type_iterate(utype) {
+          if (utype_can_do_act_when_ustate(utype, stopped_action,
+                                           USP_LIVABLE_TILE, FALSE)) {
+            types[i++] = utype_name_translation(utype);
+          }
+        } unit_type_iterate_end;
+      }
+
+      if (0 < i) {
+        struct astring astr = ASTRING_INIT;
+
+        notify_player(pplayer, unit_tile(actor),
+                      event, ftc_server,
+                      _("Your %s can't do %s from %s. "
+                        "Only %s can do %s from a non livable tile."),
+                      unit_name_translation(actor),
+                      action_get_ui_name(stopped_action),
+                      terrain_name_translation(explnat->no_act_terrain),
+                      action_get_ui_name(stopped_action),
+                      astr_build_or_list(&astr, types, i));
+
+        astr_free(&astr);
+      } else {
+        notify_player(pplayer, unit_tile(actor),
+                      event, ftc_server,
+                      _("Your %s can't do %s from %s."),
+                      unit_name_translation(actor),
+                      action_get_ui_name(stopped_action),
+                      terrain_name_translation(explnat->no_act_terrain));
+      }
+    }
     break;
   case ANEK_BAD_TERRAIN_TGT:
     notify_player(pplayer, unit_tile(actor),


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

Reply via email to