Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2005:
[Freeciv-Dev] (PR#12933) bug in river generation conditionals
Home

[Freeciv-Dev] (PR#12933) bug in river generation conditionals

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12933) bug in river generation conditionals
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 29 Apr 2005 10:45:23 -0700
Reply-to: bugs@xxxxxxxxxxx

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

The river generation code has various conditionals.  If these are not
met the river is abandoned.  However the conditionals are supposed to be
dropped as the number of river-building attempts grows.  Unfortunately
the code to do this uses == instead of >= and so fails.  This means if
the conditionals fail (on a highly mountainous map, for instance) you
will have few/no rivers and mapgen will take a bit longer.

Attached are patches to fix this for the development version, and 2.0.

-jason

Index: server/generator/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/mapgen.c,v
retrieving revision 1.24
diff -u -r1.24 mapgen.c
--- server/generator/mapgen.c   26 Apr 2005 06:57:37 -0000      1.24
+++ server/generator/mapgen.c   29 Apr 2005 17:42:48 -0000
@@ -942,22 +942,22 @@
           it. */
        && (count_terrain_property_near_tile(ptile, TRUE, TRUE,
                                             MG_MOUNTAINOUS) < 90
-           || iteration_counter == RIVERS_MAXTRIES / 10 * 5)
+           || iteration_counter >= RIVERS_MAXTRIES / 10 * 5)
 
        /* Don't start a river on hills unless it is hard to find
           somewhere else to start it. */
        && (get_tile_type(ptile->terrain)->property[MG_MOUNTAINOUS] == 0
-           || iteration_counter == RIVERS_MAXTRIES / 10 * 6)
+           || iteration_counter >= RIVERS_MAXTRIES / 10 * 6)
 
        /* Don't start a river on arctic unless it is hard to find
           somewhere else to start it. */
        && (get_tile_type(ptile->terrain)->property[MG_FROZEN] == 0
-           || iteration_counter == RIVERS_MAXTRIES / 10 * 8)
+           || iteration_counter >= RIVERS_MAXTRIES / 10 * 8)
 
        /* Don't start a river on desert unless it is hard to find
           somewhere else to start it. */
        && (get_tile_type(ptile->terrain)->property[MG_DRY] == 0
-           || iteration_counter == RIVERS_MAXTRIES / 10 * 9)) {
+           || iteration_counter >= RIVERS_MAXTRIES / 10 * 9)) {
 
       /* Reset river_map before making a new river. */
       memset(river_map, 0, MAP_INDEX_SIZE * sizeof(*river_map));
Index: server/generator/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/mapgen.c,v
retrieving revision 1.12.2.4
diff -u -r1.12.2.4 mapgen.c
--- server/generator/mapgen.c   3 Dec 2004 09:53:38 -0000       1.12.2.4
+++ server/generator/mapgen.c   29 Apr 2005 17:43:02 -0000
@@ -842,27 +842,27 @@
           it. */
        && (count_terrain_near_tile(ptile, TRUE, TRUE, T_HILLS)
            + count_terrain_near_tile(ptile, TRUE, TRUE, T_MOUNTAINS) < 90
-           || iteration_counter == RIVERS_MAXTRIES / 10 * 5)
+           || iteration_counter >= RIVERS_MAXTRIES / 10 * 5)
 
        /* Don't start a river on hills unless it is hard to find
           somewhere else to start it. */
        && (map_get_terrain(ptile) != T_HILLS
-           || iteration_counter == RIVERS_MAXTRIES / 10 * 6)
+           || iteration_counter >= RIVERS_MAXTRIES / 10 * 6)
 
        /* Don't start a river on mountains unless it is hard to find
           somewhere else to start it. */
        && (map_get_terrain(ptile) != T_MOUNTAINS
-           || iteration_counter == RIVERS_MAXTRIES / 10 * 7)
+           || iteration_counter >= RIVERS_MAXTRIES / 10 * 7)
 
        /* Don't start a river on arctic unless it is hard to find
           somewhere else to start it. */
        && (map_get_terrain(ptile) != T_ARCTIC
-           || iteration_counter == RIVERS_MAXTRIES / 10 * 8)
+           || iteration_counter >= RIVERS_MAXTRIES / 10 * 8)
 
        /* Don't start a river on desert unless it is hard to find
           somewhere else to start it. */
        && (map_get_terrain(ptile) != T_DESERT
-           || iteration_counter == RIVERS_MAXTRIES / 10 * 9)) {
+           || iteration_counter >= RIVERS_MAXTRIES / 10 * 9)) {
 
       /* Reset river_map before making a new river. */
       for (i = 0; i < map.xsize * map.ysize; i++) {

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12933) bug in river generation conditionals, Jason Short <=