Author: cazfi
Date: Fri Dec 12 19:04:05 2014
New Revision: 27269

URL: http://svn.gna.org/viewcvs/freeciv?rev=27269&view=rev
Log:
Prevented AI settlers from accessing advisor stats from illegal index when
considering improvements for ocean city.

See bug #23046

Modified:
    branches/S2_4/ai/default/aicity.c

Modified: branches/S2_4/ai/default/aicity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_4/ai/default/aicity.c?rev=27269&r1=27268&r2=27269&view=diff
==============================================================================
--- branches/S2_4/ai/default/aicity.c   (original)
+++ branches/S2_4/ai/default/aicity.c   Fri Dec 12 19:04:05 2014
@@ -661,7 +661,8 @@
   unit_tile_set(virtualunit, pcenter);
   want = settler_evaluate_improvements(virtualunit, &best_act, &best_tile,
                                        NULL, NULL);
-  /* We consider unit_food_upkeep with only hald FOOD_WEIGHTING to
+
+  /* We consider unit_food_upkeep with only half FOOD_WEIGHTING to
    * balance the fact that unit can improve many tiles during its
    * lifetime, and want is calculated for just one of them.
    * Having full FOOD_WEIGHT here would mean that tile improvement of
@@ -674,9 +675,13 @@
   /* Massage our desire based on available statistics to prevent
    * overflooding with worker type units if they come cheap in
    * the ruleset */
-  want /= MAX(1, ai->stats.workers[place]
-                 / (ai->stats.cities[place] + 1));
-  want -= ai->stats.workers[place];
+  if (place >= 0) {
+    want /= MAX(1, ai->stats.workers[place]
+                / (ai->stats.cities[place] + 1));
+    want -= ai->stats.workers[place];
+  } else {
+    /* TODO: Handle Oceans with cities sensibly */
+  }
   want = MAX(want, 0);
 
   CITY_LOG(LOG_DEBUG, pcity, "wants %s with want %d to do %s at (%d,%d), "


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

Reply via email to