Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] Re: Client core (PR#1107)
Home

[Freeciv-Dev] Re: Client core (PR#1107)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Client core (PR#1107)
From: Mike Kaufman <mkaufman@xxxxxxxxxxxxxx>
Date: Sat, 8 Dec 2001 21:57:42 -0600

On Sat, Dec 08, 2001 at 07:20:40PM -0800, jdorje@xxxxxxxxxxxxxxxxxxxxx wrote:
> Paul Zastoupil wrote:
> 
> When you click on a tile like that, the game tries to associate a city 
> with it, so it calls find_city_near_tile.  Unfortunately, 
> find_city_near_tile is not CHECK_MAP_POS-safe, so it'll fail the 
> assertion any time a wrap-around is needed to find the city (i.e. any 
> time you're working near x==0 or x==map.xsize-1).
> 
> This is easy enough to fix.  But, it's more complicated because each of 
> gui-gtk, gui-xaw, and gui-mui uses its own local (static) version of the 
> function; this code is not common.  However, nothing in the code is 
> gui-specific, and in fact all three versions of the code are completely 
> identical.  (I'm not sure what gui-win32 does for this...maybe it's not 
> implemented yet.)
> 
> I therefore propose that this code be unified into find_city_near_tile() 
> in mapctrl_common.[ch] in client/.  A patch for this will follow.

More and more new gui common files showing up. (keep it up...)
We've already got citydlg and mapview commons. I know that wldlg.c has
some non-gui specific functions that could be unified as well.

perhaps we should put all the gui common files into a new gui-common/
directory?

-mike

> 
> Attached is a preleminary patch for this that should fix the segfault if 
> you're playing under GTK.  Please test if possible.
> 
> jason

> ? old
> ? topology
> Index: client/gui-gtk/mapctrl.c
> ===================================================================
> RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapctrl.c,v
> retrieving revision 1.50
> diff -u -r1.50 mapctrl.c
> --- client/gui-gtk/mapctrl.c  2001/12/08 15:15:51     1.50
> +++ client/gui-gtk/mapctrl.c  2001/12/09 03:18:10
> @@ -358,7 +358,10 @@
>  
>    pcity2 = NULL;
>    city_map_iterate(i, j)  {
> -    pcity = map_get_city(x+i-2, y+j-2);
> +    int map_x, map_y;
> +    if (!base_city_map_to_map(&map_x, &map_y, x, y, i, j))
> +      continue;
> +    pcity = map_get_city(map_x, map_y);
>      if(pcity && pcity->owner==game.player_idx && 
>         get_worker_city(pcity,4-i,4-j)==C_TILE_EMPTY)  {  /* rule b */
>        if(pcity==last_pcity) return pcity;  /* rule c */



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