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: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: Trent Piepho <xyzzy@xxxxxxxxxxxxx>, "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] bugfix for wrapping problem
From: Jason Dorje Short <jshort@xxxxxxxxxxxxx>
Date: Fri, 24 Aug 2001 19:25:53 -0400

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);


Or, a new map function could be created that finds the set of points
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.

All of these give slightly sub-par results, but not as bad as not having
wrapping at all.


As a final idea, if you really want to avoid wrap-around I think a
better way to do it is not by normalizing all the time, but by limiting
the width of the canvas.  If the canvas is no bigger than (map.xsize,
map.ysize) in width/height, then there will still be no wrapping, the
graphical updates will be faster, and the "correct" solution for
handling coordinates can still be used (allowing different topologies to
work).

jason


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