Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2004:
[Freeciv-Dev] (PR#7726) unification of draw_segment
Home

[Freeciv-Dev] (PR#7726) unification of draw_segment

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#7726) unification of draw_segment
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 10 Mar 2004 17:19:58 -0800
Reply-to: rt@xxxxxxxxxxx

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

> [jdorje - Thu Mar 11 01:18:54 2004]:
> 
> Here's an update of the patch:
> 
> - Renamed some variables to match between the different drawing methods.
> - Renamed gui_put_line as canvas_put_line.
> - Rewrote a comment.
> 
> I think the speed different is trivial and this patch should go in.

Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.88
diff -u -r1.88 mapview_common.c
--- client/mapview_common.c     9 Mar 2004 19:10:40 -0000       1.88
+++ client/mapview_common.c     11 Mar 2004 01:15:46 -0000
@@ -1383,6 +1383,121 @@
   }
 }
 
+#define ABS(x) (((x) >= 0) ? (x) : -(x))
+
+/****************************************************************************
+  Put a segment on the mapview (in iso-view only).  The segment is drawn
+  from the source tile to the adjacent tile in the given direction.
+
+  This method is faster than the one used for non-iso view, but there are
+  two drawbacks:
+  1.  Since each line spans multiple tiles, updating a single tile is
+      harder (see update_map_canvas).
+  2.  We don't know where the map wraps, so we have problems when we reach
+      the wrapping point.  On very large mapviews this means segments might
+      not be drawn near the wrapping points.
+****************************************************************************/
+static void draw_segment_iso(int src_x, int src_y, enum direction8 dir)
+{
+  int dest_x, dest_y;
+  bool is_visible1, is_visible2;
+  int canvas_src_x, canvas_src_y;
+  int canvas_dest_x, canvas_dest_y;
+
+  if (!MAPSTEP(dest_x, dest_y, src_x, src_y, dir)) {
+    assert(0);
+    return;
+  }
+
+  /* Find middle of tiles. y-1 to not undraw the the middle pixel of a
+     horizontal line when we refresh the tile below-between. */
+  is_visible1
+    = map_to_canvas_pos(&canvas_src_x, &canvas_src_y, src_x, src_y);
+  is_visible2
+    = map_to_canvas_pos(&canvas_dest_x, &canvas_dest_y, dest_x, dest_y);
+
+  if (!is_visible1 && !is_visible2) {
+    return; /* No need to draw anything. */
+  }
+
+  canvas_src_x += NORMAL_TILE_WIDTH/2;
+  canvas_src_y += NORMAL_TILE_HEIGHT/2-1;
+  canvas_dest_x += NORMAL_TILE_WIDTH/2;
+  canvas_dest_y += NORMAL_TILE_HEIGHT/2-1;
+
+  /* HACK: sometimes we draw from a source tile on one side of the screen
+   * to a destination tile on the other side.  In this case we don't want
+   * to draw garbage.  Instead we just don't draw the line at all.  Note
+   * that the non-iso-view method of drawing doesn't have this problem. */
+  if (abs(canvas_dest_x - canvas_src_x) > NORMAL_TILE_WIDTH
+      || abs(canvas_dest_y - canvas_src_y) > NORMAL_TILE_HEIGHT)
+    return;
+
+  /* draw it! */
+  canvas_put_line(mapview_canvas.store, COLOR_STD_CYAN, LINE_GOTO,
+                 canvas_src_x, canvas_src_y,
+                 canvas_dest_x - canvas_src_x,
+                 canvas_dest_y - canvas_src_y);
+  dirty_rect(MIN(canvas_src_x, canvas_dest_x) - 1,
+            MIN(canvas_src_y, canvas_dest_y) - 1,
+            ABS(canvas_dest_x - canvas_src_x) + 2,
+            ABS(canvas_dest_y - canvas_src_y) + 2);
+}
+
+/****************************************************************************
+  Put a half-segment (in non-iso view only).  The segment goes from the
+  given tile *toward* the adjacent tile in the given direction.  However
+  it only goes the the edge of the source tile.  Thus only one tile is
+  spanned (making updates of single tiles easier) but two lines must be
+  drawn to get a single segment (meaning more work & slower).
+****************************************************************************/
+static void put_line(int x, int y, enum direction8 dir)
+{
+  int canvas_src_x, canvas_src_y, canvas_dest_x, canvas_dest_y;
+
+  if (!map_to_canvas_pos(&canvas_src_x, &canvas_src_y, x, y)) {
+    return;
+  }
+  canvas_src_x += NORMAL_TILE_WIDTH/2;
+  canvas_src_y += NORMAL_TILE_HEIGHT/2;
+  DIRSTEP(canvas_dest_x, canvas_dest_y, dir);
+  canvas_dest_x = canvas_src_x + (NORMAL_TILE_WIDTH * canvas_dest_x) / 2;
+  canvas_dest_y = canvas_src_y + (NORMAL_TILE_WIDTH * canvas_dest_y) / 2;
+
+  canvas_put_line(mapview_canvas.store, COLOR_STD_CYAN, LINE_GOTO,
+                 canvas_src_x, canvas_src_y,
+                 canvas_dest_x - canvas_src_x,
+                 canvas_dest_y - canvas_src_y);
+
+  dirty_rect(MIN(canvas_src_x, canvas_dest_x) - 1,
+            MIN(canvas_src_y, canvas_dest_y) - 1,
+            ABS(canvas_dest_x - canvas_src_x) + 2,
+            ABS(canvas_dest_y - canvas_src_y) + 2);
+}
+
+/****************************************************************************
+  Draw a goto line at the given location and direction.  The line goes from
+  the source tile to the adjacent tile in the given direction.
+****************************************************************************/
+void draw_segment(int src_x, int src_y, enum direction8 dir)
+{
+  if (is_isometric) {
+    draw_segment_iso(src_x, src_y, dir);
+  } else {
+    int dest_x, dest_y, is_real;
+
+    is_real = MAPSTEP(dest_x, dest_y, src_x, src_y, dir);
+    assert(is_real);
+
+    if (tile_visible_mapcanvas(src_x, src_y)) {
+      put_line(src_x, src_y, dir);
+    }
+    if (tile_visible_mapcanvas(dest_x, dest_y)) {
+      put_line(dest_x, dest_y, DIR_REVERSE(dir));
+    }
+  }
+}
+
 /**************************************************************************
   Remove the line from src_x, src_y in the given direction, and redraw
   the change if necessary.
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.50
diff -u -r1.50 mapview_common.h
--- client/mapview_common.h     8 Mar 2004 07:20:49 -0000       1.50
+++ client/mapview_common.h     11 Mar 2004 01:15:46 -0000
@@ -14,6 +14,7 @@
 #ifndef FC__MAPVIEW_COMMON_H
 #define FC__MAPVIEW_COMMON_H
 
+#include "map.h"
 #include "shared.h"            /* bool type */
 
 #include "colors_g.h"
