Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] (PR#8797) ocean cities and TER_NO_CITIES
Home

[Freeciv-Dev] (PR#8797) ocean cities and TER_NO_CITIES

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8797) ocean cities and TER_NO_CITIES
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 21 May 2004 19:59:23 -0700
Reply-to: rt@xxxxxxxxxxx

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

Currently some code assumes that there can be no cities on the ocean. 
For instance when transforming terrain you have to check that the target 
can support cities (if there's a city on the tile).

But other more recent code allows ocean cities.  However in the default 
ruleset it should not be possible to change a city tile into ocean.

The only reasonable way to resolve this is a new terrain flag, 
TER_NO_CITIES.  This is added to ocean in all current rulesets to 
prevent cities on the ocean.

I think glacier should get the NoCities flag in the default and history 
rulesets.  But this is a rules change and I'll leave it for later.

jason

? convert.sh
? eff
? flags
? spec.diff
? data/flags
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.211
diff -u -r1.211 city.c
--- common/city.c       21 May 2004 19:03:43 -0000      1.211
+++ common/city.c       22 May 2004 02:58:48 -0000
@@ -860,15 +860,14 @@
 **************************************************************************/
 bool city_can_be_built_here(int x, int y, struct unit *punit)
 {
-  if (punit) {
-    enum unit_move_type move_type = unit_type(punit)->move_type;
+  if (punit && punit->transported_by != -1) {
+    /* Transported units cannot build cities. */
+    return FALSE;
+  }
 
-    /* We allow land units to build land cities and sea units to build
-     * ocean cities. */
-    if ((move_type == LAND_MOVING && is_ocean(map_get_terrain(x, y)))
-       || (move_type == SEA_MOVING && !is_ocean(map_get_terrain(x, y)))) {
-      return FALSE;
-    }
+  if (terrain_has_flag(map_get_terrain(x, y), TER_NO_CITIES)) {
+    /* No cities on this terrain. */
+    return FALSE;
   }
 
   /* game.rgame.min_dist_bw_cities minimum is 1, meaning adjacent is okay */
Index: common/terrain.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/terrain.c,v
retrieving revision 1.6
diff -u -r1.6 terrain.c
--- common/terrain.c    19 May 2004 00:49:31 -0000      1.6
+++ common/terrain.c    22 May 2004 02:58:48 -0000
@@ -65,6 +65,7 @@
     /* Must match terrain flags in terrain.h. */
     "NoBarbs",
     "NoPollution",
+    "NoCities",
     "Starter",
     "CanHaveRiver",
     "UnsafeCoast",
Index: common/terrain.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/terrain.h,v
retrieving revision 1.15
diff -u -r1.15 terrain.h
--- common/terrain.h    19 May 2004 00:49:31 -0000      1.15
+++ common/terrain.h    22 May 2004 02:58:48 -0000
@@ -74,6 +74,7 @@
 enum terrain_flag_id {
   TER_NO_BARBS, /* No barbarians summoned on this terrain. */
   TER_NO_POLLUTION, /* This terrain cannot be polluted. */
+  TER_NO_CITIES, /* No cities on this terrain. */
   TER_STARTER, /* Players will start on this terrain type. */
   TER_CAN_HAVE_RIVER, /* Terrains with this type can have S_RIVER on them. */
   TER_UNSAFE_COAST,/*this tile is not safe as coast, (all ocean / ice) */ 
Index: common/unit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v
retrieving revision 1.210
diff -u -r1.210 unit.c
--- common/unit.c       19 May 2004 00:49:31 -0000      1.210
+++ common/unit.c       22 May 2004 02:58:49 -0000
@@ -952,7 +952,7 @@
            && (is_ocean(ptile->terrain)
                || !is_ocean(type->transform_result)
                || can_channel_land(map_x, map_y))
-           && (!is_ocean(type->transform_result)
+           && (!terrain_has_flag(type->transform_result, TER_NO_CITIES)
                || !(map_get_city(map_x, map_y)))
            && unit_flag(punit, F_TRANSFORM));
 
Index: data/civ1/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ1/terrain.ruleset,v
retrieving revision 1.23
diff -u -r1.23 terrain.ruleset
--- data/civ1/terrain.ruleset   19 May 2004 00:49:32 -0000      1.23
+++ data/civ1/terrain.ruleset   22 May 2004 02:58:49 -0000
@@ -439,7 +439,7 @@
 mining_time          = 0
 transform_result     = "no"
 transform_time       = 0
-flags                = "Oceanic", "NoPollution", "UnsafeCoast"
+flags                = "Oceanic", "NoPollution", "UnsafeCoast", "NoCities"
 helptext            = _("\
 Oceans cover much of the world, and only sea units (Triremes and\
  other boats) can travel on them.\
Index: data/civ2/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/civ2/terrain.ruleset,v
retrieving revision 1.24
diff -u -r1.24 terrain.ruleset
--- data/civ2/terrain.ruleset   19 May 2004 00:49:32 -0000      1.24
+++ data/civ2/terrain.ruleset   22 May 2004 02:58:49 -0000
@@ -452,7 +452,7 @@
 mining_time          = 0
 transform_result     = "no"
 transform_time       = 0
-flags                = "Oceanic", "NoPollution, "UnsafeCoast"
+flags                = "Oceanic", "NoPollution, "UnsafeCoast", "NoCities"
 helptext            = _("\
 Oceans cover much of the world, and only sea units (Triremes and\
  other boats) can travel on them.\
Index: data/default/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/terrain.ruleset,v
retrieving revision 1.25
diff -u -r1.25 terrain.ruleset
--- data/default/terrain.ruleset        19 May 2004 00:49:32 -0000      1.25
+++ data/default/terrain.ruleset        22 May 2004 02:58:49 -0000
@@ -452,7 +452,7 @@
 mining_time          = 0
 transform_result     = "Swamp"
 transform_time       = 36
-flags                = "Oceanic", "NoPollution", "UnsafeCoast" 
+flags                = "Oceanic", "NoPollution", "UnsafeCoast", "NoCities"
 helptext            = _("\
 Oceans cover much of the world, and only sea units (Triremes and\
  other boats) can travel on them.\
Index: data/history/terrain.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/history/terrain.ruleset,v
retrieving revision 1.8
diff -u -r1.8 terrain.ruleset
--- data/history/terrain.ruleset        23 Feb 2004 05:31:20 -0000      1.8
+++ data/history/terrain.ruleset        22 May 2004 02:58:49 -0000
@@ -193,7 +193,7 @@
 mining_time          = 10
 transform_result     = "Tundra"
 transform_time       = 24
-flags                = "NoBarbs", "CanHaveRiver"
+flags                = "NoBarbs", "CanHaveRiver", "UnsafeCoast", "Unsafe"
 helptext            = _("\
 Glaciers are found only in the most northerly or southerly\
  reaches of the world.  They are very cold, and hence difficult to\
@@ -452,7 +452,7 @@
 mining_time          = 0
 transform_result     = "Swamp"
 transform_time       = 36
-flags                = "Oceanic", "NoPollution"
+flags                = "Oceanic", "NoPollution", "UnsafeCoast", "NoCities"
 helptext            = _("\
 Oceans cover much of the world, and only sea units (Triremes and\
  other boats) can travel on them.\
Index: server/sanitycheck.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/sanitycheck.c,v
retrieving revision 1.40
diff -u -r1.40 sanitycheck.c
--- server/sanitycheck.c        25 Jan 2004 08:04:53 -0000      1.40
+++ server/sanitycheck.c        22 May 2004 02:58:49 -0000
@@ -142,6 +142,8 @@
 
   assert(pcity->size >= 1);
   assert(is_normal_map_pos(pcity->x, pcity->y));
+  assert(!terrain_has_flag(map_get_terrain(pcity->x, pcity->y),
+                          TER_NO_CITIES));
 
   unit_list_iterate(pcity->units_supported, punit) {
     assert(punit->homecity == pcity->id);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#8797) ocean cities and TER_NO_CITIES, Jason Short <=