Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] (PR#7335) remove mapview macros for gui-xaw
Home

[Freeciv-Dev] (PR#7335) remove mapview macros for gui-xaw

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#7335) remove mapview macros for gui-xaw
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 27 Jan 2004 18:39:39 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7335 >

When the mapview unification was done we just wrote wrappers for the new
values in mapview.h, rather than rename them throughout the code.

This patch removes these wrappers from gui-xaw. There are some
cleanups done in the process: many callers did not check the value of
get_canvas_xy (map_to_canvas_pos), and did unnecessary work.

jason

Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.151
diff -u -r1.151 mapview.c
--- client/gui-xaw/mapview.c    2003/11/19 17:30:51     1.151
+++ client/gui-xaw/mapview.c    2004/01/28 02:38:57
@@ -95,23 +95,26 @@
 
   } while (punit0->hp > hp0 || punit1->hp > hp1);
 
-  get_canvas_xy(losing_unit->x, losing_unit->y, &canvas_x, &canvas_y);
-  for (i = 0; i < num_tiles_explode_unit; i++) {
-    struct canvas_store store = {single_tile_pixmap};
-
-    anim_timer = renew_timer_start(anim_timer, TIMER_USER, TIMER_ACTIVE);
-
-    put_one_tile(&store, 0, 0, losing_unit->x, losing_unit->y, FALSE);
-    put_unit_full(losing_unit, &store, 0, 0);
-    pixmap_put_overlay_tile(single_tile_pixmap, 0, 0, sprites.explode.unit[i]);
-
-    XCopyArea(display, single_tile_pixmap, XtWindow(map_canvas), civ_gc,
-             0, 0,
-             UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT,
-             canvas_x, canvas_y);
+  if (map_to_canvas_pos(&canvas_x, &canvas_y,
+                       losing_unit->x, losing_unit->y)) {
+    for (i = 0; i < num_tiles_explode_unit; i++) {
+      struct canvas_store store = {single_tile_pixmap};
+
+      anim_timer = renew_timer_start(anim_timer, TIMER_USER, TIMER_ACTIVE);
+
+      put_one_tile(&store, 0, 0, losing_unit->x, losing_unit->y, FALSE);
+      put_unit_full(losing_unit, &store, 0, 0);
+      pixmap_put_overlay_tile(single_tile_pixmap, 0, 0,
+                             sprites.explode.unit[i]);
+
+      XCopyArea(display, single_tile_pixmap, XtWindow(map_canvas), civ_gc,
+               0, 0,
+               UNIT_TILE_WIDTH, UNIT_TILE_HEIGHT,
+               canvas_x, canvas_y);
 
-    XSync(display, 0);
-    usleep_since_timer_start(anim_timer, 20000);
+      XSync(display, 0);
+      usleep_since_timer_start(anim_timer, 20000);
+    }
   }
 
   set_units_in_combat(NULL, NULL);
@@ -499,8 +502,9 @@
                 event->xexpose.width, event->xexpose.height,
                 event->xexpose.x, event->xexpose.y);
 
-    if(map_canvas_store_twidth !=tile_width ||
-       map_canvas_store_theight!=tile_height) { /* resized? */
+    /* resized? */
+    if (mapview_canvas.tile_width != tile_width
+       || mapview_canvas.tile_height != tile_height) {
       map_canvas_resize();
     }
     return;
@@ -511,13 +515,14 @@
   }
 
   if (map_exists()) { /* do we have a map at all */
-    if(map_canvas_store_twidth !=tile_width ||
-       map_canvas_store_theight!=tile_height) { /* resized? */
+    /* resized? */
+    if (mapview_canvas.tile_width != tile_width
+       || mapview_canvas.tile_height!=tile_height) {
       map_canvas_resize();
 
       XFillRectangle(display, map_canvas_store, fill_bg_gc, 0, 0, 
-                    NORMAL_TILE_WIDTH*map_canvas_store_twidth,
-                    NORMAL_TILE_HEIGHT*map_canvas_store_theight);
+                    NORMAL_TILE_WIDTH * mapview_canvas.tile_width,
+                    NORMAL_TILE_HEIGHT * mapview_canvas.tile_height);
 
       update_map_canvas_visible();
 
@@ -549,13 +554,13 @@
   mapview_canvas.width = width;
   mapview_canvas.height = height;
 
-  map_canvas_store_twidth=((width-1)/NORMAL_TILE_WIDTH)+1;
-  map_canvas_store_theight=((height-1)/NORMAL_TILE_HEIGHT)+1;
+  mapview_canvas.tile_width = ((width - 1) /NORMAL_TILE_WIDTH) + 1;
+  mapview_canvas.tile_height = ((height - 1) /NORMAL_TILE_HEIGHT) + 1;
 
   map_canvas_store=XCreatePixmap(display, XtWindow(map_canvas),
-                                map_canvas_store_twidth*NORMAL_TILE_WIDTH,
-                                map_canvas_store_theight*NORMAL_TILE_HEIGHT,
-                                display_depth);
+                       mapview_canvas.tile_width * NORMAL_TILE_WIDTH,
+                       mapview_canvas.tile_height * NORMAL_TILE_HEIGHT,
+                       display_depth);
 
   if (!mapview_canvas.store) {
     mapview_canvas.store = fc_malloc(sizeof(*mapview_canvas.store));
@@ -903,7 +908,9 @@
        int canvas_x, canvas_y;
        struct Sprite *mysprite = sprites.explode.nuke[y_itr][x_itr];
 
-       get_canvas_xy(x1, y1, &canvas_x, &canvas_y);
+       if (!map_to_canvas_pos(&canvas_x, &canvas_y, x1, y1)) {
+         continue;
+       }
        XCopyArea(display, map_canvas_store, single_tile_pixmap, civ_gc,
                  canvas_x, canvas_y, NORMAL_TILE_WIDTH, NORMAL_TILE_HEIGHT,
                  0, 0);
@@ -968,10 +975,9 @@
 **************************************************************************/
 void put_cross_overlay_tile(int x,int y)
 {
-  int canvas_x, canvas_y, is_real = normalize_map_pos(&x, &y);
-  assert(is_real);
+  int canvas_x, canvas_y;
 
-  if (get_canvas_xy(x, y, &canvas_x, &canvas_y)) {
+  if (map_to_canvas_pos(&canvas_x, &canvas_y, x, y)) {
     pixmap_put_overlay_tile(XtWindow(map_canvas), canvas_x, canvas_y,
                            sprites.user.attention);
   }
@@ -993,11 +999,12 @@
   }
 
   XSetForeground(display, fill_tile_gc, colors_standard[color]);
-  get_canvas_xy(pcity->x, pcity->y, &canvas_x, &canvas_y);
   city_map_checked_iterate(pcity->x, pcity->y, i, j, x, y) {
     enum city_tile_type worked = get_worker_city(pcity, i, j);
 
-    get_canvas_xy(x, y, &canvas_x, &canvas_y);
+    if (!map_to_canvas_pos(&canvas_x, &canvas_y, x, y)) {
+      continue;
+    }
     if (!is_city_center(i, j)) {
       if (worked == C_TILE_EMPTY) {
        XSetStipple(display, fill_tile_gc, gray25);
@@ -1092,7 +1099,7 @@
 static void put_line(Pixmap pm, int x, int y, int dir)
 {
   int canvas_src_x, canvas_src_y, canvas_dest_x, canvas_dest_y;
-  get_canvas_xy(x, y, &canvas_src_x, &canvas_src_y);
+  (void) map_to_canvas_pos(&canvas_src_x, &canvas_src_y, x, y);
   canvas_src_x += NORMAL_TILE_WIDTH/2;
   canvas_src_y += NORMAL_TILE_HEIGHT/2;
   canvas_dest_x = canvas_src_x + (NORMAL_TILE_WIDTH * DIR_DX[dir])/2;
Index: client/gui-xaw/mapview.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.h,v
retrieving revision 1.18
diff -u -r1.18 mapview.h
--- client/gui-xaw/mapview.h    2003/07/18 01:12:10     1.18
+++ client/gui-xaw/mapview.h    2004/01/28 02:38:57
@@ -47,14 +47,4 @@
 void scrollbar_scroll_callback(Widget w, XtPointer client_data,
                             XtPointer position_ptr);
 
-/* These values are stored in the mapview_canvas struct now. */
-#define map_view_x0 mapview_canvas.map_x0
-#define map_view_y0 mapview_canvas.map_y0
-#define map_canvas_store_twidth mapview_canvas.tile_width
-#define map_canvas_store_theight mapview_canvas.tile_height
-
-/* Use of these wrapper functions is deprecated. */
-#define get_canvas_xy(map_x, map_y, canvas_x, canvas_y) \
-  map_to_canvas_pos(canvas_x, canvas_y, map_x, map_y)
-
 #endif  /* FC__MAPVIEW_H */

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#7335) remove mapview macros for gui-xaw, Jason Short <=