Author: sveinung
Date: Mon Jun 13 02:13:45 2016
New Revision: 32841

URL: http://svn.gna.org/viewcvs/freeciv?rev=32841&view=rev
Log:
Action not enabled explain unit_attack_result.

It is forbidden to perform the action "Explode Nuclear" to a neighbor tile
when blocked by unit unreachability, source terrain, destination terrain or
unit details. Explain when this blocks it.

See patch #7256

Modified:
    trunk/server/unithand.c

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=32841&r1=32840&r2=32841&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Mon Jun 13 02:13:45 2016
@@ -110,6 +110,8 @@
   ANEK_TGT_IS_CLAIMED,
   /* Explanation: can't be done to unclaimed target tiles. */
   ANEK_TGT_IS_UNCLAIMED,
+  /* Explanation: actor can't reach unit at target. */
+  ANEK_TGT_UNREACHABLE,
   /* Explanation: the action is disabled in this scenario. */
   ANEK_SCENARIO_DISABLED,
   /* Explanation: too close to a city. */
@@ -765,6 +767,14 @@
     break;
   case ACTION_AIRLIFT:
     action_custom = test_unit_can_airlift_to(NULL, punit, target_city);
+    break;
+  case ACTION_NUKE:
+    if (target_tile != unit_tile(punit)) {
+      /* unit_attack_units_at_tile_result() matters for neighbor tiles. */
+      action_custom = unit_attack_units_at_tile_result(punit, target_tile);
+    } else {
+      action_custom = ATT_OK;
+    }
     break;
   default:
     action_custom = 0;
@@ -901,6 +911,28 @@
                                        city_size_get(target_city)
                                        + unit_pop_value(punit))))) {
     explnat->kind = ANEK_CITY_POP_LIMIT;
+  } else if (action_id == ACTION_NUKE
+             && action_custom != ATT_OK) {
+    switch (action_custom) {
+    case ATT_NON_ATTACK:
+      explnat->kind = ANEK_ACTOR_UNIT;
+      break;
+    case ATT_UNREACHABLE:
+      explnat->kind = ANEK_TGT_UNREACHABLE;
+      break;
+    case ATT_NONNATIVE_SRC:
+      explnat->kind = ANEK_BAD_TERRAIN_ACT;
+      explnat->no_act_terrain = tile_terrain(unit_tile(punit));
+      break;
+    case ATT_NONNATIVE_DST:
+      explnat->kind = ANEK_BAD_TERRAIN_TGT;
+      explnat->no_act_terrain = tile_terrain(target_tile);
+      break;
+    default:
+      fc_assert(action_custom != ATT_OK);
+      explnat->kind = ANEK_UNKNOWN;
+      break;
+    }
   } else if (action_id == ACTION_AIRLIFT
              && action_custom == AR_SRC_NO_FLIGHTS) {
     explnat->kind = ANEK_CITY_NO_CAPACITY;
@@ -1078,6 +1110,12 @@
                   _("%s can't do anything to an unknown target tile."),
                   unit_name_translation(punit));
     break;
+  case ANEK_TGT_UNREACHABLE:
+    notify_player(pplayer, target_tile, E_BAD_COMMAND, ftc_server,
+                  _("%s can't do anything since there is an unreachable "
+                    "unit."),
+                  unit_name_translation(punit));
+    break;
   case ANEK_ACTION_BLOCKS:
     /* If an action blocked another action the blocking action must be
      * possible. */
@@ -1466,6 +1504,14 @@
                   event, ftc_server,
                   /* TRANS: Paratroopers ... Drop Paratrooper */
                   _("%s can't do %s to an unknown tile."),
+                  unit_name_translation(actor),
+                  action_get_ui_name(stopped_action));
+    break;
+  case ANEK_TGT_UNREACHABLE:
+    notify_player(pplayer, target_tile,
+                  event, ftc_server,
+                  _("Your %s can't do %s there since there's an "
+                    "unreachable unit."),
                   unit_name_translation(actor),
                   action_get_ui_name(stopped_action));
     break;


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

Reply via email to