Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: to wrap or not to wrap?
Home

[Freeciv-Dev] Re: to wrap or not to wrap?

[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: to wrap or not to wrap?
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 15 Oct 2001 09:41:09 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Mon, Oct 15, 2001 at 03:05:47AM -0400, Jason Dorje Short wrote:
> void wrap_map_pos(int *x, int *y)
> {
>   if (wrap_in_x_direction) {
>     while (x < 0) x += map.xsize;
>     while (x >= map.xsize) x -= map.xsize;
>   }
> 
>   if (wrap_in_y_direction) {
>     while (y < 0) y += map.ysize;
>     while (y >= map.ysize) y -= map.ysize;
>   }
> }

> The reason wrap_map_pos works while normalize_map_pos doesn't is that
> the "position" that's being wrapped isn't really a position at all; it's
> just a random vector expressing the difference between (map_x, map_y)
> and (map_view_x0, map_view_y0).  But wrap_map_pos will handle it just
> fine by wrapping it in only the correct (valid) directions.

Ok. But this wrapping isn't a map wrapping but a GUI wrapping.

> The problem is exactly that the GUI does not behave in this manner. 
> It's not just a flat window sitting over a wrapping world; the
> coordinates in the window itself are being wrapped (as above).  If it
> were otherwise, then we'd just take our window coordinates (window_x,
> window_y), adjust them to map coordinates (map_x, map_y), and call

> normalize_map_pos() to see what we had at that position.  This would be
> the better solution, but unfortunately (1) it will require a significant
> overhaul to achieve this and (2) we will need to do some additional
> tricks to make sure we don't draw a tile more than once (since the
> flat-earth window knows nothing of the underlying topology) [2].

IMHO we should do the real fix. Even if it requires more work. We can
make the fixing in small steps. So far everybody agrees that the
client is messed up. We also agreed that the drawing isn't the
problem. A bit more difficult could be the transformation back
(mouse-click position to map position) But this is only one method. So
far nobody has stepped forward to do a real fix. If nobody volunteer I
will do it. But please forget about the wrap_map_pos band-aid.

Jason can you point out any problems which the author of a cleanup
patch may encounter?

> [1] This word looks really ugly without the accent!

You forgot [2].

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  (On the statement print "42 monkeys"+"1 snake"): BTW, both perl and Python
  get this wrong. Perl gives 43 and Python gives "42 monkeys1 snake", when 
  the answer is clearly "41 monkeys and 1 fat snake".  
    -- Jim Fulton, 10 Aug 1999


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