Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2004:
[Freeciv-Dev] (PR#7259) new function tile_has_river
Home

[Freeciv-Dev] (PR#7259) new function tile_has_river

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#7259) new function tile_has_river
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 20 Feb 2004 15:30:18 -0800
Reply-to: rt@xxxxxxxxxxx

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

> [jdorje - Fri Jan 30 23:01:21 2004]:

> Here's a preliminary patch to remove T_RIVER.  I put it here because I
> have no more time to work on it for now.

Here's a full patch to remove T_RIVER.

The chance of individual terrains getting a river is still hard-coded
into mapgen.  Changing this will need more complex logic.  All this
patch does is remove T_RIVER itself.  Now all rivers are specials.

A new terrain flag CanHaveRiver is added.  In most rulesets all
non-ocean terrain can have river.  In civ1 ruleset only grassland can
have river.

There is one drawback to this: now civ1 "river" terrains get the
grassland specials (i.e., "resources").  IMO this is not a big problem.
 In future civ1 can actually get a full terrain "river" that is
identical to grassland, but without the resources and with CanHaveRiver.
 But I think this is not needed now (nor am I sure it would be correct).
 So I'd leave this to someone who cares enough about civ1 compatability
to do the necessary research.

jason

Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.352
diff -u -r1.352 packhand.c
--- client/packhand.c   2004/02/19 18:23:15     1.352
+++ client/packhand.c   2004/02/20 23:15:38
@@ -2530,7 +2530,6 @@
 **************************************************************************/
 void handle_ruleset_terrain_control(struct terrain_misc *p)
 {
-  terrain_control.river_style = p->river_style;
   terrain_control.may_road = p->may_road;
   terrain_control.may_irrigate = p->may_irrigate;
   terrain_control.may_mine = p->may_mine;
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.141
diff -u -r1.141 tilespec.c
--- client/tilespec.c   2004/02/20 15:57:18     1.141
+++ client/tilespec.c   2004/02/20 23:15:39
@@ -1430,13 +1430,6 @@
   *tspecial = map_get_special(map_x, map_y);
   *ttype = map_get_terrain(map_x, map_y);
 
-  /* In iso view a river is drawn as an overlay on top of an underlying
-   * grassland terrain. */
-  if (is_isometric && *ttype == T_RIVER) {
-    *ttype = T_GRASSLAND;
-    *tspecial |= S_RIVER;
-  }
-
   /* Loop over all adjacent tiles.  We should have an iterator for this. */
   for (dir = 0; dir < 8; dir++) {
     int x1, y1;
@@ -1445,12 +1438,6 @@
        && tile_get_known(x1, y1) != TILE_UNKNOWN) {
       tspecial_near[dir] = map_get_special(x1, y1);
       ttype_near[dir] = map_get_terrain(x1, y1);
-
-      /* hacking away the river here... */
-      if (is_isometric && ttype_near[dir] == T_RIVER) {
-       tspecial_near[dir] |= S_RIVER;
-       ttype_near[dir] = T_GRASSLAND;
-      }
     } else {
       /* We draw the edges of the (known) map as if the same terrain just
        * continued off the edge of the map. */
@@ -2175,8 +2162,7 @@
       ADD_SPRITE_SIMPLE(sprites.tx.coast_cape[tileno]);
 
     for (dir = 0; dir < 4; dir++) {
-      if (contains_special(tspecial_near[DIR4_TO_DIR8[dir]], S_RIVER) ||
-          ttype_near[DIR4_TO_DIR8[dir]] == T_RIVER) {
+      if (contains_special(tspecial_near[DIR4_TO_DIR8[dir]], S_RIVER)) {
        ADD_SPRITE_SIMPLE(sprites.tx.river_outlet[dir]);
       }
     }
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.161
diff -u -r1.161 map.c
--- common/map.c        2004/02/18 22:26:45     1.161
+++ common/map.c        2004/02/20 23:15:40
@@ -440,8 +440,6 @@
 
   case T_FOREST:
     return (map_get_special(x, y) == S_NO_SPECIAL) ? 3 : 5;
-  case T_RIVER:
-    return (map_get_special(x, y) == S_NO_SPECIAL) ? 3 : 4;
   case T_GRASSLAND:
   case T_PLAINS:
   case T_HILLS:
@@ -631,7 +629,6 @@
 
   ptile = map_get_tile(x, y);
   if (is_ocean(ptile->terrain)
-      || ptile->terrain == T_RIVER
       || tile_has_special(ptile, S_RIVER)
       || tile_has_special(ptile, S_IRRIGATION))
     return TRUE;
@@ -639,7 +636,6 @@
   cartesian_adjacent_iterate(x, y, x1, y1) {
     ptile = map_get_tile(x1, y1);
     if (is_ocean(ptile->terrain)
-       || ptile->terrain == T_RIVER
        || tile_has_special(ptile, S_RIVER)
        || tile_has_special(ptile, S_IRRIGATION))
       return TRUE;
@@ -932,8 +928,7 @@
   if (tile_has_special(t1, S_ROAD) && tile_has_special(t2, S_ROAD))
     return MOVE_COST_ROAD;
 
-  if (((t1->terrain == T_RIVER) && (t2->terrain == T_RIVER)) ||
-      (tile_has_special(t1, S_RIVER) && tile_has_special(t2, S_RIVER))) {
+  if (tile_has_special(t1, S_RIVER) && tile_has_special(t2, S_RIVER)) {
     cardinal_move = is_move_cardinal(x1, y1, x2, y2);
     switch (terrain_control.river_move_mode) {
     case RMV_NORMAL:
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.10
diff -u -r1.10 packets.def
--- common/packets.def  2004/02/18 22:26:45     1.10
+++ common/packets.def  2004/02/20 23:15:40
@@ -169,7 +169,6 @@
 type DIPLOMAT_ACTION   = uint8(enum diplomat_actions)
 type CMDLEVEL          = uint8(enum cmdlevel_id)
 type PLACE_TYPE                = uint8(enum spaceship_place_type)
-type RIVER_TYPE                = uint8(enum terrain_river_type)
 type RIVER_MOVE                = uint8(enum special_river_move)
 type REPORT_TYPE       = uint8(enum report_type)
 type AUTH_TYPE         = uint8(enum authentication_type)
@@ -1052,7 +1051,6 @@
 end
 
 PACKET_RULESET_TERRAIN_CONTROL=101;sc
-  RIVER_TYPE river_style;
   BOOL may_road;       /* may build roads/railroads */
   BOOL may_irrigate;   /* may build irrigation/farmland */
   BOOL may_mine;       /* may build mines */
Index: common/terrain.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/terrain.c,v
retrieving revision 1.4
diff -u -r1.4 terrain.c
--- common/terrain.c    2004/01/22 23:52:21     1.4
+++ common/terrain.c    2004/02/20 23:15:40
@@ -16,6 +16,7 @@
 #endif
 
 #include "map.h"
+#include "rand.h"
 #include "shared.h"
 #include "support.h"
 #include "terrain.h"
@@ -65,6 +66,7 @@
     "NoBarbs",
     "NoPollution",
     "Starter",
+    "CanHaveRiver",
     "Oceanic"
   };
 
@@ -77,6 +79,34 @@
   }
 
   return TER_LAST;
+}
+
+/****************************************************************************
+  Return a random terrain that has the specified flag.
+****************************************************************************/
+enum tile_terrain_type get_flag_terrain(enum terrain_flag_id flag)
+{
+  bool has_flag[T_COUNT];
+  int count = 0;
+
+  terrain_type_iterate(t) {
+    if ((has_flag[t] = terrain_has_flag(t, flag))) {
+      count++;
+    }
+  } terrain_type_iterate_end;
+
+  count = myrand(count);
+  terrain_type_iterate(t) {
+    if (has_flag[t]) {
+      if (count == 0) {
+       return t;
+      }
+      count--;
+    }
+  } terrain_type_iterate_end;
+
+  die("Reached end of get_flag_terrain!");
+  return T_LAST;
 }
 
 /****************************************************************************
Index: common/terrain.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/terrain.h,v
retrieving revision 1.13
diff -u -r1.13 terrain.h
--- common/terrain.h    2004/02/17 04:52:59     1.13
+++ common/terrain.h    2004/02/20 23:15:40
@@ -15,10 +15,6 @@
 
 #include "shared.h"
 
-enum terrain_river_type {
-  R_AS_TERRAIN=1, R_AS_SPECIAL=2
-};
-
 enum special_river_move {
   RMV_NORMAL=0, RMV_FAST_STRICT=1, RMV_FAST_RELAXED=2, RMV_FAST_ALWAYS=3
 };
@@ -64,9 +60,10 @@
    | S_FORTRESS             \
    | S_AIRBASE)
 
+/* Changing this breaks savegame and network compatability. */
 enum tile_terrain_type {
   T_ARCTIC, T_DESERT, T_FOREST, T_GRASSLAND, T_HILLS, T_JUNGLE, 
-  T_MOUNTAINS, T_OCEAN, T_PLAINS, T_RIVER, T_SWAMP, T_TUNDRA, T_UNKNOWN,
+  T_MOUNTAINS, T_OCEAN, T_PLAINS, T_UNUSED, T_SWAMP, T_TUNDRA, T_UNKNOWN,
   T_LAST
 };
 #define T_FIRST (T_ARCTIC)
@@ -77,6 +74,7 @@
   TER_NO_BARBS, /* No barbarians summoned on this terrain. */
   TER_NO_POLLUTION, /* This terrain cannot be polluted. */
   TER_STARTER, /* Players will start on this terrain type. */
+  TER_CAN_HAVE_RIVER, /* Terrains with this type can have S_RIVER on them. */
   TER_OCEANIC, /* This is an ocean terrain. */
   TER_LAST
 };
@@ -98,6 +96,7 @@
 const char *get_terrain_name(enum tile_terrain_type type);
 enum terrain_flag_id terrain_flag_from_str(const char *s);
 #define terrain_has_flag(terr, flag) BV_ISSET(tile_types[(terr)].flags, flag)
+enum tile_terrain_type get_flag_terrain(enum terrain_flag_id flag);
 void tile_types_free(void);
 
 /* Functions to operate on a general terrain type. */
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.198
diff -u -r1.198 unit.c
--- common/unit.c       2004/02/07 10:55:20     1.198
+++ common/unit.c       2004/02/20 23:15:41
@@ -690,7 +690,7 @@
     return (terrain_control.may_road &&
            unit_flag(punit, F_SETTLERS) &&
            !tile_has_special(ptile, S_ROAD) && type->road_time != 0 &&
-           ((ptile->terrain != T_RIVER && !tile_has_special(ptile, S_RIVER))
+           (!tile_has_special(ptile, S_RIVER)
             || player_knows_techs_with_flag(pplayer, TF_BRIDGE)));
 
   case ACTIVITY_MINE:
@@ -770,7 +770,7 @@
            (tile_has_special(ptile, S_ROAD) ||
             (punit->connecting &&
              (type->road_time != 0 &&
-              ((ptile->terrain!=T_RIVER && !tile_has_special(ptile, S_RIVER))
+              (!tile_has_special(ptile, S_RIVER)
                || player_knows_techs_with_flag(pplayer, TF_BRIDGE))))) &&
            !tile_has_special(ptile, S_RAILROAD) &&
            player_knows_techs_with_flag(pplayer, TF_RAILROAD));
Index: data/civ1/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/terrain.ruleset,v
retrieving revision 1.20
diff -u -r1.20 terrain.ruleset
--- data/civ1/terrain.ruleset   2004/02/17 04:52:59     1.20
+++ data/civ1/terrain.ruleset   2004/02/20 23:15:41
@@ -15,7 +15,6 @@
 options="1.9"
 
 [options]
-river_style=1        ; 1 means Civ1-style, 2 means Civ2-style
 may_road=1           ; 0 means no, 1 means yes
 may_irrigate=1       ; 0 means no, 1 means yes
 may_mine=1           ; 0 means no, 1 means yes
@@ -149,6 +148,9 @@
 ;                        units.  Most terrain improvements can only be built
 ;                        on land.  Oceanic terrain has no zones of control.
 ;                        The list goes on.
+;   - CanHaveRiver     = Set to 1 if this terrain can have river on it (the
+;                        actual chance of river generation is controlled
+;                        separately
 ; helptext            = optional help text string; should escape all raw 
 ;                       newlines so that xgettext parsing works
 
@@ -293,7 +295,7 @@
 mining_time          = 10
 transform_result     = "no"
 transform_time       = 0
-flags                = "Starter"
+flags                = "Starter", "CanHaveRiver"
 helptext            = _("\
 Grasslands afford exceptional agricultural opportunities.\
 ")
Index: data/civ2/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/terrain.ruleset,v
retrieving revision 1.22
diff -u -r1.22 terrain.ruleset
--- data/civ2/terrain.ruleset   2004/02/17 04:53:00     1.22
+++ data/civ2/terrain.ruleset   2004/02/20 23:15:41
@@ -15,7 +15,6 @@
 options="1.9"
 
 [options]
-river_style=2        ; 1 means Civ1-style, 2 means Civ2-style
 may_road=1           ; 0 means no, 1 means yes
 may_irrigate=1       ; 0 means no, 1 means yes
 may_mine=1           ; 0 means no, 1 means yes
@@ -157,6 +156,9 @@
 ;                        units.  Most terrain improvements can only be built
 ;                        on land.  Oceanic terrain has no zones of control.
 ;                        The list goes on.
+;   - CanHaveRiver     = Set to 1 if this terrain can have river on it (the
+;                        actual chance of river generation is controlled
+;                        separately
 ; helptext            = optional help text string; should escape all raw 
 ;                       newlines so that xgettext parsing works
 
@@ -191,7 +193,7 @@
 mining_time          = 10
 transform_result     = "Tundra"
 transform_time       = 24
-flags                = "NoBarbs"
+flags                = "NoBarbs", "CanHaveRiver"
 helptext            = _("\
 Glaciers are found only in the most northerly or southerly\
  reaches of the world.  They are very cold, and hence difficult to\
@@ -229,6 +231,7 @@
 mining_time          = 5
 transform_result     = "Plains"
 transform_time       = 24
+flags                = "CanHaveRiver"
 helptext            = _("\
 Deserts are regions of extreme dryness, making agriculture and\
  trade very difficult.\
@@ -265,6 +268,7 @@
 mining_time          = 0
 transform_result     = "Grassland"
 transform_time       = 24
+flags                = "CanHaveRiver"
 helptext            = _("\
 Forests are densely wooded, making agriculture somewhat\
  problematic.\
@@ -301,7 +305,7 @@
 mining_time          = 10
 transform_result     = "Hills"
 transform_time       = 24
-flags                = "Starter"
+flags                = "Starter", "CanHaveRiver"
 helptext            = _("\
 Grasslands afford exceptional agricultural opportunities.\
 ")
@@ -337,6 +341,7 @@
 mining_time          = 10
 transform_result     = "Plains"
 transform_time       = 24
+flags                = "CanHaveRiver"
 helptext            = _("\
 In addition to being amenable to agriculture, Hills are frequently\
  rich in resources.\
@@ -373,6 +378,7 @@
 mining_time          = 15
 transform_result     = "Plains"
 transform_time       = 24
+flags                = "CanHaveRiver"
 helptext            = _("\
 Jungles are densely overgrown, making agriculture somewhat\
  problematic.\
@@ -409,6 +415,7 @@
 mining_time          = 10
 transform_result     = "Hills"
 transform_time       = 24
+flags                = "CanHaveRiver"
 helptext            = _("\
 Mountains are regions of extreme altitude, making agriculture and\
  trade very difficult.\
@@ -484,7 +491,7 @@
 mining_time          = 15
 transform_result     = "Grassland"
 transform_time       = 24
-flags                = "Starter"
+flags                = "Starter", "CanHaveRiver"
 helptext            = _("\
 Plains are very broad, sparse regions, which makes trade slightly\
  inconvenient.\
@@ -553,6 +560,7 @@
 mining_time          = 15
 transform_result     = "Plains"
 transform_time       = 24
+flags                = "CanHaveRiver"
 helptext            = _("\
 Swamps suffer from an over-abundance of water, making agriculture\
  somewhat problematic.\
@@ -589,7 +597,7 @@
 mining_time          = 0
 transform_result     = "Desert"
 transform_time       = 24
-flags                = "NoBarbs"
+flags                = "NoBarbs", "CanHaveRiver"
 helptext            = _("\
 Tundra are broad, cold regions, fit for some agriculture and little\
  else.\
Index: data/default/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/terrain.ruleset,v
retrieving revision 1.23
diff -u -r1.23 terrain.ruleset
--- data/default/terrain.ruleset        2004/02/17 04:53:00     1.23
+++ data/default/terrain.ruleset        2004/02/20 23:15:41
@@ -15,7 +15,6 @@
 options="1.9"
 
 [options]
-river_style=2        ; 1 means Civ1-style, 2 means Civ2-style
 may_road=1           ; 0 means no, 1 means yes
 may_irrigate=1       ; 0 means no, 1 means yes
 may_mine=1           ; 0 means no, 1 means yes
@@ -157,6 +156,9 @@
 ;                        units.  Most terrain improvements can only be built
 ;                        on land.  Oceanic terrain has no zones of control.
 ;                        The list goes on.
+;   - CanHaveRiver     = Set to 1 if this terrain can have river on it (the
+;                        actual chance of river generation is controlled
+;                        separately
 ; helptext            = optional help text string; should escape all raw 
 ;                       newlines so that xgettext parsing works
 
@@ -191,7 +193,7 @@
 mining_time          = 10
 transform_result     = "Tundra"
 transform_time       = 24
-flags                = "NoBarbs"
+flags                = "NoBarbs", "CanHaveRiver"
 helptext            = _("\
 Glaciers are found only in the most northerly or southerly\
  reaches of the world.  They are very cold, and hence difficult to\
@@ -229,6 +231,7 @@
 mining_time          = 5
 transform_result     = "Plains"
 transform_time       = 24
+flags                = "CanHaveRiver"
 helptext            = _("\
 Deserts are regions of extreme dryness, making agriculture and\
  trade very difficult.\
@@ -265,6 +268,7 @@
 mining_time          = 15
 transform_result     = "Grassland"
 transform_time       = 24
+flags                = "CanHaveRiver"
 helptext            = _("\
 Forests are densely wooded, making agriculture somewhat\
  problematic.\
@@ -301,7 +305,7 @@
 mining_time          = 10
 transform_result     = "Hills"
 transform_time       = 24
-flags                = "Starter"
+flags                = "Starter", "CanHaveRiver"
 helptext            = _("\
 Grasslands afford exceptional agricultural opportunities.\
 ")
@@ -337,6 +341,7 @@
 mining_time          = 10
 transform_result     = "Plains"
 transform_time       = 24
+flags                = "CanHaveRiver"
 helptext            = _("\
 In addition to being amenable to agriculture, Hills are frequently\
  rich in resources.\
@@ -373,6 +378,7 @@
 mining_time          = 15
 transform_result     = "Plains"
 transform_time       = 24
+flags                = "CanHaveRiver"
 helptext            = _("\
 Jungles are densely overgrown, making agriculture somewhat\
  problematic.\
@@ -409,6 +415,7 @@
 mining_time          = 10
 transform_result     = "Hills"
 transform_time       = 24
+flags                = "CanHaveRiver"
 helptext            = _("\
 Mountains are regions of extreme altitude, making agriculture and\
  trade very difficult.\
@@ -484,7 +491,7 @@
 mining_time          = 15
 transform_result     = "Grassland"
 transform_time       = 24
-flags                = "Starter"
+flags                = "Starter", "CanHaveRiver"
 helptext            = _("\
 Plains are very broad, sparse regions, which makes trade slightly\
  inconvenient.\
@@ -553,6 +560,7 @@
 mining_time          = 15
 transform_result     = "Ocean"
 transform_time       = 36
+flags                = "CanHaveRiver"
 helptext            = _("\
 Swamps suffer from an over-abundance of water, making agriculture\
  somewhat problematic.\
@@ -589,7 +597,7 @@
 mining_time          = 0
 transform_result     = "Desert"
 transform_time       = 24
-flags                = "NoBarbs"
+flags                = "NoBarbs", "CanHaveRiver"
 helptext            = _("\
 Tundra are broad, cold regions, fit for some agriculture and little\
  else.\
Index: data/history/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/terrain.ruleset,v
retrieving revision 1.7
diff -u -r1.7 terrain.ruleset
--- data/history/terrain.ruleset        2004/02/17 04:53:00     1.7
+++ data/history/terrain.ruleset        2004/02/20 23:15:43
@@ -15,7 +15,6 @@
 options="1.9"
 
 [options]
-river_style=2        ; 1 means Civ1-style, 2 means Civ2-style
 may_road=1           ; 0 means no, 1 means yes
 may_irrigate=1       ; 0 means no, 1 means yes
 may_mine=1           ; 0 means no, 1 means yes
@@ -157,6 +156,9 @@
 ;                        units.  Most terrain improvements can only be built
 ;                        on land.  Oceanic terrain has no zones of control.
 ;                        The list goes on.
+;   - CanHaveRiver     = Set to 1 if this terrain can have river on it (the
+;                        actual chance of river generation is controlled
+;                        separately
 ; helptext            = optional help text string; should escape all raw 
 ;                       newlines so that xgettext parsing works
 
@@ -191,7 +193,7 @@
 mining_time          = 10
 transform_result     = "Tundra"
 transform_time       = 24
-flags                = "NoBarbs"
+flags                = "NoBarbs", "CanHaveRiver"
 helptext            = _("\
 Glaciers are found only in the most northerly or southerly\
  reaches of the world.  They are very cold, and hence difficult to\
@@ -229,6 +231,7 @@
 mining_time          = 5
 transform_result     = "Plains"
 transform_time       = 24
+flags                = "CanHaveRiver"
 helptext            = _("\
 Deserts are regions of extreme dryness, making agriculture and\
  trade very difficult.\
@@ -265,6 +268,7 @@
 mining_time          = 15
 transform_result     = "Grassland"
 transform_time       = 24
+flags                = "CanHaveRiver"
 helptext            = _("\
 Forests are densely wooded, making agriculture somewhat\
  problematic.\
@@ -301,7 +305,7 @@
 mining_time          = 10
 transform_result     = "Hills"
 transform_time       = 24
-flags                = "Starter"
+flags                = "Starter", "CanHaveRiver"
 helptext            = _("\
 Grasslands afford exceptional agricultural opportunities.\
 ")
@@ -337,6 +341,7 @@
 mining_time          = 10
 transform_result     = "Plains"
 transform_time       = 24
+flags                = "CanHaveRiver"
 helptext            = _("\
 In addition to being amenable to agriculture, Hills are frequently\
  rich in resources.\
@@ -373,6 +378,7 @@
 mining_time          = 15
 transform_result     = "Plains"
 transform_time       = 24
+flags                = "CanHaveRiver"
 helptext            = _("\
 Jungles are densely overgrown, making agriculture somewhat\
  problematic.\
@@ -409,6 +415,7 @@
 mining_time          = 10
 transform_result     = "Hills"
 transform_time       = 24
+flags                = "CanHaveRiver"
 helptext            = _("\
 Mountains are regions of extreme altitude, making agriculture and\
  trade very difficult.\
@@ -484,7 +491,7 @@
 mining_time          = 15
 transform_result     = "Grassland"
 transform_time       = 24
-flags                = "Starter"
+flags                = "Starter", "CanHaveRiver"
 helptext            = _("\
 Plains are very broad, sparse regions, which makes trade slightly\
  inconvenient.\
@@ -551,7 +558,7 @@
 mining_result        = "Forest"
 mining_shield_incr   = 0
 mining_time          = 15
-transform_result     = "Ocean"
+transform_result     = "Ocean", "CanHaveRiver"
 transform_time       = 36
 helptext            = _("\
 Swamps suffer from an over-abundance of water, making agriculture\
@@ -589,7 +596,7 @@
 mining_time          = 0
 transform_result     = "Desert"
 transform_time       = 24
-flags                = "NoBarbs"
+flags                = "NoBarbs", "CanHaveRiver"
 helptext            = _("\
 Tundra are broad, cold regions, fit for some agriculture and little\
  else.\
Index: server/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v
retrieving revision 1.128
diff -u -r1.128 mapgen.c
--- server/mapgen.c     2004/02/02 01:48:48     1.128
+++ server/mapgen.c     2004/02/20 23:15:43
@@ -325,9 +325,9 @@
   int num_adjacent  = 0;
 
   cartesian_adjacent_iterate(x, y, x1, y1) {
-    if (map_get_terrain(x1, y1) == T_RIVER
-       || map_has_special(x1, y1, S_RIVER))
+    if (map_has_special(x1, y1, S_RIVER)) {
       num_adjacent++;
+    }
   } cartesian_adjacent_iterate_end;
 
   return num_adjacent;
@@ -711,7 +711,6 @@
        !is_ocean(map_get_terrain(x, y)) &&
 
        /* Don't start a river on river. */
-       map_get_terrain(x, y) != T_RIVER &&
        !map_has_special(x, y, S_RIVER) &&
 
        /* Don't start a river on a tile is surrounded by > 1 river +
@@ -761,11 +760,14 @@
       if (make_river(x, y)) {
        whole_map_iterate(x1, y1) {
          if (TEST_BIT(rmap(x1, y1), RS_RIVER)) {
-           if (terrain_control.river_style == R_AS_TERRAIN) {
-             map_set_terrain(x1, y1, T_RIVER); /* Civ1 river style. */
-           } else if (terrain_control.river_style == R_AS_SPECIAL) {
-             map_set_special(x1, y1, S_RIVER); /* Civ2 river style. */
+           enum tile_terrain_type t = map_get_terrain(x1, y1);
+
+           if (!terrain_has_flag(t, TER_CAN_HAVE_RIVER)) {
+             /* We have to change the terrain to put a river here. */
+             t = get_flag_terrain(TER_CAN_HAVE_RIVER);
+             map_set_terrain(x1, y1, t);
            }
+           map_set_special(x1, y1, S_RIVER);
            current_riverlength++;
            freelog(LOG_DEBUG, "Applied a river to (%d, %d).", x1, y1);
          }
@@ -839,14 +841,12 @@
 {
   whole_map_iterate(map_x, map_y) {
     if (terrain_is_clean(map_x, map_y)) {
-      if (map_get_terrain(map_x, map_y) != T_RIVER
-         && !map_has_special(map_x, map_y, S_RIVER)) {
+      if (!map_has_special(map_x, map_y, S_RIVER)) {
        map_set_terrain(map_x, map_y, T_HILLS);
       }
       cartesian_adjacent_iterate(map_x, map_y, x1, y1) {
        if (myrand(100) > 66
            && !is_ocean(map_get_terrain(x1, y1))
-           && map_get_terrain(x1, y1) != T_RIVER
            && !map_has_special(x1, y1, S_RIVER)) {
          map_set_terrain(x1, y1, T_HILLS);
        }
@@ -1287,10 +1287,6 @@
   total = map.mountains + map.deserts + map.forestsize + map.swampsize 
     + map.grasssize;
 
-  if (terrain_control.river_style == R_AS_TERRAIN) {
-    total += map.riverlength;
-  }
-
   if (total != 100 - polar) {
     map.forestsize = map.forestsize * (100 - polar) / total;
     map.swampsize = map.swampsize * (100 - polar) / total;
@@ -1298,10 +1294,6 @@
     map.deserts = map.deserts * (100 - polar) / total;
     map.grasssize = 100 - map.forestsize - map.swampsize - map.mountains 
       - polar - map.deserts;
-    if (terrain_control.river_style == R_AS_TERRAIN) {
-      map.riverlength = map.riverlength * (100 - polar) / total;
-      map.grasssize -= map.riverlength;
-    }
   }
 }
 
@@ -1539,19 +1531,14 @@
             || is_terrain_near_tile(x,y,cold1) 
             )
           &&( !is_at_coast(x, y) || myrand(100) < coast )) {
-        if (cold1 != T_RIVER) {
-          if (map_pos_is_cold(x, y)) {
-            map_set_terrain(x, y, 
(myrand(cold0_weight+cold1_weight)<cold0_weight) 
-                           ? cold0 : cold1);
-         } else {
-            map_set_terrain(x, y, 
(myrand(warm0_weight+warm1_weight)<warm0_weight) 
-                           ? warm0 : warm1);
-         }
-        } else {
-          if (is_water_adjacent_to_tile(x, y) &&
-             count_ocean_near_tile(x, y) < 4 &&
-             count_terrain_near_tile(x, y, T_RIVER) < 3)
-           map_set_terrain(x, y, T_RIVER);
+       if (map_pos_is_cold(x, y)) {
+         map_set_terrain(x, y, (myrand(cold0_weight
+                                       + cold1_weight) < cold0_weight) 
+                         ? cold0 : cold1);
+       } else {
+         map_set_terrain(x, y, (myrand(warm0_weight
+                                       + warm1_weight) < warm0_weight) 
+                         ? warm0 : warm1);
        }
       }
       if (map_get_terrain(x,y) != T_GRASSLAND) i--;
@@ -1560,7 +1547,7 @@
 }
 
 /**************************************************************************
-  fill an island with rivers, when river style is R_AS_SPECIAL
+  fill an island with rivers
 **************************************************************************/
 static void fill_island_rivers(int coast, long int *bucket,
                               const struct gen234_state *const pstate)
@@ -1854,17 +1841,10 @@
            islemass, i, balance, checkmass);
 
     i *= tilefactor;
-    if (terrain_control.river_style==R_AS_TERRAIN) {
-      riverbuck += map.riverlength * i;
-      fill_island(1, &riverbuck,
-                 1,1,1,1,
-                 T_RIVER, T_RIVER, T_RIVER, T_RIVER, 
-                 pstate);
-    }
-    if (terrain_control.river_style==R_AS_SPECIAL) {
-      riverbuck += map.riverlength * i;
-      fill_island_rivers(1, &riverbuck, pstate);
-    }
+
+    riverbuck += map.riverlength * i;
+    fill_island_rivers(1, &riverbuck, pstate);
+
     mountbuck += map.mountains * i;
     fill_island(20, &mountbuck,
                3,1, 3,1,
Index: server/maphand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/maphand.c,v
retrieving revision 1.133
diff -u -r1.133 maphand.c
--- server/maphand.c    2004/02/18 22:26:46     1.133
+++ server/maphand.c    2004/02/20 23:15:43
@@ -57,10 +57,8 @@
 **************************************************************************/
 static bool is_terrain_ecologically_wet(int x, int y)
 {
-  return (map_get_terrain(x, y) == T_RIVER
-         || map_has_special(x, y, S_RIVER)
+  return (map_has_special(x, y, S_RIVER)
          || is_ocean_near_tile(x, y)
-         || is_terrain_near_tile(x, y, T_RIVER)
          || is_special_near_tile(x, y, S_RIVER));
 }
 
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.164
diff -u -r1.164 ruleset.c
--- server/ruleset.c    2004/02/14 02:21:26     1.164
+++ server/ruleset.c    2004/02/20 23:15:44
@@ -1495,10 +1495,6 @@
     check_ruleset_capabilities(file, "+1.9", filename);
 
   /* options */
-
-  terrain_control.river_style =
-    secfile_lookup_int_default(file, R_AS_SPECIAL, "options.river_style");
-
   terrain_control.may_road =
     secfile_lookup_bool_default(file, TRUE, "options.may_road");
   terrain_control.may_irrigate =
@@ -2140,7 +2136,7 @@
               /*
                * Note that at this time (before a call to
                * translate_data_names) the terrain_name fields contains an
-               * untranslated string.  Note that name of T_RIVER is "".
+               * untranslated string.  Note that name of T_RIVER_UNUSED is "".
                * However this is not a problem because we take care of rivers
                * separately.
                */
Index: server/settlers.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v
retrieving revision 1.178
diff -u -r1.178 settlers.c
--- server/settlers.c   2004/02/05 20:28:41     1.178
+++ server/settlers.c   2004/02/20 23:15:45
@@ -533,7 +533,7 @@
   }
 
   t=map_get_terrain(x,y);
-  if (is_ocean(t) || t == T_RIVER) {
+  if (is_ocean(t)) {
     return TRUE;
   }
   s=map_get_special(x,y);
@@ -727,7 +727,7 @@
   struct tile *ptile = map_get_tile(mx, my);
 
   if (!is_ocean(ptile->terrain) &&
-      (((ptile->terrain != T_RIVER) && !tile_has_special(ptile, S_RIVER)) ||
+      (!tile_has_special(ptile, S_RIVER) ||
        player_knows_techs_with_flag(pplayer, TF_BRIDGE)) &&
       !tile_has_special(ptile, S_ROAD)) {
     ptile->special|=S_ROAD; /* have to do this to avoid reset_move_costs -- 
Syela */

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#7259) new function tile_has_river, Jason Short <=