Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2003:
[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]
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#2583) fix for [un]queue_mapview_update
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Wed, 22 Jan 2003 12:31:39 -0800
Reply-to: rt@xxxxxxxxxxxxxx

[jdorje - Sun Dec 15 22:44:57 2002]:

> 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.

Here's an update of the patch for current CVS.

jason

? .xvpics
? annotate
? canvas_pos_to_map_pos-5.diff
? city_descriptions.diff
? city_turns_to_grow-4.diff
? city_turns_to_grow-5.diff
? cityrep_sorting.diff
? cityrepdata-fix.diff
? civscore.log
? config.h.diff
? d
? debian.diff
? diff
? dither.diff
? draw_enums.diff
? draw_multi_dithering.diff
? eyecandy-3.diff
? eyecandy-jdorje.diff
? free_sprite-2.diff
? free_sprite.diff
? freeciv-patches.tgz
? gen-topologies-new.diff
? gen_topologies.diff
? general-topologies.diff
? gtk2-client.diff
? include
? lib
? logdebug_check.diff
? mountainous.diff
? multi_dither_option.diff
? nohup.out
? normalize_map_pos.diff
? normalize_real_map_pos.diff
? obsolete_last.diff
? output
? popdown_all_game_dialogs.diff
? popdown_city_report_dialog-2.diff
? popdown_city_report_dialog.diff
? put_one_tile_iso.diff
? rc
? screenshot.jpg
? ss
? test.pl
? tile_visible_and_not_on_border_mapcanvas.diff
? tile_visible_mapcanvas.diff
? tileset_fix.diff
? tileset_switching_bugs.diff
? tileset_switching_gtk2.diff
? tileset_switching_memleak.diff
? tileset_switching_statebug.diff
? undraw_segment.diff
? unit_pixmap_table-gtk2.diff
? unit_pixmap_table.diff
? warmap.diff
? data/civclient.dsc
? data/civserver.dsc
? data/civserver.room
? data/hills.spec
? data/mountains.spec
? data/theme
? data/isotrident/eyecandy.png
? data/isotrident/eyecandy.spec
? data/isotrident/hills.png
? data/isotrident/hills.spec
? m4/ggz.m4
? m4/xaw-client.m4
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     2003/01/22 20:30:25
@@ -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.24
diff -u -r1.24 mapview_common.c
--- client/mapview_common.c     2003/01/17 20:20:56     1.24
+++ client/mapview_common.c     2003/01/22 20:30:26
@@ -874,7 +874,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
@@ -893,23 +893,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.19
diff -u -r1.19 mapview_common.h
--- client/mapview_common.h     2003/01/17 20:20:56     1.19
+++ client/mapview_common.h     2003/01/22 20:30:26
@@ -116,6 +116,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);
 
@@ -154,7 +161,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.276
diff -u -r1.276 packhand.c
--- client/packhand.c   2003/01/17 09:15:41     1.276
+++ client/packhand.c   2003/01/22 20:30:29
@@ -358,7 +358,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);
@@ -495,7 +495,12 @@
   }
 
   if (draw_map_grid && can_client_change_view()) {
-    queue_mapview_update();
+    /* We have to make sure we update any workers on the map grid, then
+     * redraw the city descriptions on top of them. */
+    update_map_canvas(pcity->x - CITY_MAP_SIZE / 2,
+                     pcity->y - CITY_MAP_SIZE / 2,
+                     CITY_MAP_SIZE, CITY_MAP_SIZE, FALSE);
+    queue_mapview_update(UPDATE_CITY_DESCRIPTIONS);
   } else {
     refresh_tile_mapcanvas(pcity->x, pcity->y, TRUE);
   }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#2583) fix for [un]queue_mapview_update, Jason Short via RT <=