Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9824) problems with counting adjacent tiles in hex top
Home

[Freeciv-Dev] (PR#9824) problems with counting adjacent tiles in hex top

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9824) problems with counting adjacent tiles in hex topologies
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 26 Aug 2004 19:34:35 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9824 >

> [jdorje - Thu Aug 26 21:03:53 2004]:
> 
> Several places count the number of tiles adjacent to a current tile:
> 
> - When transforming ocean<->land.
> - When calculating borders.
> - Who knows where else?
> 
> Obviously this won't work very well with hex topologies.
> 
> My solution would be to turn these values into percentages rather than 
> total values.

The idea is good.  The existing code is ugly and there's some
opportunity to improve it.  Here's a patch that does it all.  This is
probably a bit too complicated for a single patch, though.

count_special_near_tile, count_terrain_near_tile, and
count_terrain_flag_near_tile should probably all be merged somehow.  In
the patch I merge the cardinal and non-cardinal versions, which is a
good step I think.

jason

Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.397
diff -u -r1.397 packhand.c
--- client/packhand.c   26 Aug 2004 18:37:51 -0000      1.397
+++ client/packhand.c   27 Aug 2004 02:30:26 -0000
@@ -2628,28 +2628,7 @@
 **************************************************************************/
 void handle_ruleset_terrain_control(struct terrain_misc *p)
 {
-  terrain_control.may_road = p->may_road;
-  terrain_control.may_irrigate = p->may_irrigate;
-  terrain_control.may_mine = p->may_mine;
-  terrain_control.may_transform = p->may_transform;
-  terrain_control.ocean_reclaim_requirement = p->ocean_reclaim_requirement;
-  terrain_control.land_channel_requirement = p->land_channel_requirement;
-  terrain_control.river_move_mode = p->river_move_mode;
-  terrain_control.river_defense_bonus = p->river_defense_bonus;
-  terrain_control.river_trade_incr = p->river_trade_incr;
-  sz_strlcpy(terrain_control.river_help_text, p->river_help_text);
-  terrain_control.fortress_defense_bonus = p->fortress_defense_bonus;
-  terrain_control.road_superhighway_trade_bonus = 
p->road_superhighway_trade_bonus;
-  terrain_control.rail_food_bonus = p->rail_food_bonus;
-  terrain_control.rail_shield_bonus = p->rail_shield_bonus;
-  terrain_control.rail_trade_bonus = p->rail_trade_bonus;
-  terrain_control.farmland_supermarket_food_bonus = 
p->farmland_supermarket_food_bonus;
-  terrain_control.pollution_food_penalty = p->pollution_food_penalty;
-  terrain_control.pollution_shield_penalty = p->pollution_shield_penalty;
-  terrain_control.pollution_trade_penalty = p->pollution_trade_penalty;
-  terrain_control.fallout_food_penalty = p->fallout_food_penalty;
-  terrain_control.fallout_shield_penalty = p->fallout_shield_penalty;
-  terrain_control.fallout_trade_penalty = p->fallout_trade_penalty;
+  terrain_control = *p;
 }
 
 /**************************************************************************
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.188
diff -u -r1.188 map.c
--- common/map.c        25 Aug 2004 18:24:19 -0000      1.188
+++ common/map.c        27 Aug 2004 02:30:26 -0000
@@ -593,16 +593,26 @@
 /***************************************************************
   counts tiles close to x,y having special spe
 ***************************************************************/
