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: Jason Dorje Short <jshort@xxxxxxxxxxxxx>
Cc: Trent Piepho <xyzzy@xxxxxxxxxxxxx>, "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] bugfix for wrapping problem
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 25 Aug 2001 08:48:04 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Fri, Aug 24, 2001 at 07:25:53PM -0400, Jason Dorje Short wrote:
> Raimar Falke wrote:
> > 
> > On Fri, Aug 24, 2001 at 02:01:43PM -0700, Trent Piepho wrote:
> 
> > > Getting a wrapped around map to work properly would be a major 
> > > undertaking.
> > > All the map update code assumes that in order to show X on the map, it 
> > > just
> > > needs to find out where X is and draw it once.  Having to worry about 
> > > finding
> > > all copies of X on the map and drawing each one of them would be a major 
> > > pain
> > > in the ass to code.  No way is it worth it, especially for something that
> > > would be a visual nightmare.
> > 
> > So we still have to option of making a brute "refresh the whole
> > canvas" if the map wraps and only a single should be updated?!
> 
> Refreshing the whole canvas will not give the appropriate animations,
> although it would be easy to implement.
> 
> 
> 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.

> Or, a new map function could be created that finds the set of points

For an arbitrary topology you will have the same loop as above.

> automatically; then the update can be done easily.  For instance,
> 
> get_absolute_positions(update_x, update_y, &num, abs_x_array,
> abs_y_array);
> for (i=0; i<num; i++)
>       do_update_function(abs_x_array[i], abs_y_array[i);
> 
> As you can see, this would take little extra work by the calling code. 
> However, it would result the updates happening sequentially rather than
> in parallel, which may give ugly animations depending on how the
> animations are implemented (but only if there is wrap-around, otherwise
> it would work fine).
> 
> 
> A combination might be appropriate: run the update function for one
> absolute coordinate set, and for any other set just refresh the map
> instead.

I think the loop from above solves the problem in a nice way.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "I do feel kind of sorry for Microsoft. Their attornies and marketing
  force must have tons of ulcers trying to figure out how to beat (not
  just co-exist with) a product that has no clearly defined (read
  suable) human owner, and that changes on an hourly basis like the
  sea changes the layout of the sand on a beach. Severely tough to
  fight something like that."
    -- David D.W. Downey at linux-kernel


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