@@ -188,6 +189,7 @@
 void show_city_descriptions(void);
 bool show_unit_orders(struct unit *punit);
 
+void draw_segment(int src_x, int src_y, enum direction8 dir);
 void undraw_segment(int src_x, int src_y, int dir);
 
 void decrease_unit_hp_smooth(struct unit *punit0, int hp0, 
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.204
diff -u -r1.204 mapview.c
--- client/gui-gtk/mapview.c    9 Mar 2004 19:10:41 -0000       1.204
+++ client/gui-gtk/mapview.c    11 Mar 2004 01:15:47 -0000
@@ -55,7 +55,6 @@
 static void pixmap_put_overlay_tile(GdkDrawable *pixmap,
                                    int canvas_x, int canvas_y,
                                    struct Sprite *ssprite);
-static void put_line(GdkDrawable *pm, int x, int y, int dir);
 
 static void pixmap_put_overlay_tile_draw(GdkDrawable *pixmap,
                                         int canvas_x, int canvas_y,
@@ -63,8 +62,6 @@
                                         int offset_x, int offset_y,
                                         int width, int height,
                                         bool fog);
-static void really_draw_segment(int src_x, int src_y, int dir,
-                               bool write_to_screen, bool force);
 static void pixmap_put_tile_iso(GdkDrawable *pm, int x, int y,
                                int canvas_x, int canvas_y,
                                int citymode,
@@ -776,6 +773,9 @@
   case LINE_TILE_FRAME:
     gc = thick_line_gc;
     break;
+  case LINE_GOTO:
+    gc = thick_line_gc;
+    break;
   }
 
   gdk_gc_set_foreground(gc, colors_standard[color]);
@@ -1006,30 +1006,6 @@
 }
 
 /**************************************************************************
-...
-**************************************************************************/
-void draw_segment(int src_x, int src_y, int dir)
-{
-  if (is_isometric) {
-    really_draw_segment(src_x, src_y, dir, TRUE, FALSE);
-  } else {
-    int dest_x, dest_y, is_real;
-
-    is_real = MAPSTEP(dest_x, dest_y, src_x, src_y, dir);
-    assert(is_real);
-
-    if (tile_visible_mapcanvas(src_x, src_y)) {
-      put_line(map_canvas_store, src_x, src_y, dir);
-      put_line(map_canvas->window, src_x, src_y, dir);
-    }
-    if (tile_visible_mapcanvas(dest_x, dest_y)) {
-      put_line(map_canvas_store, dest_x, dest_y, DIR_REVERSE(dir));
-      put_line(map_canvas->window, dest_x, dest_y, DIR_REVERSE(dir));
-    }
-  }
-}
-
-/**************************************************************************
  Area Selection
 **************************************************************************/
 void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h)
