[Freeciv-Dev] (PR#4718) topology cleanup for client autocenter code
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#4718) topology cleanup for client autocenter code |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Thu, 22 Jan 2004 22:55:26 -0800 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=4718 >
> [jdorje - Tue Jul 29 17:12:46 2003]:
>
> The code for centering the mapview when the client first connects has
> lots of fallbacks.
>
> Currently the second-to-last fallback is to iterate outwards around the
> center position on the map to find any known tile, and center on that.
>
> The last fallback is just to center the mapview on the center tile of
> the map.
>
> The problem is (map.xsize/2, map.ysize/2) is not the center map position
> of the map under gen-topologies: it is a native position. And
> iterate_outward can't take map.xsize/2, map.ysize/2 as its dimensions
> since these are native, not map, dimensions.
Here's a Ross-like patch for this piece of code. Although using
(map.xsize + map.ysize) as the iteration radius is nonstandard (this is
a native dimension being used as a map one) it should be safe enough
(since it's a really *big* native dimension).
jason
Index: client/climisc.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/climisc.c,v
retrieving revision 1.125
diff -u -r1.125 climisc.c
--- client/climisc.c 2004/01/11 17:45:03 1.125
+++ client/climisc.c 2004/01/23 06:53:26
@@ -363,8 +363,13 @@
center_tile_mapcanvas(punit->x, punit->y);
} else {
/* Just any known tile will do; search near the middle first. */
- iterate_outward(map.xsize / 2, map.ysize / 2,
- MAX(map.xsize / 2, map.ysize / 2), x, y) {
+ int center_map_x, center_map_y;
+
+ native_to_map_pos(¢er_map_x, ¢er_map_y,
+ map.xsize / 2, map.ysize / 2);
+
+ iterate_outward(center_map_x, center_map_y,
+ map.xsize + map.ysize, x, y) {
if (tile_get_known(x, y) != TILE_UNKNOWN) {
center_tile_mapcanvas(x, y);
goto OUT;
@@ -373,7 +378,7 @@
iterate_outward_end;
/* If we get here we didn't find a known tile.
Refresh a random place to clear the intro gfx. */
- center_tile_mapcanvas(map.xsize / 2, map.ysize / 2);
+ center_tile_mapcanvas(center_map_x, center_map_y);
OUT:
; /* do nothing */
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#4718) topology cleanup for client autocenter code,
Jason Short <=
|
|