Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12269) two new tile update types
Home

[Freeciv-Dev] (PR#12269) two new tile update types

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12269) two new tile update types
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 17 Feb 2005 10:24:51 -0800
Reply-to: bugs@xxxxxxxxxxx

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

And, here's an updated (hopefully final) patch.

-jason

? freeciv-2.0.99-devel.tar.gz
Index: client/climisc.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/climisc.c,v
retrieving revision 1.153
diff -u -r1.153 climisc.c
--- client/climisc.c    17 Feb 2005 03:12:53 -0000      1.153
+++ client/climisc.c    17 Feb 2005 18:24:22 -0000
@@ -72,6 +72,7 @@
   struct tile *ptile = punit->tile;
   int hc = punit->homecity;
   struct unit *ufocus = get_unit_in_focus();
+  struct unit old_unit = *punit;
 
   freelog(LOG_DEBUG, "removing unit %d, %s %s (%d %d) hcity %d",
          punit->id, get_nation_name(unit_owner(punit)->nation),
@@ -115,7 +116,7 @@
            TILE_XY(pcity->tile));
   }
 
-  refresh_tile_mapcanvas(ptile, FALSE);
+  refresh_unit_mapcanvas(&old_unit, ptile, TRUE, FALSE);
 }
 
 /**************************************************************************
@@ -125,6 +126,7 @@
 {
   bool effect_update;
   struct tile *ptile = pcity->tile;
+  struct city old_city = *pcity;
 
   freelog(LOG_DEBUG, "removing city %s, %s, (%d %d)", pcity->name,
          get_nation_name(city_owner(pcity)->nation), TILE_XY(ptile));
@@ -145,7 +147,7 @@
   popdown_city_dialog(pcity);
   game_remove_city(pcity);
   city_report_dialog_update();
-  refresh_tile_mapcanvas(ptile, FALSE);
+  refresh_city_mapcanvas(&old_city, ptile, TRUE, FALSE);
 }
 
 /**************************************************************************
Index: client/control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.158
diff -u -r1.158 control.c
--- client/control.c    15 Feb 2005 16:40:40 -0000      1.158
+++ client/control.c    17 Feb 2005 18:24:22 -0000
@@ -168,7 +168,7 @@
     auto_center_on_focus_unit();
 
     punit->focus_status=FOCUS_AVAIL;
-    refresh_unit_mapcanvas(punit, punit->tile, FALSE);
+    refresh_unit_mapcanvas(punit, punit->tile, TRUE, FALSE);
 
     if (unit_has_orders(punit)) {
       /* Clear the focus unit's orders. */
@@ -184,7 +184,8 @@
   /* avoid the old focus unit disappearing: */
   if (punit_old_focus
       && (!punit || !same_pos(punit_old_focus->tile, punit->tile))) {
-    refresh_unit_mapcanvas(punit_old_focus, punit_old_focus->tile, FALSE);
+    refresh_unit_mapcanvas(punit_old_focus, punit_old_focus->tile,
+                          TRUE, FALSE);
   }
 
   update_unit_info_label(punit);
@@ -422,7 +423,14 @@
       /* If we lag, we don't try to catch up.  Instead we just start a
        * new blink_time on every update. */
       blink_timer = renew_timer_start(blink_timer, TIMER_USER, TIMER_ACTIVE);
-      refresh_unit_mapcanvas(punit, punit->tile, TRUE);
+
+      /* HACK: since this is called so often we're careful to only do the
+       * minimal refresh. */
+      if (sprites.unit.select[0]) {
+       refresh_tile_mapcanvas(punit->tile, FALSE, TRUE);
+      } else {
+       refresh_unit_mapcanvas(punit, punit->tile, FALSE, TRUE);
+      }
     }
 
     return blink_time - read_timer_seconds(blink_timer);
