Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2005:
[Freeciv-Dev] Re: (PR#12996) citymindist bug
Home

[Freeciv-Dev] Re: (PR#12996) citymindist bug

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: bdunstan149@xxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#12996) citymindist bug
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 5 May 2005 20:25:19 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12996 >

Brian Dunstan wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=12996 >
> 
> Attached is a save game with citymindist set to 4, and
> where the game has allowed the ai to place a city with
> distance 2 from the next city.  In global observe
> mode, many instances of this are visible.

Looks like this is caused by the load-rulesets-on-startup change.  This
patch should fix it.  It's untested (note the savegame isn't useful
here, since the cities would already exist when it was loaded).

-jason

Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.340
diff -u -r1.340 city.c
--- common/city.c       5 May 2005 18:32:49 -0000       1.340
+++ common/city.c       6 May 2005 03:21:44 -0000
@@ -861,6 +861,8 @@
 **************************************************************************/
 bool city_can_be_built_here(const struct tile *ptile, const struct unit *punit)
 {
+  int citymindist;
+
   if (terrain_has_flag(ptile->terrain, TER_NO_CITIES)) {
     /* No cities on this terrain. */
     return FALSE;
@@ -879,7 +881,11 @@
   }
 
   /* game.info.min_dist_bw_cities minimum is 1, meaning adjacent is okay */
-  square_iterate(ptile, game.info.min_dist_bw_cities - 1, ptile1) {
+  citymindist = game.info.citymindist;
+  if (citymindist == 0) {
+    citymindist = game.info.min_dist_bw_cities;
+  }
+  square_iterate(ptile, citymindist - 1, ptile1) {
     if (ptile1->city) {
       return FALSE;
     }
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.254
diff -u -r1.254 ruleset.c
--- server/ruleset.c    5 May 2005 19:22:25 -0000       1.254
+++ server/ruleset.c    6 May 2005 03:21:45 -0000
@@ -2468,18 +2468,13 @@
                                   get_output_identifier(o));
   } output_type_iterate_end;
 
-  /* if the server variable citymindist is set (!= 0) the ruleset
-     setting is overwritten by citymindist */
-  if (game.info.citymindist == 0) {
-    game.info.min_dist_bw_cities =
-       secfile_lookup_int(&file, "civstyle.min_dist_bw_cities");
-    if (game.info.min_dist_bw_cities < 1) {
-      freelog(LOG_ERROR, "Bad value %i for min_dist_bw_cities. Using 2.",
-             game.info.min_dist_bw_cities);
-      game.info.min_dist_bw_cities = 2;
-    }
-  } else {
-    game.info.min_dist_bw_cities = game.info.citymindist;
+  /* This only takes effect if citymindist is set to 0. */
+  game.info.min_dist_bw_cities
+    = secfile_lookup_int(&file, "civstyle.min_dist_bw_cities");
+  if (game.info.min_dist_bw_cities < 1) {
+    freelog(LOG_ERROR, "Bad value %i for min_dist_bw_cities. Using 2.",
+           game.info.min_dist_bw_cities);
+    game.info.min_dist_bw_cities = 2;
   }
 
   game.info.init_vis_radius_sq =

[Prev in Thread] Current Thread [Next in Thread]