Author: sveinung
Date: Wed Dec  3 21:48:49 2014
New Revision: 27171

URL: http://svn.gna.org/viewcvs/freeciv?rev=27171&view=rev
Log:
AI: Don't build units that can't establish trade routes for that purpose.

Because of action enabler control over Establish Trade Route a unit type may
have the TradeRoute flag but still be incapable of establish a trade route.
Don't build units that can't establish trade routes for the purpose of
establishing trade routes.

See patch #5478

Modified:
    trunk/ai/default/advdomestic.c
    trunk/ai/default/aicity.c

Modified: trunk/ai/default/advdomestic.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/advdomestic.c?rev=27171&r1=27170&r2=27171&view=diff
==============================================================================
--- trunk/ai/default/advdomestic.c      (original)
+++ trunk/ai/default/advdomestic.c      Wed Dec  3 21:48:49 2014
@@ -274,6 +274,11 @@
     unit_type = get_role_unit(UTYF_TRADE_ROUTE, 0);
   }
 
+  if (!utype_can_do_action(unit_type, ACTION_TRADE_ROUTE)) {
+    /* This unit type isn't suitable for establishing trade routes. */
+    return;
+  }
+
   trade_routes = city_num_trade_routes(pcity);
   /* Count also caravans enroute to establish traderoutes */
   unit_list_iterate(pcity->units_supported, punit) {

Modified: trunk/ai/default/aicity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aicity.c?rev=27171&r1=27170&r2=27171&view=diff
==============================================================================
--- trunk/ai/default/aicity.c   (original)
+++ trunk/ai/default/aicity.c   Wed Dec  3 21:48:49 2014
@@ -298,7 +298,9 @@
     CITY_LOG(LOG_WANT, pcity, "Falling back - didn't want to build soldiers,"
             " workers, caravans, settlers, or buildings!");
     city_data->choice.want = 1;
-    if (best_role_unit(pcity, UTYF_TRADE_ROUTE)) {
+    if (best_role_unit(pcity, UTYF_TRADE_ROUTE)
+        && utype_can_do_action(best_role_unit(pcity, UTYF_TRADE_ROUTE),
+                               ACTION_TRADE_ROUTE)) {
       city_data->choice.value.utype
         = best_role_unit(pcity, UTYF_TRADE_ROUTE);
       city_data->choice.type = CT_CIVILIAN;


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

Reply via email to