-int count_special_near_tile(int x, int y, enum tile_special_type spe)
+int count_special_near_tile_pct(int x, int y, bool cardinal_only,
+                               enum tile_special_type spe)
 {
-  int count = 0;
+  enum direction8 *dirlist;
+  int total, count = 0;
 
-  adjc_iterate(x, y, x1, y1) {
+  if (cardinal_only) {
+    dirlist = map.cardinal_dirs;
+    total = map.num_cardinal_dirs;
+  } else {
+    dirlist = map.valid_dirs;
+    total = map.num_valid_dirs;
+  }
+
+  adjc_dirlist_iterate(x, y, x1, y1, dir, dirlist, total) {
     if (map_has_special(x1, y1, spe))
       count++;
-  } adjc_iterate_end;
+  } adjc_dirlist_iterate_end;
 
-  return count;
+  return count * 100 / total;
 }
 
 /*************************************************************************
@@ -1014,20 +1024,9 @@
 **************************************************************************/
 bool can_reclaim_ocean(int x, int y)
 {
-  int landtiles = terrain_control.ocean_reclaim_requirement;
-
-  if (landtiles >= 9)
-    return FALSE;
-  if (landtiles <= 0)
-    return TRUE;
-
-  adjc_iterate(x, y, x1, y1) {
-    if (!is_ocean(map_get_tile(x1, y1)->terrain))
-      if (--landtiles == 0)
-       return TRUE;    
-  } adjc_iterate_end;
+  int land_tiles = 100 - count_ocean_near_tile_pct(x, y, FALSE);
 
-  return FALSE;
+  return (land_tiles >= terrain_control.ocean_reclaim_requirement_pct);
 }
 
 /**************************************************************************
@@ -1037,20 +1036,9 @@
 **************************************************************************/
 bool can_channel_land(int x, int y)
 {
-  int oceantiles = terrain_control.land_channel_requirement;
-
-  if (oceantiles >= 9)
-    return FALSE;
-  if (oceantiles <= 0)
-    return TRUE;
+  int ocean_tiles = count_ocean_near_tile_pct(x, y, FALSE);
 
-  adjc_iterate(x, y, x1, y1) {
-    if (is_ocean(map_get_tile(x1, y1)->terrain))
-      if (--oceantiles == 0)
-       return TRUE;
-  } adjc_iterate_end;
-
-  return FALSE;
+  return (ocean_tiles >= terrain_control.land_channel_requirement_pct);
 }
 
 /***************************************************************
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.210
diff -u -r1.210 map.h
--- common/map.h        26 Aug 2004 18:37:52 -0000      1.210
+++ common/map.h        27 Aug 2004 02:30:26 -0000
@@ -389,7 +389,8 @@
 enum tile_special_type get_special_by_name(const char * name);
 const char *get_special_name(enum tile_special_type type);
 bool is_special_near_tile(int x, int y, enum tile_special_type spe);
-int count_special_near_tile(int x, int y, enum tile_special_type spe);
+int count_special_near_tile_pct(int x, int y, bool cardinal_only,
+                               enum tile_special_type spe);
 bool is_safe_ocean(int x, int y);
 bool is_cardinally_adj_to_ocean(int x, int y);
 bool is_sea_usable(int x, int y);
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.42
diff -u -r1.42 packets.def
--- common/packets.def  26 Aug 2004 18:37:52 -0000      1.42
+++ common/packets.def  27 Aug 2004 02:30:26 -0000
@@ -1085,8 +1085,8 @@
   BOOL may_transform;  /* may transform terrain */
 
   /* parameters */
-  UINT8 ocean_reclaim_requirement;     /* # adjacent land tiles for reclaim */
-  UINT8 land_channel_requirement;      /* # adjacent ocean tiles for channel */
+  UINT8 ocean_reclaim_requirement_pct; /* % adjacent land tiles for reclaim */
+  UINT8 land_channel_requirement_pct;  /* % adjacent ocean tiles for channel */
   RIVER_MOVE river_move_mode;
 
   UINT16 river_defense_bonus;           /* % added to defense if Civ2 river */
Index: common/terrain.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/terrain.c,v
retrieving revision 1.11
diff -u -r1.11 terrain.c
--- common/terrain.c    25 Aug 2004 18:57:07 -0000      1.11
+++ common/terrain.c    27 Aug 2004 02:30:26 -0000
@@ -145,35 +145,32 @@
 }
 
 /****************************************************************************
-  Return the number of adjacent tiles that have the given terrain.
-****************************************************************************/
-int count_terrain_near_tile(int map_x, int map_y, Terrain_type_id t)
-{
-  int count = 0;
+  Return the percentage of adjacent tiles (rounded down) that have the given
+  terrain.
 
-  adjc_iterate(map_x, map_y, adjc_x, adjc_y) {
-    if (map_get_terrain(adjc_x, adjc_y) == t) {
-      count++;
-    }
-  } adjc_iterate_end;
-
-  return count;
-}
-
-/****************************************************************************
-  Return the number of cardinally adjacent tiles that have the given terrain.
+  If cardinal_only is specified then only cardinal directions are considered.
 ****************************************************************************/