@@ -1427,7 +1435,7 @@
   if (punit->transported_by == -1) {
     /* We have to refresh the tile before moving.  This will draw
      * the tile without the unit (because it was unlinked above). */
-    refresh_unit_mapcanvas(punit, ptile, FALSE);
+    refresh_unit_mapcanvas(punit, ptile, TRUE, FALSE);
 
     if (do_animation) {
       int dx, dy;
Index: client/goto.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/goto.c,v
retrieving revision 1.81
diff -u -r1.81 goto.c
--- client/goto.c       5 Feb 2005 07:41:53 -0000       1.81
+++ client/goto.c       17 Feb 2005 18:24:22 -0000
@@ -210,8 +210,8 @@
   }
 
   /* Refresh tiles so turn information is shown. */
-  refresh_tile_mapcanvas(old_tile, FALSE);
-  refresh_tile_mapcanvas(ptile, FALSE);
+  refresh_tile_mapcanvas(old_tile, FALSE, FALSE);
+  refresh_tile_mapcanvas(ptile, FALSE, FALSE);
 }
 
 /********************************************************************** 
Index: client/mapctrl_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapctrl_common.c,v
retrieving revision 1.47
diff -u -r1.47 mapctrl_common.c
--- client/mapctrl_common.c     15 Feb 2005 16:40:40 -0000      1.47
+++ client/mapctrl_common.c     17 Feb 2005 18:24:23 -0000
@@ -294,7 +294,7 @@
     return;
   }
 
-  refresh_tile_mapcanvas(ptile, TRUE);
+  refresh_tile_mapcanvas(ptile, FALSE, TRUE);
 }
 
 /**************************************************************************
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.191
diff -u -r1.191 mapview_common.c
--- client/mapview_common.c     17 Feb 2005 18:19:04 -0000      1.191
+++ client/mapview_common.c     17 Feb 2005 18:24:23 -0000
@@ -70,8 +70,10 @@
 /* A tile update has a tile associated with it as well as an area type.
  * See unqueue_mapview_updates for a thorough explanation. */
 enum tile_update_type {
-  TILE_UPDATE_TILE,
+  TILE_UPDATE_TILE_SINGLE,
+  TILE_UPDATE_TILE_FULL,
   TILE_UPDATE_UNIT,
+  TILE_UPDATE_CITY_DESC,
   TILE_UPDATE_CITYMAP,
   TILE_UPDATE_COUNT
 };
@@ -83,9 +85,14 @@
 /**************************************************************************
  Refreshes a single tile on the map canvas.
 **************************************************************************/
