Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2003:
[Freeciv-Dev] city_can_be_built_here bug (PR#6219)
Home

[Freeciv-Dev] city_can_be_built_here bug (PR#6219)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] city_can_be_built_here bug (PR#6219)
From: "Jason Short" <jshort@xxxxxxxxxxxxxx>
Date: Sat, 20 Sep 2003 21:19:27 -0700
Reply-to: rt@xxxxxxxxxxxxxx

And the patch.

Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.196
diff -u -r1.196 city.c
--- common/city.c       2003/09/11 00:47:08     1.196
+++ common/city.c       2003/09/21 04:17:12
@@ -818,20 +818,23 @@

 /**************************************************************************
   Returns TRUE if the given unit can build a city at the given map
-  coordinates.
+  coordinates.  punit is the founding unit, which may be NULL in some
+  cases (e.g., cities from huts).
 **************************************************************************/
 bool city_can_be_built_here(int x, int y, struct unit *punit)
 {
-  enum unit_move_type move_type = unit_type(punit)->move_type;
+  if (punit) {
+    enum unit_move_type move_type = unit_type(punit)->move_type;

-  /* 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;
+    /* 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;
+    }
   }

-  /* game.rgame.min_dist_bw_cities minimum is 1, which means adjacent is okay 
*/
+  /* game.rgame.min_dist_bw_cities minimum is 1, meaning adjacent is okay */
   square_iterate(x, y, game.rgame.min_dist_bw_cities-1, x1, y1) {
     if (map_get_city(x1, y1)) {
       return FALSE;
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.251
diff -u -r1.251 unittools.c
--- server/unittools.c  2003/09/19 14:14:45     1.251
+++ server/unittools.c  2003/09/21 04:17:13
@@ -2295,7 +2295,7 @@
 {
   struct player *pplayer = unit_owner(punit);

-  if (city_can_be_built_here(punit->x, punit->y, punit)) {
+  if (city_can_be_built_here(punit->x, punit->y, NULL)) {
     notify_player_ex(pplayer, punit->x, punit->y, E_HUT_CITY,
                     _("Game: You found a friendly city."));
     create_city(pplayer, punit->x, punit->y,



[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] city_can_be_built_here bug (PR#6219), Jason Short <=