-int adjacent_terrain_tiles4(int map_x, int map_y, Terrain_type_id t)
+int count_terrain_near_tile_pct(int map_x, int map_y, bool cardinal_only,
+                               Terrain_type_id t)
 {
-  int num_adjacent = 0;
+  enum direction8 *dirlist;
+  int total, count = 0;
+
+  if (cardinal_only) {
+    dirlist = map.cardinal_dirs;
+    total = map.num_cardinal_dirs;
+  } else {
+    dirlist = map.valid_dirs;
+    total = map.num_valid_dirs;
+  }
 
-  cardinal_adjc_iterate(map_x, map_y, adjc_x, adjc_y) {
+  adjc_dirlist_iterate(map_x, map_y, adjc_x, adjc_y, dir, dirlist, total) {
     if (map_get_terrain(adjc_x, adjc_y) == t) {
-      num_adjacent++;
+      count++;
     }
-  } cardinal_adjc_iterate_end;
+  } adjc_dirlist_iterate_end;
 
-  return num_adjacent;
+  return count * 100 / total;
 }
 
 /****************************************************************************
@@ -192,36 +189,31 @@
 }
 
 /****************************************************************************
-  Return the number of adjacent tiles that have terrain with the given flag.
-****************************************************************************/
-int count_terrain_flag_near_tile(int map_x, int map_y,
-                                enum terrain_flag_id flag)
-{
-  int count = 0;
+  Return the percentage of adjacent tiles (rounded down) that have the given
+  terrain flag.
 
-  adjc_iterate(map_x, map_y, adjc_x, adjc_y) {
-    if (terrain_has_flag(map_get_terrain(adjc_x, adjc_y), flag)) {
-      count++;
-    }
-  } adjc_iterate_end;
-
-  return count;
-}
-
-/****************************************************************************
-  Return the number of cardinally adjacent tiles that have terrain with
-  the given flag.
+  If cardinal_only is specified then only cardinal directions are considered.
 ****************************************************************************/
-int adjacent_terrain_flag_tiles4(int map_x, int map_y,
-                                enum terrain_flag_id flag)
+int count_terrain_flag_near_tile_pct(int map_x, int map_y,
+                                    bool cardinal_only,
+                                    enum terrain_flag_id flag)
 {
-  int num_adjacent = 0;
+  enum direction8 *dirlist;
+  int total, count = 0;
+
+  if (cardinal_only) {
+    dirlist = map.cardinal_dirs;
+    total = map.num_cardinal_dirs;
+  } else {
+    dirlist = map.valid_dirs;
+    total = map.num_valid_dirs;
+  }
 
-  cardinal_adjc_iterate(map_x, map_y, adjc_x, adjc_y) {
+  adjc_dirlist_iterate(map_x, map_y, adjc_x, adjc_y, dir, dirlist, total) {
     if (terrain_has_flag(map_get_terrain(adjc_x, adjc_y), flag)) {
-      num_adjacent++;
+      count++;
     }
-  } cardinal_adjc_iterate_end;
+  } adjc_dirlist_iterate_end;
 
-  return num_adjacent;
+  return count * 100 / total;
 }
Index: common/terrain.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/terrain.h,v
retrieving revision 1.20
diff -u -r1.20 terrain.h
--- common/terrain.h    25 Aug 2004 18:57:07 -0000      1.20
+++ common/terrain.h    27 Aug 2004 02:30:26 -0000
@@ -113,21 +113,20 @@
 
 /* Functions to operate on a general terrain type. */
 bool is_terrain_near_tile(int map_x, int map_y, Terrain_type_id t);
-int count_terrain_near_tile(int map_x, int map_y, Terrain_type_id t);
-int adjacent_terrain_tiles4(int map_x, int map_y, Terrain_type_id t);
+int count_terrain_near_tile_pct(int map_x, int map_y, bool cardinal_only,
+                               Terrain_type_id t);
 
 /* Functions to operate on a terrain flag. */
 bool is_terrain_flag_near_tile(int x, int y, enum terrain_flag_id flag);
