Author: sveinung
Date: Wed Mar 16 14:08:34 2016
New Revision: 32256

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

Add detection for failed "Airlift Unit" caused by missing airlift capacity
in source or in destination city.

Remove custom "Airlift Unit" messages.

See patch #7064

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

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=32256&r1=32255&r2=32256&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Wed Mar 16 14:08:34 2016
@@ -118,6 +118,8 @@
   ANEK_CITY_TOO_BIG,
   /* Explanation: the target city's population limit banned the action. */
   ANEK_CITY_POP_LIMIT,
+  /* Explanation: the specified city don't have the needed capacity. */
+  ANEK_CITY_NO_CAPACITY,
   /* Explanation: the action is blocked by another action. */
   ANEK_ACTION_BLOCKS,
   /* Explanation not detected. */
@@ -130,6 +132,9 @@
   enum ane_kind kind;
 
   union {
+    /* The city without the needed capacity- */
+    struct city *capacity_city;
+
     /* The bad terrain in question. */
     struct terrain *no_act_terrain;
 
@@ -755,6 +760,9 @@
      * Detects that the target tile is claimed by a foreigner even when it
      * is legal to found a city on an unclaimed or domestic tile. */
     action_custom = city_build_here_test(target_tile, punit);
+    break;
+  case ACTION_AIRLIFT:
+    action_custom = test_unit_can_airlift_to(NULL, punit, target_city);
     break;
   default:
     action_custom = 0;
@@ -891,6 +899,14 @@
                                        city_size_get(target_city)
                                        + unit_pop_value(punit))))) {
     expl->kind = ANEK_CITY_POP_LIMIT;
+  } else if (action_id == ACTION_AIRLIFT
+             && action_custom == AR_SRC_NO_FLIGHTS) {
+    expl->kind = ANEK_CITY_NO_CAPACITY;
+    expl->capacity_city = tile_city(unit_tile(punit));
+  } else if (action_id == ACTION_AIRLIFT
+             && action_custom == AR_DST_NO_FLIGHTS) {
+    expl->kind = ANEK_CITY_NO_CAPACITY;
+    expl->capacity_city = game_city_by_number(target_city->id);
   } else if (action_id == ACTION_FOUND_CITY
              && action_custom == CB_NO_MIN_DIST) {
     expl->kind = ANEK_CITY_TOO_CLOSE_TGT;
@@ -1040,6 +1056,14 @@
                   _("%s needs an improvement to grow, so "
                     "%s cannot do anything to it."),
                   city_name(target_city),
+                  unit_name_translation(punit));
+    break;
+  case ANEK_CITY_NO_CAPACITY:
+    notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
+                  /* TRANS: Paris ... Warriors (think: airlift) */
+                  _("%s don't have enough capacity, so "
+                    "%s cannot do anything."),
+                  city_name(expl->capacity_city),
                   unit_name_translation(punit));
     break;
   case ANEK_ACTION_BLOCKS:
@@ -1414,6 +1438,15 @@
                   city_name(target_city),
                   unit_name_translation(actor),
                   action_get_ui_name(stopped_action));
+    break;
+  case ANEK_CITY_NO_CAPACITY:
+    notify_player(pplayer, unit_tile(actor),
+                  event, ftc_server,
+                  /* TRANS: Paris ... Airlift to City ... Warriors */
+                  _("%s has no capacity to %s %s."),
+                  city_name(expl->capacity_city),
+                  action_get_ui_name(stopped_action),
+                  unit_name_translation(actor));
     break;
   case ANEK_ACTION_BLOCKS:
     notify_player(pplayer, unit_tile(actor),

Modified: trunk/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unittools.c?rev=32256&r1=32255&r2=32256&view=diff
==============================================================================
--- trunk/server/unittools.c    (original)
+++ trunk/server/unittools.c    Wed Mar 16 14:08:34 2016
@@ -2631,45 +2631,6 @@
 {
   struct city *psrc_city = tile_city(unit_tile(punit));
 
-  {
-    enum unit_airlift_result result =
-      test_unit_can_airlift_to(NULL, punit, pdest_city);
-    if (!is_successful_airlift_result(result)) {
-      switch (result) {
-      /* These two can happen through no fault of the client (for allied
-       * airlifts), so we give useful messages. */
-      case AR_SRC_NO_FLIGHTS:
-        notify_player(unit_owner(punit), unit_tile(punit),
-                      E_UNIT_RELOCATED, ftc_server,
-                      /* TRANS: Airlift failure message.
-                       * "Paris has no capacity to transport Warriors." */
-                      _("%s has no capacity to transport %s."),
-                      city_link(psrc_city), unit_link(punit));
-        break;
-      case AR_DST_NO_FLIGHTS:
-        notify_player(unit_owner(punit), unit_tile(punit),
-                      E_UNIT_RELOCATED, ftc_server,
-                      /* TRANS: Airlift failure message.
-                       * "Paris has no capacity to transport Warriors." */
-                      _("%s has no capacity to transport %s."),
-                      city_link(pdest_city), unit_link(punit));
-        break;
-      default:
-        /* The client should have been able to foresee all the other
-         * causes of failure, so it's not worth having specific messages for
-         * all of them. */
-        notify_player(unit_owner(punit), unit_tile(punit),
-                      E_UNIT_RELOCATED, ftc_server,
-                      /* TRANS: Airlift failure message.
-                       * "Warriors cannot be transported to Paris." */
-                      _("%s cannot be transported to %s."),
-                      unit_link(punit), city_link(pdest_city));
-        break;
-      }
-      return FALSE;
-    }
-  }
-
   notify_player(unit_owner(punit), city_tile(pdest_city),
                 E_UNIT_RELOCATED, ftc_server,
                 _("%s transported successfully."),


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

Reply via email to