Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] [PATCH] a different GUI wrapping bug
Home

[Freeciv-Dev] [PATCH] a different GUI wrapping bug

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] [PATCH] a different GUI wrapping bug
From: Jason Dorje Short <jshort@xxxxxxxxxxxxx>
Date: Sun, 26 Aug 2001 16:24:10 -0400

I'll restate that the current method of ensuring that no tile is
displayed twice is very bad.  It doesn't limit the size of the canvas,
instead it iterates over the whole canvas and if it wraps around then
the normalization causes the drawing to wrap around too...so that no
tile ever appears twice, but may get drawn many times onto the backing
store.

Another symptom is that clicking the mouse to scroll the screen no
longer works when the map is wrapping around.  Clicking on a tile
usually centers that tile, but if the whole map is covered the "center"
of the canvas is not the center of the image.  With particularly small
maps (I tried 10x10 so that the mapview covered only a small fraction of
the canvas) this means that clicking to center the mapview will center
it around a seemingly arbitrary location.

For non-isometric mode, the fix for all of these is simple: limit the
width of the canvas.  If we refuse to let the canvas be bigger than
xsize x ysize tiles in size then everything will work out cleanly.  It
should also make refreshing the map faster since the amount of drawing
to the canvas backing store is (potentially) less.  It removes the
"problem situation" of clicking to unreal coordinates (at least for most
topologies) since all tiles shown on the mapview should be real. 
Finally, it allows for the rest of the graphics code to use a sane
method of normalization without any tile being drawn multiple times. 
The only thing that might be considered a drawback is that no drawing is
done at all outside of the map canvas, so everything shows up as the
background color instead of black (although I think it's better this
way, and I think it could be fixed without too much trouble.

For isometric mode, this is a lot tricker.  However, the attached patch
shouldn't interfere with isometric mode at all - it just doesn't do
anything to help it.

This may also fix a different bug that I've noticed at the same time:
when playing on a small map, clicking to center the mapview will
sometimes cause the refresh to happen improperly, and the mapview isn't
drawn correctly.  I don't know exactly how to reproduce this, but it
happens for me every time if I play on a 10x10 map and just click around
for a bit (it happens on a 40x25 map, too, but much less often).  (Tests
seem to show that this bug was present before the recent patches, so
it's not coming from there.)  Using my patch, I don't get this bad
behavior.

Although many of you don't want tiles to be drawn multiple times, I hope
you'll at least agree that this is a better way to enforce that (for
non-isometric mode, at least).

Patch attached.  It fixes only the GTK frontend.

jason
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.91
diff -u -r1.91 mapview.c
--- client/gui-gtk/mapview.c    2001/08/25 07:09:36     1.91
+++ client/gui-gtk/mapview.c    2001/08/26 09:26:08
@@ -1052,6 +1052,14 @@
 
   gdk_window_get_size( widget->window, &width, &height );
 
+  /* prevent widget from exceeding map size */
+  if (width > map.xsize * NORMAL_TILE_WIDTH
+      || height > map.ysize * NORMAL_TILE_HEIGHT) {
+    width = MIN(width, map.xsize * NORMAL_TILE_WIDTH);
+    height = MIN(height, map.ysize * NORMAL_TILE_HEIGHT);
+    gdk_window_resize(widget->window, width, height);
+  }
+
   tile_width=(width+NORMAL_TILE_WIDTH-1)/NORMAL_TILE_WIDTH;
   tile_height=(height+NORMAL_TILE_HEIGHT-1)/NORMAL_TILE_HEIGHT;
 

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