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

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?

Greetings
Andreas Kemnade


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