Author: sveinung
Date: Sun Oct  4 17:02:55 2015
New Revision: 30012

URL: http://svn.gna.org/viewcvs/freeciv?rev=30012&view=rev
Log:
Tell what action blocks regular attacks

Be specific about what legal action blocked the regular attack.

See patch #6388

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

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=30012&r1=30011&r2=30012&view=diff
==============================================================================
--- trunk/common/actions.c      (original)
+++ trunk/common/actions.c      Sun Oct  4 17:02:55 2015
@@ -634,35 +634,38 @@
 }
 
 /**************************************************************************
-  Returns TRUE iff an action that blocks regular attacks is forced and
-  possible.
+  Returns the action that blocks regular attacks or NULL if they aren't
+  blocked.
+
+  An action that can block regular attacks blocks them when the action is
+  forced and possible.
 
   TODO: Make regular attacks action enabler controlled and delete this
   function.
 **************************************************************************/
-bool action_blocks_attack(const struct unit *actor_unit,
-                          const struct tile *target_tile)
+struct action *action_blocks_attack(const struct unit *actor_unit,
+                                    const struct tile *target_tile)
 {
   if (capture_units_blocks(actor_unit, target_tile)) {
     /* Capture unit is possible.
      * The ruleset forbids regular attacks when it is. */
-    return TRUE;
+    return action_by_number(ACTION_CAPTURE_UNITS);
   }
 
   if (bombard_blocks(actor_unit, target_tile)) {
     /* Bomard units is possible.
      * The ruleset forbids regular attacks when it is. */
-    return TRUE;
+    return action_by_number(ACTION_BOMBARD);
   }
 
   if (explode_nuclear_blocks(actor_unit, target_tile)) {
     /* Explode nuclear is possible.
      * The ruleset forbids regular attacks when it is. */
-    return TRUE;
+    return action_by_number(ACTION_NUKE);
   }
 
   /* Nothing is blocking a regular attack. */
-  return FALSE;
+  return NULL;
 }
 
 /**************************************************************************

Modified: trunk/common/actions.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.h?rev=30012&r1=30011&r2=30012&view=diff
==============================================================================
--- trunk/common/actions.h      (original)
+++ trunk/common/actions.h      Sun Oct  4 17:02:55 2015
@@ -238,8 +238,8 @@
 action_enabler_copy(const struct action_enabler *original);
 void action_enabler_add(struct action_enabler *enabler);
 
-bool action_blocks_attack(const struct unit *actor_unit,
-                          const struct tile *target_tile);
+struct action *action_blocks_attack(const struct unit *actor_unit,
+                                    const struct tile *target_tile);
 bool action_blocks_disband(const struct unit *actor_unit);
 
 bool is_action_enabled_unit_on_city(const enum gen_action wanted_action,

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=30012&r1=30011&r2=30012&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Sun Oct  4 17:02:55 2015
@@ -2972,14 +2972,15 @@
       || is_non_allied_city_tile(pdesttile, pplayer)) {
     struct unit *victim = NULL;
     enum unit_attack_result ua_result;
-
-    if (action_blocks_attack(punit, pdesttile)) {
+    struct action *blocker;
+
+    if ((blocker = action_blocks_attack(punit, pdesttile))) {
       /* Blocked by of the attacks that now are action enabler
        * controlled. */
       notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
-                    _("Regular attack not allowed since you could have done "
-                      "Capture Units, Bombard or Explode Nuclear in "
-                      "stead."));
+                    /* TRANS: ... Capture Units ... */
+                    _("Regular attack not allowed when %s is legal."),
+                    action_get_ui_name(blocker->id));
       return FALSE;
     }
 


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

Reply via email to