Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: PATCH: map iteration (PR#1018)
Home

[Freeciv-Dev] Re: PATCH: map iteration (PR#1018)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: PATCH: map iteration (PR#1018)
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 22 Oct 2001 12:34:56 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Sun, Oct 21, 2001 at 10:52:51PM -0400, Jason Dorje Short wrote:
> Raimar Falke wrote:
> > 
> > On Fri, Oct 19, 2001 at 09:15:46PM -0400, Ross W. Wetmore wrote:
> > > The is_normal_map_pos() solution is really just a bad hack because you
> > > aren't willing to think about the case and fix it right at the moment :-).
> > >
> > > But in most cases, the right fix it is far easier than what you are
> > > proposing.
> > >
> > > The examples below should use whole_map_iterate(). When you get weird
> > > maps, then whole_map_iterate() will become weird, but until then it will
> > > remain as is, i.e. efficient iteration over the whole map. The change
> > > when needed is to 1 line of code in a header.
> > 
> > Yes whole_map_iterate should be prefered. However whole_map_iterate
> > doesn't allow an action if the map position is unreal or an extra
> > action for every new line.
> 
> Indeed.  Adding such code to whole_map_iterate would be very unwieldy at
> best.
> 
> My understanding is that whole_map_iterate also doesn't guarantee
> anything about the order in which the coordinates are traversed.  The
> stuff in server/savegame.c certainly needs such a guarantee.

Lets go a step back:
$ grep -Irn 'for.*map.xsize.*[+][+]' .
./client/goto.c:224:  for (x_itr = 0; x_itr < map.xsize; x_itr++) {
./client/gui-mui/overviewclass.c:205:    for (x = 0; x < map.xsize; x++)

./common/game.c:125:      for (x = 0; x < map.xsize; x++)
./common/game.c:133:          for (x = 0; x < map.xsize; x++)
./common/game.c:144:      for (x = 0; x < map.xsize; x++)
./common/game.c:152:          for (x = 0; x < map.xsize; x++)
./common/game.c:167:  for (x = 0; x < map.xsize; x++)
./common/game.c:175:      for (x = 0; x < map.xsize; x++)
./common/game.c:183:  for (x = 0; x < map.xsize; x++)
./common/game.c:191:      for (x = 0; x < map.xsize; x++)

We may remove this LAND_AREA_DEBUG stuff altogether.

./common/map.h:475:    for (WMI_x_itr = 0; WMI_x_itr < map.xsize; WMI_x_itr++)
./server/barbarian.c:96:        for( j = 0; j < map.xsize; j++ )
./server/gamelog.c:93:    for (x=0;x<map.xsize;x++) {

./server/mapgen.c:111:    for (x=0;x<map.xsize;x++) {
./server/mapgen.c:123:    for (x=0;x<map.xsize;x++) {
./server/mapgen.c:138:  for (x=0;x<map.xsize;x++) {
./server/mapgen.c:724:      for (i = 0; i < map.xsize * map.ysize; i++) {
./server/mapgen.c:782:  for (x=0;x<map.xsize;x++) {
./server/mapgen.c:801:    for (x=0;x<map.xsize;x++) {
./server/mapgen.c:1406:    for (x=0;x<map.xsize; x++) {
./server/mapgen.c:1765:    for (x = 0 ; x < map.xsize ; x++) {
./server/mapgen.c:1769:  for (x = 0 ; x < map.xsize; x++) {

Some of them can be replaced with a new rectangle/block_iterate.

./server/maphand.c:302: for (x=0; x<map.xsize; x++) {
./server/maphand.c:309: for (x=0; x<map.xsize; x++) {

Difficult.

./server/savegame.c:70:    for (x = 0; x < map.xsize; x++) {                   \
./server/savegame.c:128:    for(x = 0; x < map.xsize; x++) {                    
      \

Ok.

./server/gotohand.c:192:    for (x = 0; x < map.xsize; x++) {
./server/gotohand.c:205:    for (x = 0; x < map.xsize; x++)
./server/gotohand.c:210:    for (x = 0; x < map.xsize; x++)
./server/gotohand.c:824:  for (x = 0; x < map.xsize; x++)

Not topology depend.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Like the ad says, at 300 dpi you can tell she's wearing a
  swimsuit. At 600 dpi you can tell it's wet. At 1200 dpi you
  can tell it's painted on. I suppose at 2400 dpi you can tell
  if the paint is giving her a rash."
    -- Joshua R. Poulson


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