Author: sveinung
Date: Wed Dec 16 05:02:59 2015
New Revision: 31010

URL: http://svn.gna.org/viewcvs/freeciv?rev=31010&view=rev
Log:
Action not enabled explain add to size limit

Replace UAB_TOO_BIG with an action not enabled explanation. No support for
checking if a !present MinSize requirement makes the city to big included.

See patch #6682

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

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=31010&r1=31009&r2=31010&view=diff
==============================================================================
--- trunk/common/actions.c      (original)
+++ trunk/common/actions.c      Wed Dec 16 05:02:59 2015
@@ -1198,6 +1198,20 @@
   }
 
   if (wanted_action == ACTION_JOIN_CITY) {
+    int new_pop;
+
+    if (!omniscient
+        && !mke_can_see_city_externals(actor_player, target_city)) {
+      return TRI_MAYBE;
+    }
+
+    new_pop = city_size_get(target_city) + unit_pop_value(actor_unit);
+
+    if (new_pop > game.info.add_to_size_limit) {
+      /* Reason: Make the add_to_size_limit setting work. */
+      return TRI_NO;
+    }
+
     /* TODO: Move more individual requirements to the action enabler. */
     if (!unit_can_add_to_city(actor_unit, target_city)) {
       return TRI_NO;

Modified: trunk/common/unit.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/unit.c?rev=31010&r1=31009&r2=31010&view=diff
==============================================================================
--- trunk/common/unit.c (original)
+++ trunk/common/unit.c Wed Dec 16 05:02:59 2015
@@ -416,9 +416,6 @@
   fc_assert(unit_pop_value(punit) > 0);
   new_pop = city_size_get(pcity) + unit_pop_value(punit);
 
-  if (new_pop > game.info.add_to_size_limit) {
-    return UAB_TOO_BIG;
-  }
   if (!city_can_grow_to(pcity, new_pop)) {
     return UAB_NO_SPACE;
   }

Modified: trunk/common/unit.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/unit.h?rev=31010&r1=31009&r2=31010&view=diff
==============================================================================
--- trunk/common/unit.h (original)
+++ trunk/common/unit.h Wed Dec 16 05:02:59 2015
@@ -61,7 +61,6 @@
   UAB_BAD_UNIT_TERRAIN, /* Equivalent to 'CB_BAD_UNIT_TERRAIN'. */
   UAB_BAD_BORDERS,      /* Equivalent to 'CB_BAD_BORDERS'. */
   UAB_NO_MIN_DIST,      /* Equivalent to 'CB_NO_MIN_DIST'. */
-  UAB_TOO_BIG,          /* City is too big to be added to. */
   UAB_NO_SPACE          /* Adding takes city past limit. */
 };
 

Modified: trunk/server/cityhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/cityhand.c?rev=31010&r1=31009&r2=31010&view=diff
==============================================================================
--- trunk/server/cityhand.c     (original)
+++ trunk/server/cityhand.c     Wed Dec 16 05:02:59 2015
@@ -89,7 +89,6 @@
     break;
 
   case UAB_ADD_OK:
-  case UAB_TOO_BIG:
   case UAB_NO_SPACE:
     log_verbose("handle_city_name_suggest_req(unit_pos (%d, %d)): "
                 "there is already a city there.", TILE_XY(unit_tile(punit)));

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=31010&r1=31009&r2=31010&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Wed Dec 16 05:02:59 2015
@@ -100,6 +100,8 @@
   ANEK_TGT_IS_UNCLAIMED,
   /* Explanation: the action is disabled in this scenario. */
   ANEK_SCENARIO_DISABLED,
+  /* Explanation: the target city is too big. */
+  ANEK_CITY_TOO_BIG,
   /* Explanation: the action is blocked by another action. */
   ANEK_ACTION_BLOCKS,
   /* Explanation not detected. */
@@ -762,6 +764,15 @@
                                              CITYT_CLAIMED,
                                              FALSE)) {
     expl->kind = ANEK_TGT_IS_UNCLAIMED;
+  } else if (target_city
+             && (action_id == ACTION_JOIN_CITY
+                 && action_actor_utype_hard_reqs_ok(ACTION_JOIN_CITY,
+                                                    unit_type_get(punit))
+                 && (city_size_get(target_city) + unit_pop_value(punit)
+                     > game.info.add_to_size_limit))) {
+    /* TODO: Check max city size requirements from action enabler target
+     * vectors. */
+    expl->kind = ANEK_CITY_TOO_BIG;
   } else if ((game.scenario.prevent_new_cities
               && utype_can_do_action(unit_type_get(punit), ACTION_FOUND_CITY))
              && (action_id == ACTION_FOUND_CITY
@@ -858,6 +869,13 @@
   case ANEK_SCENARIO_DISABLED:
     notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
                   _("Can't perform any action this scenario permits."));
+    break;
+  case ANEK_CITY_TOO_BIG:
+    notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
+                  /* TRANS: Settler ... Berlin */
+                  _("%s can't do anything to %s. It is too big."),
+                  unit_name_translation(punit),
+                  city_name(target_city));
     break;
   case ANEK_ACTION_BLOCKS:
     /* If an action blocked another action the blocking action must be
@@ -1176,6 +1194,15 @@
                   _("Can't do %s in this scenario."),
                   gen_action_translated_name(stopped_action));
     break;
+  case ANEK_CITY_TOO_BIG:
+    notify_player(pplayer, unit_tile(actor),
+                  event, ftc_server,
+                  /* TRANS: Settlers ... Join City ... London */
+                  _("%s can't do %s to %s. It is too big."),
+                  unit_name_translation(actor),
+                  gen_action_translated_name(stopped_action),
+                  city_name(target_city));
+    break;
   case ANEK_ACTION_BLOCKS:
     notify_player(pplayer, unit_tile(actor),
                   event, ftc_server,
@@ -2066,11 +2093,6 @@
     notify_player(pplayer, ptile, E_BAD_COMMAND, ftc_server,
                   _("Can't place a city there because another city is too "
                     "close."));
-    break;
-  case UAB_TOO_BIG:
-    notify_player(pplayer, ptile, E_BAD_COMMAND, ftc_server,
-                  _("%s is too big to add %s."),
-                  city_link(pcity), unit_link(punit));
     break;
   case UAB_NO_SPACE:
     notify_player(pplayer, ptile, E_BAD_COMMAND, ftc_server,


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

Reply via email to