Author: cazfi
Date: Sun Dec  6 23:27:56 2015
New Revision: 30873

URL: http://svn.gna.org/viewcvs/freeciv?rev=30873&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:
    branches/S2_6/ai/default/aicity.c

Modified: branches/S2_6/ai/default/aicity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/ai/default/aicity.c?rev=30873&r1=30872&r2=30873&view=diff
==============================================================================
--- branches/S2_6/ai/default/aicity.c   (original)
+++ branches/S2_6/ai/default/aicity.c   Sun Dec  6 23:27:56 2015
@@ -302,14 +302,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