Author: sveinung
Date: Thu Dec 25 22:14:51 2014
New Revision: 27409

AI: Get a fall back trade route unit to build of one exists.

Request the best unit capable of the action Establish Trade Route in stead
of requesting the best unit with the TradeRoute unit type flag and aborting
if it can't do Establish Trade Route.

This adds support for rulesets where a unit without the TradeRoute unit type
flag is capable of the Establish Trade Route action or where a unit with the
TradeRoute flag incapable of establishing a trade route is "better" than one
that can.

See patch #5602


Modified: trunk/ai/default/aicity.c
--- trunk/ai/default/aicity.c   (original)
+++ trunk/ai/default/aicity.c   Thu Dec 25 22:14:51 2014
@@ -298,11 +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)
-        && utype_can_do_action(best_role_unit(pcity, UTYF_TRADE_ROUTE),
-                               ACTION_TRADE_ROUTE)) {
+    if (best_role_unit(pcity, action_get_role(ACTION_TRADE_ROUTE))) {
-        = best_role_unit(pcity, UTYF_TRADE_ROUTE);
+        = best_role_unit(pcity, action_get_role(ACTION_TRADE_ROUTE));
       city_data->choice.type = CT_CIVILIAN;
     } else if (best_role_unit(pcity, UTYF_SETTLERS)) {

Freeciv-commits mailing list

Reply via email to