@@ -1047,26 +1023,6 @@
             canvas_x + w, canvas_y, canvas_x + w, canvas_y + h);
 
   rectangle_active = TRUE;
-}
-
-/**************************************************************************
-Not used in isometric view.
-**************************************************************************/
-static void put_line(GdkDrawable *pm, int x, int y, int dir)
-{
-  int canvas_src_x, canvas_src_y, canvas_dest_x, canvas_dest_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;
-  DIRSTEP(canvas_dest_x, canvas_dest_y, dir);
-  canvas_dest_x = canvas_src_x + (NORMAL_TILE_WIDTH * canvas_dest_x) / 2;
-  canvas_dest_y = canvas_src_y + (NORMAL_TILE_WIDTH * canvas_dest_y) / 2;
-
-  gdk_gc_set_foreground(civ_gc, colors_standard[COLOR_STD_CYAN]);
-
-  gdk_draw_line(pm, civ_gc,
-               canvas_src_x, canvas_src_y,
-               canvas_dest_x, canvas_dest_y);
 }
 
 /**************************************************************************
Index: client/gui-gtk-2.0/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.104
diff -u -r1.104 mapview.c
--- client/gui-gtk-2.0/mapview.c        9 Mar 2004 19:10:41 -0000       1.104
+++ client/gui-gtk-2.0/mapview.c        11 Mar 2004 01:15:47 -0000
@@ -56,7 +56,6 @@
 static void pixmap_put_overlay_tile(GdkDrawable *pixmap,
                                    int canvas_x, int canvas_y,
                                    struct Sprite *ssprite);
-static void put_line(GdkDrawable *pm, int x, int y, int dir);
 
 static void pixmap_put_overlay_tile_draw(GdkDrawable *pixmap,
                                         int canvas_x, int canvas_y,
@@ -64,8 +63,6 @@
                                         int offset_x, int offset_y,
                                         int width, int height,
                                         bool fog);
-static void really_draw_segment(int src_x, int src_y, int dir,
-                               bool write_to_screen, bool force);
 static void pixmap_put_tile_iso(GdkDrawable *pm, int x, int y,
                                int canvas_x, int canvas_y,
                                int citymode,
@@ -846,6 +843,9 @@
   case LINE_TILE_FRAME:
     gc = thick_line_gc;
     break;
+  case LINE_GOTO:
+    gc = thick_line_gc;
+    break;
   }
 
   gdk_gc_set_foreground(gc, colors_standard[color]);
@@ -1034,82 +1034,6 @@
   set_mapview_scroll_pos(scroll_x, scroll_y);
 }
 
-  
-/**************************************************************************
-draw a line from src_x,src_y -> dest_x,dest_y on both map_canvas and
-map_canvas_store
-FIXME: We currently always draw the line.
-Only used for isometric view.
-**************************************************************************/
-static void really_draw_segment(int src_x, int src_y, int dir,
-                               bool write_to_screen, bool force)
-{
-  int dest_x, dest_y;
-  bool is_real, is_visible1, is_visible2;
-  int canvas_start_x, canvas_start_y;
-  int canvas_end_x, canvas_end_y;
-
-  gdk_gc_set_foreground(thick_line_gc, colors_standard[COLOR_STD_CYAN]);
-
-  is_real = MAPSTEP(dest_x, dest_y, src_x, src_y, dir);
-  assert(is_real);
-
-  /* Find middle of tiles. y-1 to not undraw the the middle pixel of a
-     horizontal line when we refresh the tile below-between. */
-  is_visible1
-    = map_to_canvas_pos(&canvas_start_x, &canvas_start_y, src_x, src_y);
-  is_visible2
-    = map_to_canvas_pos(&canvas_end_x, &canvas_end_y, dest_x, dest_y);
-
-  if (!is_visible1 && !is_visible2) {
-    return; /* No need to draw anything. */
-  }
-
-  canvas_start_x += NORMAL_TILE_WIDTH/2;
-  canvas_start_y += NORMAL_TILE_HEIGHT/2-1;
-  canvas_end_x += NORMAL_TILE_WIDTH/2;
-  canvas_end_y += NORMAL_TILE_HEIGHT/2-1;
-
-  /* somewhat hackish way of solving the problem where draw from a tile on
-     one side of the screen out of the screen, and the tile we draw to is
-     found to be on the other side of the screen. */
-  if (abs(canvas_end_x - canvas_start_x) > NORMAL_TILE_WIDTH
-      || abs(canvas_end_y - canvas_start_y) > NORMAL_TILE_HEIGHT)
-    return;
-
-  /* draw it! */
-  gdk_draw_line(map_canvas_store, thick_line_gc,
-               canvas_start_x, canvas_start_y, canvas_end_x, canvas_end_y);
-  if (write_to_screen)
-    gdk_draw_line(map_canvas->window, thick_line_gc,
-                 canvas_start_x, canvas_start_y, canvas_end_x, canvas_end_y);
-  return;
-}
-
-/**************************************************************************
-...
-**************************************************************************/
-void draw_segment(int src_x, int src_y, int dir)
-{
-  if (is_isometric) {
-    really_draw_segment(src_x, src_y, dir, TRUE, FALSE);
-  } else {
-    int dest_x, dest_y, is_real;
-
-    is_real = MAPSTEP(dest_x, dest_y, src_x, src_y, dir);
-    assert(is_real);
-
-    if (tile_visible_mapcanvas(src_x, src_y)) {
-      put_line(map_canvas_store, src_x, src_y, dir);
-      put_line(map_canvas->window, src_x, src_y, dir);
-    }
-    if (tile_visible_mapcanvas(dest_x, dest_y)) {
-      put_line(map_canvas_store, dest_x, dest_y, DIR_REVERSE(dir));
-      put_line(map_canvas->window, dest_x, dest_y, DIR_REVERSE(dir));
-    }
-  }
-}
-
 /**************************************************************************
  Area Selection
 **************************************************************************/
