Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: Map coordinate cleanups.
Home

[Freeciv-Dev] Re: Map coordinate cleanups.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gaute B Strokkenes <gs234@xxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Map coordinate cleanups.
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 16 Aug 2001 10:10:22 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Thu, Aug 16, 2001 at 02:15:07AM +0200, Gaute B Strokkenes wrote:
> 
> +    int x1 = pcity->x + x - 2;
> +    int y1 = pcity->y + y - 2;

Can a function created which does this transformation? It is used all
over the place. This would be the reverse of
common/city.h:get_citymap_xy().

> -  for (tt = T_FIRST; tt < T_COUNT; tt++) {
> -    if (0 == strcmp (tile_types[tt].terrain_name, name)) {
> +  for (tt = T_FIRST; tt < T_COUNT; tt++)
> +    if (!strcmp (tile_types[tt].terrain_name, name))
>        break;
> -    }
> -  }
> +

Maybe it is time to decide which rule freeciv should follow. I would
vote for the extra {}s.


> -  for (inx = 0;
> -       inx < 
> sizeof(tile_special_type_names)/sizeof(tile_special_type_names[0]);
> -       inx++) {
> -    if (type & 0x1) {
> -      return tile_special_type_names[inx];
> -    }
> +  for (i = 0; i < NUM_SPECIAL_NAMES; i++) {
> +    if (type & 0x1)
> +      return tile_special_type_names[i];
> +
>      type >>= 1;
>    }

Could this be rewritten to use ffs(3). There is no loop needed.

> +#if 1
>  #define map_inx(x,y) \
>    ((x)+(y)*map.xsize)
> +#endif

Mhh.

> +/* FIXME: These are particularly useless, but used everywhere.  */

These methods provide abstraction.

> +#if 1
> +#define MAP(x,y) (map.tiles + (IS_PROP_TILE((x),(y)) \
> +                               ? ((x) + map.xsize * (y)) \
> +                            : (abort(), 0)))
> +#else
> +#define MAP(x,y) (map.tiles + (x) + map.xsize * (y))
> +#endif

Mhh.

> +#define MAPSTEP(x,y,x1,y1,dir)     \

I like this one.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Transported to a surreal landscape, a young girl kills the first woman
  she meets and then teams up with three complete strangers to kill again."
    -- TV listing for the Wizard of Oz in the Marin Independent Journal


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