Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12147) bug with refreshing of corner sprites
Home

[Freeciv-Dev] (PR#12147) bug with refreshing of corner sprites

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12147) bug with refreshing of corner sprites
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 6 Feb 2005 15:25:05 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12147 >

With corner and edge sprites, if one tile changes it's not enough to 
redraw that tile.  You also have to redraw 1/2 of each adjacent tile. 
For instance consider (in non-iso-view for simplicity):

   XXX
   X*X
   XXX

the tile at * changes from known to fogged.  So we call 
refresh_tile_mapcanvas.  However the changing of this fogging means all 
of the X tiles have to be partially redrawn as well.

This patch fixes it.

This sounds really inefficient, and it is.  However 
refresh_tile_mapcanvas is not a critical function so this shouldn't be a 
big deal most of the time.  The exception is when you get a large number 
of tiles all at once, as from apollo or game-end.  For this we should 
have a better queueing system for drawing so that we don't do 
unnecessary duplicate drawing.

-jason

? blend.png
? fog
? fog.c
? fog.png
? foo
? terrain1.png
? vgcore.pid11541
? data/isotrident/foo.png
? data/isotrident/grid.png
? data/isotrident/grid.xcf
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.176
diff -u -r1.176 mapview_common.c
--- client/mapview_common.c     5 Feb 2005 19:26:38 -0000       1.176
+++ client/mapview_common.c     6 Feb 2005 23:21:55 -0000
@@ -67,8 +67,14 @@
   int canvas_x, canvas_y;
 
   if (tile_to_canvas_pos(&canvas_x, &canvas_y, ptile)) {
-    canvas_y += NORMAL_TILE_HEIGHT - UNIT_TILE_HEIGHT;
-    update_map_canvas(canvas_x, canvas_y, UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT);
+    const int W = NORMAL_TILE_WIDTH, H = NORMAL_TILE_HEIGHT;
+
+    /* We draw an extra NORMAL_TILE_XXX / 2 on each side because with
+     * corner and edge sprites this much extra may need to be drawn.  This
+     * is only applicable when the underlying tile changes however.  There
+     * should probably be a refresh_unit_mapcanvas/refresh_city_mapcanvas
+     * functions that handle updates for those items more elegantly. */
+    update_map_canvas(canvas_x - W / 2, canvas_y - H / 2, 2 * W, 2 * H);
 
     if (write_to_screen) {
       flush_dirty();

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12147) bug with refreshing of corner sprites, Jason Short <=