Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2005:
[Freeciv-Dev] Re: (PR#14635) civserver segfault in city_can_be_built_her
Home

[Freeciv-Dev] Re: (PR#14635) civserver segfault in city_can_be_built_her

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: chrisk@xxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#14635) civserver segfault in city_can_be_built_here
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sat, 19 Nov 2005 05:29:55 -0800
Reply-to: bugs@xxxxxxxxxxx

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

On Sat, 19 Nov 2005, Christian Knoke wrote:
> #00x080af9a8 in city_can_be_built_here (ptile=0x88e9bb4, punit=0x0) at 
> city.c:756

Patch attached. I did not see any reason why punit should be NULL when
checking whether we can build a city from a hut.

PS Why don't we always generate a settler? I find random cities from huts
quite annoying.

  - Per

Index: server/unittools.c
===================================================================
--- server/unittools.c  (revision 11249)
+++ server/unittools.c  (working copy)
@@ -2219,7 +2219,7 @@
 {
   struct player *pplayer = unit_owner(punit);
 
-  if (city_can_be_built_here(punit->tile, NULL)) {
+  if (city_can_be_built_here(punit->tile, punit)) {
     notify_player(pplayer, punit->tile, E_HUT_CITY,
                     _("You found a friendly city."));
     create_city(pplayer, punit->tile,
Index: common/city.c
===================================================================
--- common/city.c       (revision 11249)
+++ common/city.c       (working copy)
@@ -735,8 +735,7 @@
 
 /**************************************************************************
   Returns TRUE if the given unit can build a city at the given map
-  coordinates.  punit is the founding unit, which may be NULL in some
-  cases (e.g., cities from huts).
+  coordinates.  punit is the founding unit.
 **************************************************************************/
 bool city_can_be_built_here(const struct tile *ptile, const struct unit *punit)
 {
@@ -747,7 +746,7 @@
     return FALSE;
   }
 
-  if (punit && !can_unit_exist_at_tile(punit, ptile)) {
+  if (!can_unit_exist_at_tile(punit, ptile)) {
     /* We allow land units to build land cities and sea units to build
      * ocean cities. Air units can build cities anywhere. */
     return FALSE;

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