Author: cazfi
Date: Sun Dec  6 23:27:49 2015
New Revision: 30872

URL: http://svn.gna.org/viewcvs/freeciv?rev=30872&view=rev
Log:
If AI city with no defenders ends up taking fallback build target, make defender
the first fallback option.

See patch #6534

Modified:
    trunk/ai/default/aicity.c

Modified: trunk/ai/default/aicity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aicity.c?rev=30872&r1=30871&r2=30872&view=diff
==============================================================================
--- trunk/ai/default/aicity.c   (original)
+++ trunk/ai/default/aicity.c   Sun Dec  6 23:27:49 2015
@@ -303,14 +303,21 @@
       city_data->choice.value.utype
         = best_role_unit(pcity, action_get_role(ACTION_TRADE_ROUTE));
       city_data->choice.type = CT_CIVILIAN;
-    } else if (best_role_unit(pcity, UTYF_SETTLERS)) {
-      city_data->choice.value.utype
-        = dai_role_utype_for_terrain_class(pcity, UTYF_SETTLERS, TC_LAND);
-      city_data->choice.type = CT_CIVILIAN;
     } else {
-      CITY_LOG(LOG_ERROR, pcity, "Cannot even build a fallback "
-              "(caravan/coinage/settlers). Fix the ruleset!");
-      city_data->choice.want = 0;
+      unsigned int our_def = assess_defense_quadratic(ait, pcity);
+
+      if (our_def == 0
+          && dai_process_defender_want(ait, pplayer, pcity, 1, 
&(city_data->choice))) {
+        CITY_LOG(LOG_DEBUG, pcity, "Building fallback defender");
+      } else if (best_role_unit(pcity, UTYF_SETTLERS)) {
+        city_data->choice.value.utype
+          = dai_role_utype_for_terrain_class(pcity, UTYF_SETTLERS, TC_LAND);
+        city_data->choice.type = CT_CIVILIAN;
+      } else {
+        CITY_LOG(LOG_ERROR, pcity, "Cannot even build a fallback "
+                 "(caravan/coinage/settlers). Fix the ruleset!");
+        city_data->choice.want = 0;
+      }
     }
   }
 


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

Reply via email to