Complete.Org: Mailing Lists: Archives: freeciv-dev: June 2004:
[Freeciv-Dev] (PR#8964) goto line bugs
Home

[Freeciv-Dev] (PR#8964) goto line bugs

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8964) goto line bugs
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 14 Jun 2004 17:28:30 -0700
Reply-to: rt@xxxxxxxxxxx

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

> [jdorje - Sat Jun 12 07:06:33 2004]:
> 
> There are at least one and probably two bugs with the drawing of goto
lines.

> I believe the attached patch fixes both problems.  Note that one place 
> should use map_to_gui_vector() when it is written.

And here's an updated version of the patch.  It uses map_to_gui_vector.

jason

Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.125
diff -u -r1.125 mapview_common.c
--- client/mapview_common.c     13 Jun 2004 16:53:34 -0000      1.125
+++ client/mapview_common.c     15 Jun 2004 00:27:27 -0000
@@ -1446,8 +1446,14 @@
   }
 
   /* Draw the goto lines on top of the whole thing. This is done last as
-   * we want it completely on top. */
-  gui_rect_iterate(gui_x0, gui_y0, width, height, map_x, map_y, draw) {
+   * we want it completely on top.
+   *
+   * Note that a pixel right on the border of a tile may actually contain a
+   * goto line from an adjacent tile.  Thus we draw any extra goto lines
+   * from adjacent tiles (if they're close enough). */
+  gui_rect_iterate(gui_x0 - GOTO_WIDTH, gui_y0 - GOTO_WIDTH,
+                  width + 2 * GOTO_WIDTH, height + 2 * GOTO_WIDTH,
+                  map_x, map_y, draw) {
     if (((draw & D_B) || (draw & D_M))
        && normalize_map_pos(&map_x, &map_y)) {
       adjc_dir_iterate(map_x, map_y, adjc_x, adjc_y, dir) {
@@ -1749,7 +1755,7 @@
 **************************************************************************/
 void undraw_segment(int src_x, int src_y, int dir)
 {
-  int dest_x, dest_y;
+  int dest_x, dest_y, canvas_x, canvas_y, canvas_dx, canvas_dy;
 
   assert(!is_drawn_line(src_x, src_y, dir));
 
@@ -1757,26 +1763,17 @@
     assert(0);
   }
 
-  refresh_tile_mapcanvas(src_x, src_y, FALSE);
-  refresh_tile_mapcanvas(dest_x, dest_y, FALSE);
-
-  if (!is_isometric) {
-    if (NORMAL_TILE_WIDTH % 2 == 0 || NORMAL_TILE_HEIGHT % 2 == 0) {
-      if (dir == DIR8_NORTHEAST) {
-       /* Since the tile doesn't have a middle we draw an extra pixel
-        * on the adjacent tile when drawing in this direction. */
-       if (!MAPSTEP(dest_x, dest_y, src_x, src_y, DIR8_EAST)) {
-         assert(0);
-       }
-       refresh_tile_mapcanvas(dest_x, dest_y, FALSE);
-      } else if (dir == DIR8_SOUTHWEST) {      /* the same */
-       if (!MAPSTEP(dest_x, dest_y, src_x, src_y, DIR8_SOUTH)) {
-         assert(0);
-       }
-       refresh_tile_mapcanvas(dest_x, dest_y, FALSE);
-      }
-    }
-  }
+  /* Note that if source and dest tiles are not adjacent (because the
+   * mapview wraps around) this will not give the correct behavior.  This is
+   * consistent with the current design which fails when the size of the
+   * mapview approaches the size of the map. */
+  (void) map_to_canvas_pos(&canvas_x, &canvas_y, src_x, src_y);
+  map_to_gui_vector(&canvas_dx, &canvas_dy, DIR_DX[dir], DIR_DY[dir]);
+
+  update_map_canvas(MIN(canvas_x, canvas_x + canvas_dx),
+                   MIN(canvas_y, canvas_y + canvas_dy),
+                   ABS(canvas_dx) + NORMAL_TILE_WIDTH,
+                   ABS(canvas_dy) + NORMAL_TILE_HEIGHT);
 }
 
 /****************************************************************************
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.67
diff -u -r1.67 mapview_common.h
--- client/mapview_common.h     13 Jun 2004 16:53:34 -0000      1.67
+++ client/mapview_common.h     15 Jun 2004 00:27:27 -0000
@@ -128,6 +128,7 @@
 #define D_FULL D_TMB_LR
 
 #define BORDER_WIDTH 2
+#define GOTO_WIDTH 2
 
 enum update_type {
   /* Masks */

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