-int count_terrain_flag_near_tile(int x, int y, enum terrain_flag_id flag);
-int adjacent_terrain_flag_tiles4(int x, int y, enum terrain_flag_id flag);
+int count_terrain_flag_near_tile_pct(int map_x, int map_y,
+                                    bool cardinal_only,
+                                    enum terrain_flag_id flag);
 
 /* Terrain-specific functions. */
 #define is_ocean(x) (terrain_has_flag((x), TER_OCEANIC))
 #define is_ocean_near_tile(x, y) is_terrain_flag_near_tile(x, y, TER_OCEANIC)
-#define adjacent_ocean_tiles4(x, y) \
-         adjacent_terrain_flag_tiles4(x, y, TER_OCEANIC)
-#define count_ocean_near_tile(x, y) \
-         count_terrain_flag_near_tile(x, y, TER_OCEANIC)
+#define count_ocean_near_tile_pct(x, y, cardinal_only)                 \
+  count_terrain_flag_near_tile_pct(x, y, cardinal_only, TER_OCEANIC)
 
 /* This iterator iterates over all terrain types. */
 #define terrain_type_iterate(id)                                            \
Index: data/civ1/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/terrain.ruleset,v
retrieving revision 1.27
diff -u -r1.27 terrain.ruleset
--- data/civ1/terrain.ruleset   24 Aug 2004 01:59:43 -0000      1.27
+++ data/civ1/terrain.ruleset   27 Aug 2004 02:30:26 -0000
@@ -22,13 +22,13 @@
 
 [parameters]
 
-; number of "land" tiles required to be adjacent to an ocean tile before
-; it may be "reclaimed" into a land tile (0-9; 0=anywhere, 9=nowhere)
-ocean_reclaim_requirement=9
-
-; number of "ocean" tiles required to be adjacent to a land tile before
-; it may be "channeled" into an ocean tile (0-9; 0=anywhere, 9=nowhere)
-land_channel_requirement=9
+; Percentage of "land" tiles required to be adjacent to an ocean tile before
+; it may be "reclaimed" into a land tile (0-101; 0=anywhere, 101=nowhere)
+ocean_reclaim_requirement_pct=101
+
+; Percentage of "ocean" tiles required to be adjacent to a land tile before
+; it may be "channeled" into an ocean tile (0-101; 0=anywhere, 101=nowhere)
+land_channel_requirement_pct=101
 
 ; special movement costs for rivers:
 ;   0 - normal movement cost for rivers (matches Civ1)
Index: data/civ2/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/terrain.ruleset,v
retrieving revision 1.29
diff -u -r1.29 terrain.ruleset
--- data/civ2/terrain.ruleset   24 Aug 2004 01:59:43 -0000      1.29
+++ data/civ2/terrain.ruleset   27 Aug 2004 02:30:27 -0000
@@ -22,13 +22,13 @@
 
 [parameters]
 
-; number of "land" tiles required to be adjacent to an ocean tile before
-; it may be "reclaimed" into a land tile (0-9; 0=anywhere, 9=nowhere)
-ocean_reclaim_requirement=9
-
-; number of "ocean" tiles required to be adjacent to a land tile before
-; it may be "channeled" into an ocean tile (0-9; 0=anywhere, 9=nowhere)
-land_channel_requirement=9
+; Percentage of "land" tiles required to be adjacent to an ocean tile before
+; it may be "reclaimed" into a land tile (0-101; 0=anywhere, 101=nowhere)
+ocean_reclaim_requirement_pct=101
+
+; Percentage of "ocean" tiles required to be adjacent to a land tile before
+; it may be "channeled" into an ocean tile (0-101; 0=anywhere, 101=nowhere)
+land_channel_requirement_pct=101
 
 ; special movement costs for rivers:
 ;   0 - normal movement cost for rivers (matches Civ1)
Index: data/default/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/terrain.ruleset,v
retrieving revision 1.30
diff -u -r1.30 terrain.ruleset
--- data/default/terrain.ruleset        24 Aug 2004 01:59:43 -0000      1.30
+++ data/default/terrain.ruleset        27 Aug 2004 02:30:27 -0000
@@ -22,13 +22,13 @@
 
 [parameters]
 