-void refresh_tile_mapcanvas(struct tile *ptile, bool write_to_screen)
+void refresh_tile_mapcanvas(struct tile *ptile,
+                           bool full_refresh, bool write_to_screen)
 {
-  queue_mapview_tile_update(ptile, TILE_UPDATE_TILE);
+  if (full_refresh) {
+    queue_mapview_tile_update(ptile, TILE_UPDATE_TILE_FULL);
+  } else {
+    queue_mapview_tile_update(ptile, TILE_UPDATE_TILE_SINGLE);
+  }
   if (write_to_screen) {
     unqueue_mapview_updates(TRUE);
   }
@@ -95,9 +102,9 @@
  Refreshes a single unit on the map canvas.
 **************************************************************************/
 void refresh_unit_mapcanvas(struct unit *punit, struct tile *ptile,
-                           bool write_to_screen)
+                           bool full_refresh, bool write_to_screen)
 {
-  if (unit_type_flag(punit->type, F_CITIES)) {
+  if (full_refresh && unit_type_flag(punit->type, F_CITIES)) {
     queue_mapview_tile_update(ptile, TILE_UPDATE_CITYMAP);
   } else {
     queue_mapview_tile_update(ptile, TILE_UPDATE_UNIT);
@@ -1110,7 +1117,7 @@
     color_index = (color_index + 1) % NUM_CITY_COLORS;
   }
 
-  refresh_unit_mapcanvas(punit, punit->tile, FALSE);
+  refresh_unit_mapcanvas(punit, punit->tile, TRUE, FALSE);
 }
 
 /****************************************************************************
@@ -1724,15 +1731,7 @@
 **************************************************************************/
 void update_city_description(struct city *pcity)
 {
-  int canvas_x, canvas_y;
-
-  /* We update the entire map canvas area that this city description
-   * might be covering.  This may, for instance, redraw other city
-   * descriptions that overlap with this one. */
-  (void) tile_to_canvas_pos(&canvas_x, &canvas_y, pcity->tile);
-  update_map_canvas(canvas_x - (max_desc_width - NORMAL_TILE_WIDTH) / 2,
-                   canvas_y + NORMAL_TILE_HEIGHT,
-                   max_desc_width, max_desc_height);
+  queue_mapview_tile_update(pcity->tile, TILE_UPDATE_CITY_DESC);
 }
 
 /**************************************************************************
@@ -1877,8 +1876,8 @@
     assert(0);
     return;
   }
-  refresh_tile_mapcanvas(src_tile, FALSE);
-  refresh_tile_mapcanvas(dst_tile, FALSE);
+  refresh_tile_mapcanvas(src_tile, FALSE, FALSE);
+  refresh_tile_mapcanvas(dst_tile, FALSE, FALSE);
 }
 
 /****************************************************************************
@@ -1902,10 +1901,10 @@
 
     if (myrand(diff0 + diff1) < diff0) {
       punit0->hp--;
-      refresh_unit_mapcanvas(punit0, punit0->tile, FALSE);
+      refresh_unit_mapcanvas(punit0, punit0->tile, FALSE, FALSE);
     } else {
       punit1->hp--;
-      refresh_unit_mapcanvas(punit1, punit1->tile, FALSE);
+      refresh_unit_mapcanvas(punit1, punit1->tile, FALSE, FALSE);
     }
 
     unqueue_mapview_updates(TRUE);
@@ -1917,7 +1916,7 @@
   if (num_tiles_explode_unit > 0
       && tile_to_canvas_pos(&canvas_x, &canvas_y,
                           losing_unit->tile)) {
-    refresh_unit_mapcanvas(losing_unit, losing_unit->tile, FALSE);
+    refresh_unit_mapcanvas(losing_unit, losing_unit->tile, FALSE, FALSE);
     unqueue_mapview_updates(FALSE);
     canvas_copy(mapview.tmp_store, mapview.store,
                canvas_x, canvas_y, canvas_x, canvas_y,
@@ -1949,8 +1948,8 @@
   }
 
   set_units_in_combat(NULL, NULL);
-  refresh_unit_mapcanvas(punit0, punit0->tile, FALSE);
-  refresh_unit_mapcanvas(punit1, punit1->tile, FALSE);
+  refresh_unit_mapcanvas(punit0, punit0->tile, TRUE, FALSE);
+  refresh_unit_mapcanvas(punit1, punit1->tile, TRUE, FALSE);
 }
 
 /**************************************************************************
@@ -2268,8 +2267,10 @@
   const struct {
     int dx, dy, w, h;
   } area[TILE_UPDATE_COUNT] = {
+    {0, 0, W, H},
     {-W / 2, -H / 2, 2 * W, 2 * H},
     {(W - UW) / 2, H - UH, UW, UH},
+    {-(max_desc_width - W) / 2, H, max_desc_width, max_desc_height},
     {-(city_width - W) / 2, -(city_height - H) / 2, city_width, city_height}
   };
 
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.93
diff -u -r1.93 mapview_common.h
--- client/mapview_common.h     14 Feb 2005 17:52:56 -0000      1.93
+++ client/mapview_common.h     17 Feb 2005 18:24:23 -0000
@@ -203,9 +203,10 @@
   }                                                                        \
 }
 
-void refresh_tile_mapcanvas(struct tile *ptile, bool write_to_screen);
+void refresh_tile_mapcanvas(struct tile *ptile,
+                           bool full_refresh, bool write_to_screen);
 void refresh_unit_mapcanvas(struct unit *punit, struct tile *ptile,
-                           bool write_to_screen);
+                           bool full_refresh, bool write_to_screen);
 void refresh_city_mapcanvas(struct city *pcity, struct tile *ptile,
                            bool full_refresh, bool write_to_screen);
 
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.471
diff -u -r1.471 packhand.c
--- client/packhand.c   15 Feb 2005 05:37:04 -0000      1.471
+++ client/packhand.c   17 Feb 2005 18:24:24 -0000
@@ -296,8 +296,8 @@
        punit1->hp = hp1;
 
        set_units_in_combat(NULL, NULL);
-       refresh_unit_mapcanvas(punit0, punit0->tile, FALSE);
-       refresh_unit_mapcanvas(punit1, punit1->tile, FALSE);
+       refresh_unit_mapcanvas(punit0, punit0->tile, TRUE, FALSE);
+       refresh_unit_mapcanvas(punit1, punit1->tile, TRUE, FALSE);
       }
     }
   }
@@ -586,7 +586,7 @@
 
 
   if (can_client_change_view()) {
-    refresh_tile_mapcanvas(pcity->tile, FALSE);
+    refresh_city_mapcanvas(pcity, pcity->tile, FALSE, FALSE);
   }
 
   if (city_workers_display==pcity)  {
@@ -1203,7 +1203,7 @@
   }
 
   if (repaint_unit) {
-    refresh_unit_mapcanvas(punit, punit->tile, FALSE);
+    refresh_unit_mapcanvas(punit, punit->tile, TRUE, FALSE);
   }
 
   if ((check_focus || get_unit_in_focus() == NULL) &&
@@ -1955,7 +1955,7 @@
   if (can_client_change_view()) {
     /* the tile itself (including the necessary parts of adjacent tiles) */
     if (tile_changed || old_known!=ptile->known) {
-      refresh_tile_mapcanvas(ptile, FALSE);
+      refresh_tile_mapcanvas(ptile, TRUE, FALSE);
     }
   }
 

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