Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2002:
[Freeciv-Dev] (PR#2583) fix for [un]queue_mapview_update
Home

[Freeciv-Dev] (PR#2583) fix for [un]queue_mapview_update

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#2583) fix for [un]queue_mapview_update
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Sun, 15 Dec 2002 14:44:57 -0800
Reply-to: rt@xxxxxxxxxxxxxx

The current implementation of [un]queue_mapview_update is semi-broken. 
It is called when we need to do a update_city_descriptions, but when the
update is unqueued it instead calls update_map_canvas_visible.  This
forces a full redraw even if the GUI doesn't require it.

The attached patch allows either a city-description update or a
full-canvas update to be enqueued.  This is not a final solution, but is
an incremental improvement to the current code.  And it allows the GUI
to implement a 5x more efficient udpate_city_descriptions function if it
wants to.

jason


? client/fc_gtk.c
? client/fc_gtk.h
Index: client/clinet.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/clinet.c,v
retrieving revision 1.77
diff -u -r1.77 clinet.c
--- client/clinet.c     2002/12/08 22:55:24     1.77
+++ client/clinet.c     2002/12/15 22:40:04
@@ -336,7 +336,7 @@
     close_socket_callback(&aconnection);
   }
 
-  unqueue_mapview_update();
+  unqueue_mapview_updates();
 }
 
 /**************************************************************************
@@ -388,7 +388,7 @@
   }
 
 out:
-  unqueue_mapview_update();
+  unqueue_mapview_updates();
 }
 
 #ifdef WIN32_NATIVE
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.22
diff -u -r1.22 mapview_common.c
--- client/mapview_common.c     2002/12/06 22:25:12     1.22
+++ client/mapview_common.c     2002/12/15 22:40:04
@@ -590,7 +590,7 @@
   }
 }
 
-static bool need_mapview_update = FALSE;
+static enum update_type needed_updates = UPDATE_NONE;
 
 /**************************************************************************
   This function, along with unqueue_mapview_update(), helps in updating
@@ -609,23 +609,25 @@
   faster too.  But it's a bit of a hack to insert this code into the
   packet-handling code.
 **************************************************************************/
-void queue_mapview_update(void)
+void queue_mapview_update(enum update_type update)
 {
-  need_mapview_update = TRUE;
+  needed_updates |= update;
 }
 
 /**************************************************************************
   See comment for queue_mapview_update().
 **************************************************************************/
-void unqueue_mapview_update(void)
+void unqueue_mapview_updates(void)
 {
-  freelog(LOG_DEBUG, "unqueue_mapview_update: need_update=%d",
-         need_mapview_update ? 1 : 0);
+  freelog(LOG_DEBUG, "unqueue_mapview_update: needed_updates=%d",
+         needed_updates);
 
-  if (need_mapview_update) {
+  if (needed_updates & UPDATE_MAP_CANVAS_VISIBLE) {
     update_map_canvas_visible();
-    need_mapview_update = FALSE;
+  } else if (needed_updates & UPDATE_CITY_DESCRIPTIONS) {
+    update_city_descriptions();
   }
+  needed_updates = UPDATE_NONE;
 }
 
 /**************************************************************************
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.16
diff -u -r1.16 mapview_common.h
--- client/mapview_common.h     2002/11/29 10:01:58     1.16
+++ client/mapview_common.h     2002/12/15 22:40:04
@@ -114,6 +114,13 @@
   D_MB_LR = D_M_L | D_M_R | D_B_L | D_B_R
 };
 
+enum update_type {
+  /* Masks */
+  UPDATE_NONE = 0,
+  UPDATE_CITY_DESCRIPTIONS = 1,
+  UPDATE_MAP_CANVAS_VISIBLE = 2
+};
+
 void refresh_tile_mapcanvas(int x, int y, bool write_to_screen);
 enum color_std get_grid_color(int x1, int y1, int x2, int y2);
 
@@ -147,7 +154,7 @@
                                      size_t growth_buffer_len,
                                      enum color_std *grwoth_color);
 
-void queue_mapview_update(void);
-void unqueue_mapview_update(void);
+void queue_mapview_update(enum update_type update);
+void unqueue_mapview_updates(void);
 
 #endif /* FC__MAPVIEW_COMMON_H */
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.264
diff -u -r1.264 packhand.c
--- client/packhand.c   2002/12/11 10:39:41     1.264
+++ client/packhand.c   2002/12/15 22:40:05
@@ -348,7 +348,7 @@
 
     /* update the descriptions if necessary */
     if (update_descriptions && tile_visible_mapcanvas(packet->x, packet->y)) {
-      queue_mapview_update();
+      queue_mapview_update(UPDATE_CITY_DESCRIPTIONS);
     }
 
     assert(pcity->id == packet->id);
@@ -489,7 +489,7 @@
   }
 
   if (draw_map_grid && get_client_state() == CLIENT_GAME_RUNNING_STATE) {
-    queue_mapview_update();
+    queue_mapview_update(UPDATE_CITY_DESCRIPTIONS);
   } else {
     refresh_tile_mapcanvas(pcity->x, pcity->y, TRUE);
   }

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