-; number of "land" tiles required to be adjacent to an ocean tile before
-; it may be "reclaimed" into a land tile (0-9; 0=anywhere, 9=nowhere)
-ocean_reclaim_requirement=3
-
-; number of "ocean" tiles required to be adjacent to a land tile before
-; it may be "channeled" into an ocean tile (0-9; 0=anywhere, 9=nowhere)
-land_channel_requirement=1
+; Percentage of "land" tiles required to be adjacent to an ocean tile before
+; it may be "reclaimed" into a land tile (0-101; 0=anywhere, 101=nowhere)
+ocean_reclaim_requirement_pct=30
+
+; Percentage of "ocean" tiles required to be adjacent to a land tile before
+; it may be "channeled" into an ocean tile (0-101; 0=anywhere, 101=nowhere)
+land_channel_requirement_pct=10
 
 ; special movement costs for rivers:
 ;   0 - normal movement cost for rivers (matches Civ1)
Index: data/history/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/terrain.ruleset,v
retrieving revision 1.12
diff -u -r1.12 terrain.ruleset
--- data/history/terrain.ruleset        24 Aug 2004 01:59:43 -0000      1.12
+++ data/history/terrain.ruleset        27 Aug 2004 02:30:27 -0000
@@ -22,13 +22,13 @@
 
 [parameters]
 
-; number of "land" tiles required to be adjacent to an ocean tile before
-; it may be "reclaimed" into a land tile (0-9; 0=anywhere, 9=nowhere)
-ocean_reclaim_requirement=3
-
-; number of "ocean" tiles required to be adjacent to a land tile before
-; it may be "channeled" into an ocean tile (0-9; 0=anywhere, 9=nowhere)
-land_channel_requirement=1
+; Percentage of "land" tiles required to be adjacent to an ocean tile before
+; it may be "reclaimed" into a land tile (0-101; 0=anywhere, 101=nowhere)
+ocean_reclaim_requirement_pct=30
+
+; Percentage of "ocean" tiles required to be adjacent to a land tile before
+; it may be "channeled" into an ocean tile (0-101; 0=anywhere, 101=nowhere)
+land_channel_requirement_pct=10
 
 ; special movement costs for rivers:
 ;   0 - normal movement cost for rivers (matches Civ1)
Index: server/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v
retrieving revision 1.148
diff -u -r1.148 mapgen.c
--- server/mapgen.c     25 Aug 2004 18:24:20 -0000      1.148
+++ server/mapgen.c     27 Aug 2004 02:30:28 -0000
@@ -563,23 +563,6 @@
 }
 
 /*********************************************************************
- Returns the number of adjacent river tiles of a tile. This can be 0
- to 4.                                                     -Erik Sigra
-*********************************************************************/
-static int adjacent_river_tiles4(int x, int y)
-{
-  int num_adjacent  = 0;
-
-  cardinal_adjc_iterate(x, y, x1, y1) {
-    if (map_has_special(x1, y1, S_RIVER)) {
-      num_adjacent++;
-    }
-  } cardinal_adjc_iterate_end;
-
-  return num_adjacent;
-}
-
-/*********************************************************************
  Help function used in make_river(). See the help there.
 *********************************************************************/
 static int river_test_blocked(int x, int y)
@@ -601,7 +584,13 @@
 *********************************************************************/
 static int river_test_rivergrid(int x, int y)
 {
-  return (adjacent_river_tiles4(x, y) > 1) ? 1 : 0;
+  int cutoff = 100 / map.num_cardinal_dirs;
+
+  if (count_special_near_tile_pct(x, y, TRUE, S_RIVER) > cutoff) {
+    return 1;
+  } else {
+    return 0;
+  }
 }
 
 /*********************************************************************
@@ -618,7 +607,7 @@
 *********************************************************************/
 static int river_test_adjacent_ocean(int x, int y)
 {
-  return 4 - adjacent_ocean_tiles4(x, y);
+  return 100 - count_ocean_near_tile_pct(x, y, TRUE);
 }
 
 /*********************************************************************
@@ -626,7 +615,7 @@
 *********************************************************************/
 static int river_test_adjacent_river(int x, int y)
 {
-  return 4 - adjacent_river_tiles4(x, y);
+  return 100 - count_special_near_tile_pct(x, y, TRUE, S_RIVER);
 }
 
 /*********************************************************************
@@ -634,9 +623,8 @@
 *********************************************************************/
 static int river_test_adjacent_highlands(int x, int y)
 {
-  return
-    adjacent_terrain_tiles4(x, y, T_HILLS) +
-    2 * adjacent_terrain_tiles4(x, y , T_MOUNTAINS);
+  return (count_terrain_near_tile_pct(x, y, TRUE, T_HILLS)
+         + 2 * count_terrain_near_tile_pct(x, y, TRUE, T_MOUNTAINS));
 }
 
 /*********************************************************************
@@ -652,7 +640,7 @@
 *********************************************************************/
 static int river_test_adjacent_swamp(int x, int y)
 {
-  return 4 - adjacent_terrain_tiles4(x, y, T_SWAMP);
+  return 100 - count_terrain_near_tile_pct(x, y, TRUE, T_SWAMP);
 }
 
 /*********************************************************************
@@ -809,8 +797,8 @@
 
     /* Test if the river is done. */
     /* We arbitrarily make rivers end at the poles. */