@@ -1128,26 +1052,6 @@
             canvas_x + w, canvas_y, canvas_x + w, canvas_y + h);
 
   rectangle_active = TRUE;
-}
-
-/**************************************************************************
-Not used in isometric view.
-**************************************************************************/
-static void put_line(GdkDrawable *pm, int x, int y, int dir)
-{
-  int canvas_src_x, canvas_src_y, canvas_dest_x, canvas_dest_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;
-  DIRSTEP(canvas_dest_x, canvas_dest_y, dir);
-  canvas_dest_x = canvas_src_x + (NORMAL_TILE_WIDTH * canvas_dest_x) / 2;
-  canvas_dest_y = canvas_src_y + (NORMAL_TILE_WIDTH * canvas_dest_y) / 2;
-
-  gdk_gc_set_foreground(civ_gc, colors_standard[COLOR_STD_CYAN]);
-
-  gdk_draw_line(pm, civ_gc,
-               canvas_src_x, canvas_src_y,
-               canvas_dest_x, canvas_dest_y);
 }
 
 /**************************************************************************
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.102
diff -u -r1.102 mapview.c
--- client/gui-win32/mapview.c  9 Mar 2004 19:10:41 -0000       1.102
+++ client/gui-win32/mapview.c  11 Mar 2004 01:15:47 -0000
@@ -73,14 +73,10 @@
                                 int offset_x, int offset_y, int offset_y_unit,
                                 int width, int height, int height_unit,
                                 enum draw_type draw);
-static void really_draw_segment(HDC mapstoredc,int src_x, int src_y, int dir,
-                               bool write_to_screen, bool force);
 static void dither_tile(HDC hdc, struct Sprite **dither,
                         int canvas_x, int canvas_y,
                         int offset_x, int offset_y,
                         int width, int height, bool fog);
-static void put_line(HDC hdc, int x, int y, 
-                    int dir, bool write_to_screen);
 static void draw_rates(HDC hdc);
 
 
@@ -903,61 +899,6 @@
 }
 
 /**************************************************************************
-draw a line from src_x,src_y -> dest_x,dest_y on both map_canvas and
-map_canvas_store
-FIXME: We currently always draw the line.
-Only used for isometric view.
-**************************************************************************/
-static void really_draw_segment(HDC mapstoredc,int src_x, int src_y, int dir,
-                                bool write_to_screen, bool force)
-{
-
-  HPEN old;
-  int dest_x, dest_y, is_real;
-  int canvas_start_x, canvas_start_y;
-  int canvas_end_x, canvas_end_y;
-
-  is_real = MAPSTEP(dest_x, dest_y, src_x, src_y, dir);
-  assert(is_real);
-
-  /* Find middle of tiles. y-1 to not undraw the the middle pixel of a
-     horizontal line when we refresh the tile below-between. */
-  get_canvas_xy(src_x, src_y, &canvas_start_x, &canvas_start_y);
-  get_canvas_xy(dest_x, dest_y, &canvas_end_x, &canvas_end_y);
-  canvas_start_x += NORMAL_TILE_WIDTH/2;
-  canvas_start_y += NORMAL_TILE_HEIGHT/2-1;
-  canvas_end_x += NORMAL_TILE_WIDTH/2;
-  canvas_end_y += NORMAL_TILE_HEIGHT/2-1;
-
-  /* somewhat hackish way of solving the problem where draw from a tile on
-     one side of the screen out of the screen, and the tile we draw to is
-     found to be on the other side of the screen. */
-  if (abs(canvas_end_x - canvas_start_x) > NORMAL_TILE_WIDTH
-      || abs(canvas_end_y - canvas_start_y) > NORMAL_TILE_HEIGHT)
-    return;
-  
-  old=SelectObject(mapstoredc, pen_std[COLOR_STD_CYAN]);
-  /* draw it! */
-  MoveToEx(mapstoredc,canvas_start_x,canvas_start_y,NULL);
-  LineTo(mapstoredc,canvas_end_x,canvas_end_y);
-  SelectObject(mapstoredc,old);
-  if (write_to_screen) {
-    HDC hdc;
-    hdc=GetDC(map_window);
-    
-    old=SelectObject(hdc, pen_std[COLOR_STD_CYAN]);
-    
-    MoveToEx(hdc,canvas_start_x,canvas_start_y,NULL);
-    LineTo(hdc,canvas_end_x,canvas_end_y);
-    SelectObject(hdc,old);
-    ReleaseDC(map_window,hdc);
-  }
-  return;
-}
-
-
-
-/**************************************************************************
 Only used for isometric view.
 **************************************************************************/
 static void pixmap_put_overlay_tile_draw(HDC hdc,
@@ -1116,6 +1057,7 @@
     hdc = GetDC(root_window);
   }
 
