Author: cazfi
Date: Fri Dec 12 19:03:59 2014
New Revision: 27268

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

Modified: branches/S2_5/ai/default/aicity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/ai/default/aicity.c?rev=27268&r1=27267&r2=27268&view=diff
==============================================================================
--- branches/S2_5/ai/default/aicity.c   (original)
+++ branches/S2_5/ai/default/aicity.c   Fri Dec 12 19:03:59 2014
@@ -691,7 +691,7 @@
     /* We don't like disbanding the city as a side effect */
     return;
   }
-  /* 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
@@ -704,9 +704,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