Author: cazfi
Date: Wed Feb  4 03:56:36 2015
New Revision: 27951

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

See bug #23227

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

Modified: branches/S2_6/server/advisors/advbuilding.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/advisors/advbuilding.c?rev=27951&r1=27950&r2=27951&view=diff
==============================================================================
--- branches/S2_6/server/advisors/advbuilding.c (original)
+++ branches/S2_6/server/advisors/advbuilding.c Wed Feb  4 03:56:36 2015
@@ -232,18 +232,21 @@
        * These may be able to help with caravans. Also look at the whole
        * continent. */
       if (first_role_unit_for_player(pplayer,
-              action_get_role(ACTION_HELP_WONDER))) {
+                                     action_get_role(ACTION_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