-    if (adjacent_river_tiles4(x, y) != 0
-       || adjacent_ocean_tiles4(x, y) != 0
+    if (count_special_near_tile_pct(x, y, TRUE, S_RIVER) > 0
+       || count_ocean_near_tile_pct(x, y, TRUE) > 0
         || (map_get_terrain(x, y) == T_ARCTIC 
            && map_temperature(x, y) < 8 * MAX_TEMP / 100)) { 
 
@@ -953,15 +941,16 @@
 
        /* Don't start a river on a tile is surrounded by > 1 river +
           ocean tile. */
-       adjacent_river_tiles4(x, y) +
-       adjacent_ocean_tiles4(x, y) <= 1 &&
+       (count_special_near_tile_pct(x, y, TRUE, S_RIVER)
+        + count_ocean_near_tile_pct(x, y, TRUE)
+        <= 100 / map.num_cardinal_dirs) &&
 
        /* Don't start a river on a tile that is surrounded by hills or
           mountains unless it is hard to find somewhere else to start
           it. */
-       (adjacent_terrain_tiles4(x, y, T_HILLS) +
-        adjacent_terrain_tiles4(x, y, T_MOUNTAINS) < 4 ||
-        iteration_counter == RIVERS_MAXTRIES/10 * 5) &&
+       (count_terrain_near_tile_pct(x, y, TRUE, T_HILLS)
+        + count_terrain_near_tile_pct(x, y, TRUE, T_MOUNTAINS) < 90
+        || iteration_counter == RIVERS_MAXTRIES/10 * 5) &&
 
        /* Don't start a river on hills unless it is hard to find
           somewhere else to start it. */
@@ -1955,13 +1944,13 @@
       /* the first condition helps make terrain more contiguous,
         the second lets it avoid the coast: */
       if ( ( i*3>k*2 
-            || count_special_near_tile(x, y, S_RIVER) > 0
+            || count_special_near_tile_pct(x, y, FALSE, S_RIVER) > 0
             || myrand(100)<50 
             )
           &&( !is_cardinally_adj_to_ocean(x, y) || myrand(100) < coast )) {
        if (is_water_adjacent_to_tile(x, y) &&
-           count_ocean_near_tile(x, y) < 4 &&
-            count_special_near_tile(x, y, S_RIVER) < 3) {
+           count_ocean_near_tile_pct(x, y, FALSE) < 50 &&
+            count_special_near_tile_pct(x, y, FALSE, S_RIVER) < 30) {
          map_set_special(x, y, S_RIVER);
          i--;
        }
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.190
diff -u -r1.190 ruleset.c
--- server/ruleset.c    25 Aug 2004 18:57:07 -0000      1.190
+++ server/ruleset.c    27 Aug 2004 02:30:29 -0000
@@ -1552,10 +1552,10 @@
 
   /* parameters */
 
-  terrain_control.ocean_reclaim_requirement =
-    secfile_lookup_int_default(file, 9, 
"parameters.ocean_reclaim_requirement");
-  terrain_control.land_channel_requirement =
-    secfile_lookup_int_default(file, 9, "parameters.land_channel_requirement");
+  terrain_control.ocean_reclaim_requirement_pct
+    = secfile_lookup_int(file, "parameters.ocean_reclaim_requirement_pct");
+  terrain_control.land_channel_requirement_pct
+    = secfile_lookup_int(file, "parameters.land_channel_requirement_pct");
   terrain_control.river_move_mode =
     secfile_lookup_int_default(file, RMV_FAST_STRICT, 
"parameters.river_move_mode");
   terrain_control.river_defense_bonus =

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