Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2005:
[Freeciv-Dev] Re: (PR#14194) moving unit blinks
Home

[Freeciv-Dev] Re: (PR#14194) moving unit blinks

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#14194) moving unit blinks
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 5 Oct 2005 17:14:46 -0700
Reply-to: bugs@xxxxxxxxxxx

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

Jason Short wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=14194 >
> 
> Often when moving a unit, on the unit's last move at the end it will 
> blink once.

This one was a bit of a bear to track down.  The problem was the mapview 
queueing system was subverted by the GTK "expose" code, which would copy 
from the backing store (which may not have been updated yet) straight to 
the screen.  The solution is to unqueue the mapview updates before doing 
the expose.

This patch fixes the problem for all 3 GUIs (tested only for 
gui-gtk-2.0), plus has a minor related cleanup in do_move_unit.

-jason

Index: client/control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.188
diff -p -u -r1.188 control.c
--- client/control.c    3 Oct 2005 02:50:42 -0000       1.188
+++ client/control.c    6 Oct 2005 00:12:18 -0000
@@ -1488,6 +1488,10 @@ void do_move_unit(struct unit *punit, st
 
   unit_list_prepend(dst_tile->units, punit);
 
+  if (punit->transported_by == -1) {
+    refresh_unit_mapcanvas(punit, dst_tile, TRUE, FALSE);
+  }
+
   /* With the "full" citybar we have to update the citybar when units move
    * into or out of a city.  For foreign cities this is handled separately,
    * via the occupied field of the short-city packet. */
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.247
diff -p -u -r1.247 mapview_common.c
--- client/mapview_common.c     3 Oct 2005 02:50:42 -0000       1.247
+++ client/mapview_common.c     6 Oct 2005 00:12:19 -0000
@@ -64,7 +64,6 @@ enum tile_update_type {
 static void queue_mapview_update(enum update_type update);
 static void queue_mapview_tile_update(struct tile *ptile,
                                      enum tile_update_type type);
-static void unqueue_mapview_updates(bool write_to_screen);
 
 /**************************************************************************
  Refreshes a single tile on the map canvas.
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.113
diff -p -u -r1.113 mapview_common.h
--- client/mapview_common.h     11 May 2005 20:54:30 -0000      1.113
+++ client/mapview_common.h     6 Oct 2005 00:12:19 -0000
@@ -218,6 +218,8 @@ void refresh_unit_mapcanvas(struct unit 
 void refresh_city_mapcanvas(struct city *pcity, struct tile *ptile,
                            bool full_refresh, bool write_to_screen);
 
+void unqueue_mapview_updates(bool write_to_screen);
+
 void map_to_gui_vector(const struct tileset *t,
                       int *gui_dx, int *gui_dy, int map_dx, int map_dy);
 bool tile_to_canvas_pos(int *canvas_x, int *canvas_y, struct tile *ptile);
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.551
diff -p -u -r1.551 packhand.c
--- client/packhand.c   3 Oct 2005 02:50:42 -0000       1.551
+++ client/packhand.c   6 Oct 2005 00:12:19 -0000
@@ -1108,12 +1108,6 @@ static bool handle_unit_packet_common(st
 
       /* Show where the unit is going. */
       do_move_unit(punit, packet_unit);
-      if (punit->transported_by == -1) {
-       /* Repaint if the unit isn't transported.  do_move_unit erases the
-        * unit's old position and animates, but doesn't update the unit's
-        * new position. */
-       repaint_unit = TRUE;
-      }
 
       if(pcity)  {
        if (can_player_see_units_in_city(game.player_ptr, pcity)) {
Index: client/gui-gtk-2.0/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.177
diff -p -u -r1.177 mapview.c
--- client/gui-gtk-2.0/mapview.c        25 Aug 2005 20:36:13 -0000      1.177
+++ client/gui-gtk-2.0/mapview.c        6 Oct 2005 00:12:19 -0000
@@ -54,8 +54,6 @@
 #include "citydlg.h" /* For reset_city_dialogs() */
 #include "mapview.h"
 
-#define map_canvas_store (mapview.store->v.pixmap)
-
 static GtkObject *map_hadj, *map_vadj;
 
 
@@ -317,9 +315,8 @@ gboolean map_canvas_expose(GtkWidget *w,
   else
   {
     if (map_exists()) { /* do we have a map at all */
-      gdk_draw_drawable(map_canvas->window, civ_gc, map_canvas_store,
-                       ev->area.x, ev->area.y, ev->area.x, ev->area.y,
-                       ev->area.width, ev->area.height);
+      dirty_rect(ev->area.x, ev->area.y, ev->area.width, ev->area.height);
+      unqueue_mapview_updates(TRUE);
       cleared = FALSE;
     } else {
       if (!cleared) {
@@ -346,7 +343,7 @@ gboolean map_canvas_expose(GtkWidget *w,
 void flush_mapcanvas(int canvas_x, int canvas_y,
                     int pixel_width, int pixel_height)
 {
-  gdk_draw_drawable(map_canvas->window, civ_gc, map_canvas_store,
+  gdk_draw_drawable(map_canvas->window, civ_gc, mapview.store->v.pixmap,
                    canvas_x, canvas_y, canvas_x, canvas_y,
                    pixel_width, pixel_height);
 }
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.158
diff -p -u -r1.158 mapview.c
--- client/gui-win32/mapview.c  5 May 2005 18:32:48 -0000       1.158
+++ client/gui-win32/mapview.c  6 Oct 2005 00:12:20 -0000
@@ -93,8 +93,8 @@ void map_expose(int x, int y, int width,
     DeleteDC(introgfxdc);
     ReleaseDC(map_window, hdc);
   } else {
-    canvas_copy(get_mapview_window(), mapview.store, x, y, x, y,
-               width, height);
+    dirty_rect(x, y, width, height);
+    unqueue_mapview_updates(TRUE);
   }
 } 
 
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.205
diff -p -u -r1.205 mapview.c
--- client/gui-xaw/mapview.c    30 Aug 2005 20:38:00 -0000      1.205
+++ client/gui-xaw/mapview.c    6 Oct 2005 00:12:20 -0000
@@ -54,8 +54,6 @@
 
 #include "mapview.h"
 
-#define map_canvas_store (mapview.store->pixmap)
-
 static void pixmap_put_overlay_tile(Pixmap pixmap, int x, int y,
                                    struct sprite *ssprite);
 
@@ -347,11 +345,9 @@ void map_canvas_expose(Widget w, XEvent 
   }
 
   if (map_exists() && !map_resized) {
-    XCopyArea(display, map_canvas_store, XtWindow(map_canvas),
-             civ_gc,
-             event->xexpose.x, event->xexpose.y,
-             event->xexpose.width, event->xexpose.height,
-             event->xexpose.x, event->xexpose.y);
+    dirty_rect(event->xexpose.x, event->xexpose.y,
+              event->xexpose.width, event->xexpose.height);
+    unqueue_mapview_updates(TRUE);
   }
   refresh_overview_canvas();
 }
@@ -512,7 +508,7 @@ void canvas_put_line(struct canvas *pcan
 void flush_mapcanvas(int canvas_x, int canvas_y,
                     int pixel_width, int pixel_height)
 {
-  XCopyArea(display, map_canvas_store, XtWindow(map_canvas), 
+  XCopyArea(display, mapview.store->pixmap, XtWindow(map_canvas), 
            civ_gc, 
            canvas_x, canvas_y, pixel_width, pixel_height,
            canvas_x, canvas_y);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#14194) moving unit blinks, Jason Short <=