Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: [PATCH] bugfix for wrapping problem
Home

[Freeciv-Dev] Re: [PATCH] bugfix for wrapping problem

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx (Freeciv developers)
Subject: [Freeciv-Dev] Re: [PATCH] bugfix for wrapping problem
From: Reinier Post <rp@xxxxxxxxxx>
Date: Sun, 26 Aug 2001 13:24:44 +0200

On Sat, Aug 25, 2001 at 08:48:04AM +0200, Raimar Falke wrote:

> > It would also be possible to iterate over the whole canvas to look for
> > coordinates that match the given ones.  The update could be performed
> > for each of those coordinates.  This would be substantially faster:
> > 
> > for (x=x0; x<x0+width; x++)
> >   for (y=y0; y<y0+width; y++)
> >     int mapx=x, mapy=y;
> >     if (normalize_map_pos(&mapx, &mapy)
> >         && mapx==update_x && mapy==update_y)
> >       do_update_function(x, y);
> 
> I also thought about the problem and also found this solution. There
> may be performance issues however.

I don't understand, you can iterate by the wrapping size:

  normalize_map_pos(&x0, &y0);
  for (x=x0; x<x0+canvas_width; x+=map_width) {
    for (y=y0; y<y0+canvas_height; y+=map_height) {
      do_update_function(x, y);
    }
  }

-- 
Reinier


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