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: Andreas Kemnade <akemnade@xxxxxxxxxxx>
Cc: Gaute B Strokkenes <gs234@xxxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Map coordinate cleanups.
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 16 Aug 2001 11:38:30 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Thu, Aug 16, 2001 at 11:26:16AM +0200, Andreas Kemnade wrote:
> Raimar Falke writes:
>  > 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.
> ffs is not portable. It does not exist on mingw targets and on amigaos.
> (without using ixemul.library (unix emulation like cygwin.dll on
> windows))
> 
> Or should we put a my_ffs into common/support.c?

Yes it looks like a reasonable approach.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 Make a software that is foolproof, and only fools will want to use it.


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