Author: sveinung
Date: Sun Nov 13 19:30:22 2016
New Revision: 34498

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

See patch #7978

Modified:
    trunk/server/unithand.c
    trunk/server/unithand.h

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=34498&r1=34497&r2=34498&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Sun Nov 13 19:30:22 2016
@@ -801,6 +801,36 @@
   bool can_exist = can_unit_exist_at_tile(punit, unit_tile(punit));
   bool on_native = is_native_tile(unit_type_get(punit), unit_tile(punit));
   int action_custom;
+
+  switch (action_id_get_target_kind(action_id)) {
+  case ATK_CITY:
+    if (target_city == NULL) {
+      explnat->kind = ANEK_MISSING_TARGET;
+    }
+    break;
+  case ATK_UNIT:
+    if (target_unit == NULL) {
+      explnat->kind = ANEK_MISSING_TARGET;
+    }
+    break;
+  case ATK_UNITS:
+  case ATK_TILE:
+    if (target_tile == NULL) {
+      explnat->kind = ANEK_MISSING_TARGET;
+    }
+    break;
+  case ATK_SELF:
+    /* No other target. */
+    break;
+  case ATK_COUNT:
+    fc_assert(action_id_get_target_kind(action_id) != ATK_COUNT);
+    break;
+  }
+
+  if (explnat->kind == ANEK_MISSING_TARGET) {
+    /* No point continuing. */
+    return explnat;
+  }
 
   if (action_id == ACTION_ANY) {
     /* Find the target player of some actions. */
@@ -1172,6 +1202,11 @@
     notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
                   _("Unit cannot do anything."));
     break;
+  case ANEK_MISSING_TARGET:
+    notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
+                  _("Your %s found no suitable target."),
+                  unit_name_translation(punit));
+    break;
   case ANEK_BAD_TARGET:
     /* This shouldn't happen at the moment. Only specific action checks
      * will trigger bad target checks. This is a reply to a question about
@@ -1584,6 +1619,12 @@
                       action_id_name_translation(stopped_action));
       }
     }
+    break;
+  case ANEK_MISSING_TARGET:
+    notify_player(pplayer, unit_tile(actor), event, ftc_server,
+                  _("Your %s found no target suitable for %s."),
+                  unit_name_translation(actor),
+                  action_id_name_translation(stopped_action));
     break;
   case ANEK_BAD_TARGET:
     notify_player(pplayer, unit_tile(actor), event, ftc_server,

Modified: trunk/server/unithand.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.h?rev=34498&r1=34497&r2=34498&view=diff
==============================================================================
--- trunk/server/unithand.h     (original)
+++ trunk/server/unithand.h     Sun Nov 13 19:30:22 2016
@@ -21,6 +21,8 @@
 enum ane_kind {
   /* Explanation: wrong actor unit. */
   ANEK_ACTOR_UNIT,
+  /* Explanation: no action target. */
+  ANEK_MISSING_TARGET,
   /* Explanation: the action is redundant vs this target. */
   ANEK_BAD_TARGET,
   /* Explanation: bad actor terrain. */


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

Reply via email to