Author: cazfi
Date: Wed Feb  4 03:56:49 2015
New Revision: 27953

URL: http://svn.gna.org/viewcvs/freeciv?rev=27953&view=rev
Log:
Fixed a illegal array index usage in building advisor when handling an city on 
ocean.

See bug #23227

Modified:
    branches/S2_4/server/advisors/advbuilding.c

Modified: branches/S2_4/server/advisors/advbuilding.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_4/server/advisors/advbuilding.c?rev=27953&r1=27952&r2=27953&view=diff
==============================================================================
--- branches/S2_4/server/advisors/advbuilding.c (original)
+++ branches/S2_4/server/advisors/advbuilding.c Wed Feb  4 03:56:49 2015
@@ -219,16 +219,18 @@
        * continent. */
       if (first_role_unit_for_player(pplayer, F_HELP_WONDER)) {
         value += city_data->downtown;
-        value += adv->stats.cities[place] / 8;
-      }
-      if (adv->threats.continent[place] > 0) {
+        if (place >= 0) {
+          value += adv->stats.cities[place] / 8;
+        }
+      }
+      if (place >= 0 && adv->threats.continent[place] > 0) {
         /* We have threatening neighbours: -25% */
         value -= value / 4;
       }
       /* Require that there is at least some neighbors for wonder helpers,
        * if ruleset supports it. */
       if (value > best_candidate_value
-          && (!has_help || adv->stats.cities[place] > 5)
+          && (!has_help || (place >= 0 && adv->stats.cities[place] > 5))
           && (!has_help || city_data->downtown > 3)) {
         best_candidate = pcity;
         best_candidate_value = value;


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

Reply via email to