Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12211) a write_to_screen parameter for unqueue_mapview
Home

[Freeciv-Dev] (PR#12211) a write_to_screen parameter for unqueue_mapview

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12211) a write_to_screen parameter for unqueue_mapview_updates
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 10 Feb 2005 20:15:28 -0800
Reply-to: bugs@xxxxxxxxxxx

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

This patch provides a write_to_screen parameter for unqueue_mapview_updates.

This is needed because sometimes we unqueue all the updates as part of 
an ongoing animation, and we don't want to synchronize the changes to 
the screen immediately or there will be flickering.  This concept 
wouldn't work to well with an opengl implementation that always wrote 
directly to the screen, but that problem's a little ways off.

Included is a fix for the nuke graphics.  Looks like there's a bug here 
where the unqueue can overwrite the nuke sprite right after it's drawn.

-jason

Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.186
diff -u -r1.186 mapview_common.c
--- client/mapview_common.c     11 Feb 2005 03:59:51 -0000      1.186
+++ client/mapview_common.c     11 Feb 2005 04:12:55 -0000
@@ -597,7 +597,7 @@
     gui_distance_vector(&diff_x, &diff_y, start_x, start_y, gui_x0, gui_y0);
     anim_timer = renew_timer_start(anim_timer, TIMER_USER, TIMER_ACTIVE);
 
-    unqueue_mapview_updates();
+    unqueue_mapview_updates(TRUE);
 
     do {
       mytime = MIN(read_timer_seconds(anim_timer), timing_sec);
@@ -1358,11 +1358,16 @@
   canvas_x += (NORMAL_TILE_WIDTH - width) / 2;
   canvas_y += (NORMAL_TILE_HEIGHT - height) / 2;
 
+  /* Make sure everything is flushed and synced before proceeding.  First
+   * we update everything to the store, but don't write this to screen.
+   * Then add the nuke graphic to the store.  Finally flush everything to
+   * the screen and wait 1 second. */
+  unqueue_mapview_updates(FALSE);
+
   canvas_put_sprite_full(mapview_canvas.store, canvas_x, canvas_y, mysprite);
   dirty_rect(canvas_x, canvas_y, width, height);
 
-  /* Make sure everything is flushed and synced before proceeding. */
-  unqueue_mapview_updates();
+  flush_dirty();
   gui_flush();
 
   myusleep(1000000);
@@ -1948,7 +1953,7 @@
 
   set_units_in_combat(punit0, punit1);
 
-  unqueue_mapview_updates();
+  unqueue_mapview_updates(TRUE);
   while (punit0->hp > hp0 || punit1->hp > hp1) {
     const int diff0 = punit0->hp - hp0, diff1 = punit1->hp - hp1;
 
@@ -2037,7 +2042,7 @@
     return;
   }
 
-  unqueue_mapview_updates();
+  unqueue_mapview_updates(TRUE);
   if (tile_visible_mapcanvas(src_tile)
       || tile_visible_mapcanvas(dest_tile)) {
     int start_x, start_y;
@@ -2236,7 +2241,7 @@
 static void queue_callback(void *data)
 {
   callback_queued = FALSE;
-  unqueue_mapview_updates();
+  unqueue_mapview_updates(TRUE);
 }
 
 /****************************************************************************
@@ -2319,7 +2324,7 @@
 /**************************************************************************
   See comment for queue_mapview_update().
 **************************************************************************/
-void unqueue_mapview_updates(void)
+void unqueue_mapview_updates(bool write_to_screen)
 {
   freelog(LOG_DEBUG, "unqueue_mapview_update: needed_updates=%d",
          needed_updates);
@@ -2412,8 +2417,10 @@
   }
   needed_updates = UPDATE_NONE;
 
-  flush_dirty();
-  flush_dirty_overview();
+  if (write_to_screen) {
+    flush_dirty();
+    flush_dirty_overview();
+  }
 }
 
 /**************************************************************************
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.90
diff -u -r1.90 mapview_common.h
--- client/mapview_common.h     9 Feb 2005 17:15:17 -0000       1.90
+++ client/mapview_common.h     11 Feb 2005 04:12:55 -0000
@@ -296,7 +296,7 @@
 void queue_mapview_tile_update(struct tile *ptile);
 void queue_mapview_unit_update(struct unit *punit);
 void queue_mapview_city_update(struct city *pcity);
-void unqueue_mapview_updates(void);
+void unqueue_mapview_updates(bool write_to_screen);
 
 void map_to_overview_pos(int *overview_x, int *overview_y,
                         int map_x, int map_y);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12211) a write_to_screen parameter for unqueue_mapview_updates, Jason Short <=