+  /* FIXME: set line type (size). */
   old_pen = SelectObject(hdc, pen_std[color]);
   MoveToEx(hdc, start_x, start_y, NULL);
   LineTo(hdc, start_x + dx, start_y + dy);
@@ -1366,73 +1308,6 @@
                                  offset_x, offset_y_unit,
                                  width, height_unit, fog);
   
-}
-
-
-
-/**************************************************************************
-Not used in isometric view.
-**************************************************************************/
-static void put_line(HDC hdc, int x, int y, 
-                    int dir, bool write_to_screen)
-{
-  HPEN old;
-  int canvas_src_x, canvas_src_y, canvas_dest_x, canvas_dest_y;
-  get_canvas_xy(x, y, &canvas_src_x, &canvas_src_y);
-  canvas_src_x += NORMAL_TILE_WIDTH/2;
-  canvas_src_y += NORMAL_TILE_HEIGHT/2;
-  DIRSTEP(canvas_dest_x, canvas_dest_y, dir);
-  canvas_dest_x = canvas_src_x + (NORMAL_TILE_WIDTH * canvas_dest_x) / 2;
-  canvas_dest_y = canvas_src_y + (NORMAL_TILE_WIDTH * canvas_dest_y) / 2;
- 
-  old=SelectObject(hdc,pen_std[COLOR_STD_CYAN]);
-  MoveToEx(hdc,canvas_src_x,
-          canvas_src_y,
-          NULL);
-  LineTo(hdc,canvas_dest_x,
-        canvas_dest_y);
-  SelectObject(hdc,old);
-}
-
-
-/**************************************************************************
-...
-**************************************************************************/
-void draw_segment(int src_x, int src_y, int dir)
-{
-  HDC hdc;
-
-  assert(get_drawn(src_x, src_y, dir) > 0);
-
-  if (is_isometric) {
-    HDC mapstoredc = CreateCompatibleDC(NULL);
-    HBITMAP old = SelectObject(mapstoredc, mapstorebitmap);
-
-    really_draw_segment(mapstoredc, src_x, src_y, dir, TRUE, FALSE);
-    SelectObject(mapstoredc, old);
-    DeleteDC(mapstoredc);
-  } else {
-    int dest_x, dest_y, is_real;
-    HBITMAP old;
-    HDC mapstoredc;
-    is_real = MAPSTEP(dest_x, dest_y, src_x, src_y, dir);
-    assert(is_real);
-
-    mapstoredc=CreateCompatibleDC(NULL);
-    old=SelectObject(mapstoredc,mapstorebitmap);
-    hdc=GetDC(map_window);
-    if (tile_visible_mapcanvas(src_x, src_y)) {
-      put_line(mapstoredc, src_x, src_y, dir,0);
-      put_line(hdc, src_x, src_y, dir,1);
-    }
-    if (tile_visible_mapcanvas(dest_x, dest_y)) {
-      put_line(mapstoredc, dest_x, dest_y, DIR_REVERSE(dir),0);
-      put_line(hdc, dest_x, dest_y, DIR_REVERSE(dir),1);
-    }
-    ReleaseDC(map_window,hdc);
-    SelectObject(mapstoredc,old);
-    DeleteDC(mapstoredc);
-  }
 }
 
 /**************************************************************************
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.167
diff -u -r1.167 mapview.c
--- client/gui-xaw/mapview.c    9 Mar 2004 19:10:41 -0000       1.167
+++ client/gui-xaw/mapview.c    11 Mar 2004 01:15:47 -0000
@@ -56,7 +56,6 @@
 
 static void pixmap_put_overlay_tile(Pixmap pixmap, int x, int y,
                                    struct Sprite *ssprite);
-static void put_line(Pixmap pm, int x, int y, int dir);
 
 /* the intro picture is held in this pixmap, which is scaled to
    the screen size */
