Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: PATCH: cleanup in fill_tile_sprite_array (PR#1016)
Home

[Freeciv-Dev] Re: PATCH: cleanup in fill_tile_sprite_array (PR#1016)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: PATCH: cleanup in fill_tile_sprite_array (PR#1016)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 15 Oct 2001 14:33:51 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Mon, Oct 15, 2001 at 04:59:30AM -0700, jdorje@xxxxxxxxxxxxxxxxxxxxx wrote:
> The attached patch cleans up fill_tile_sprite_array and
> fill_tile_sprite_array_iso.  The new code still has some ugliness to it
> (I'm not sure how to get rid of this...), but should be safe with the
> check_map_pos changes and should also be topology-independent (which
> some of the old code was not).

Very nice. I have waited for such a patch a long time.

> 
> jason
> Index: client/tilespec.c
> ===================================================================
> RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
> retrieving revision 1.54
> diff -u -r1.54 tilespec.c
> --- client/tilespec.c 2001/10/12 10:12:13     1.54
> +++ client/tilespec.c 2001/10/15 10:54:29
> @@ -1066,6 +1066,18 @@
>  }
>  
>  /**********************************************************************
> +This is a hack wrapper to tile_is_known needed to make
> +fill_tile_sprite_array[iso] prettier.
> +***********************************************************************/
> +static enum known_type is_tile_known(int x, int y)
> +{
> +  if (!normalize_map_pos(&x, &y))
> +    return TILE_UNKNOWN;
> +  else
> +    return tile_is_known(x, y);
> +}
> +
> +/**********************************************************************

> -  dither[0] = get_dither(ttype, tile_is_known(x, y-1) ? ttype_north : 
> T_UNKNOWN);
> -  dither[1] = get_dither(ttype, tile_is_known(x, y+1) ? ttype_south : 
> T_UNKNOWN);
> -  dither[2] = get_dither(ttype, tile_is_known(x+1, y) ? ttype_east : 
> T_UNKNOWN);
> -  dither[3] = get_dither(ttype, tile_is_known(x-1, y) ? ttype_west : 
> T_UNKNOWN);
> +  /* To make this work cleanly I wrote is_tile_known as a wrapper to 
> tile_is_known.  Ugly! */
> +  dither[0] = get_dither(ttype, is_tile_known(x, y-1) ? 
> ttype_near[DIR8_NORTH] : T_UNKNOWN);
> +  dither[1] = get_dither(ttype, is_tile_known(x, y+1) ? 
> ttype_near[DIR8_SOUTH] : T_UNKNOWN);
> +  dither[2] = get_dither(ttype, is_tile_known(x+1, y) ? 
> ttype_near[DIR8_EAST] : T_UNKNOWN);
> +  dither[3] = get_dither(ttype, is_tile_known(x-1, y) ? 
> ttype_near[DIR8_WEST] : T_UNKNOWN);

What do you think about:

in map.h
enum direction4 {
  DIR4_NORTH = 0,
  DIR4_WEST = 1,
  DIR4_EAST = 2,
  DIR4_SOUTH = 3,
};

enum direction8 dir4_to_dir8(enum direction4 dir);

in tilespec.c

for(i=0;i<4;i++)
{
  dither[i]=get_dither(ttype, T_UNKNOWN);
}

cartesian_dir_adjacent_iterate(x,y,x1,y1,dir4)
{
  dither[dir4] = get_dither(ttype, tile_is_known(x1, y1) ? 
ttype_near[dir4_to_dir8(dir4)] : T_UNKNOWN);
}

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  Two OS engineers facing a petri net chart:
        "dead lock in four moves!"


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