@@ -493,9 +492,22 @@
                     enum line_type ltype, int start_x, int start_y,
                     int dx, int dy)
 {
-  GC gc;
+  GC gc = NULL;
+
+  switch (ltype) {
+  case LINE_NORMAL:
+    gc = civ_gc;
+    break;
+  case LINE_BORDER:
+    gc = border_line_gc;
+    break;
+  case LINE_TILE_FRAME:
+  case LINE_GOTO:
+    /* TODO: differentiate these. */
+    gc = civ_gc;
+    break;
+  }
 
-  gc = (ltype == LINE_BORDER ? border_line_gc : civ_gc);
   XSetForeground(display, gc, colors_standard[color]);
   XDrawLine(display, pcanvas->pixmap, gc,
            start_x, start_y, start_x + dx, start_y + dy);
@@ -874,45 +886,6 @@
 
   set_mapview_scroll_pos(scroll_x, scroll_y);
   update_map_canvas_scrollbars();
-}
-
-/**************************************************************************
-...
-**************************************************************************/
-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;
-  (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;
-  canvas_dest_y = canvas_src_y + (NORMAL_TILE_WIDTH * DIR_DY[dir])/2;
-
-  XSetForeground(display, civ_gc, colors_standard[COLOR_STD_CYAN]);
-
-  XDrawLine(display, pm, civ_gc, canvas_src_x, canvas_src_y,
-           canvas_dest_x, canvas_dest_y);
-}
-
-/**************************************************************************
-...
-**************************************************************************/
-void draw_segment(int src_x, int src_y, int dir)
-{
-  int dest_x, dest_y, is_real;
-
-  is_real = MAPSTEP(dest_x, dest_y, src_x, src_y, dir);
-  assert(is_real);
-
-  if (tile_visible_mapcanvas(src_x, src_y)) {
-    put_line(map_canvas_store, src_x, src_y, dir);
-    put_line(XtWindow(map_canvas), src_x, src_y, dir);
-  }
-
-  if (tile_visible_mapcanvas(dest_x, dest_y)) {
-    put_line(map_canvas_store, dest_x, dest_y, DIR_REVERSE(dir));
-    put_line(XtWindow(map_canvas), dest_x, dest_y, DIR_REVERSE(dir));
-  }
 }
 
 /**************************************************************************
Index: client/include/colors_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/colors_g.h,v
retrieving revision 1.8
diff -u -r1.8 colors_g.h
--- client/include/colors_g.h   27 Feb 2004 16:30:33 -0000      1.8
+++ client/include/colors_g.h   11 Mar 2004 01:15:47 -0000
@@ -28,7 +28,7 @@
 };
 
 enum line_type {
-  LINE_NORMAL, LINE_BORDER, LINE_TILE_FRAME
+  LINE_NORMAL, LINE_BORDER, LINE_TILE_FRAME, LINE_GOTO
 };
 
 enum Display_color_type {
Index: client/include/mapview_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/mapview_g.h,v
retrieving revision 1.49
diff -u -r1.49 mapview_g.h
--- client/include/mapview_g.h  9 Mar 2004 19:10:42 -0000       1.49
+++ client/include/mapview_g.h  11 Mar 2004 01:15:47 -0000
@@ -77,7 +77,6 @@
                               int old_canvas_x, int old_canvas_y,
                               int new_canvas_x, int new_canvas_y);
 
-void draw_segment(int src_x, int src_y, int dir);
 void draw_selection_rectangle(int canvas_x, int canvas_y, int w, int h);
 void tileset_changed(void);
 

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