Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: [PATCH] bugfix for wrapping problem
Home

[Freeciv-Dev] Re: [PATCH] bugfix for wrapping problem

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Jason Dorje Short <jshort@xxxxxxxxxxxxx>
Cc: rf13@xxxxxxxxxxxxxxxxxxxxxx, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] bugfix for wrapping problem
From: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Date: Fri, 24 Aug 2001 15:18:48 -0400

Are there any GUI experts around?

IMHO, having the same position drawn more than once is an error. If
you stretch the canvas to exceed the base map size, I'm not sure
that seeing only a single valued map isn't the desired behaviour. If 
there is a vote, I would vote for this, and not the other.

Resize, if ever implemented, may make the argument mute though.

I think the patch should NOT be applied until this is worked out.

Cheers,
RossW
=====

At 04:32 AM 01/08/24 -0400, Jason Dorje Short wrote:
>Raimar Falke wrote:
>> 
>
>> So we need another type of positions in the client gui? Since I like
>> "map pos(ition)" for the general (almost always normalized)
>> position. What about "canvas position"? This is just so that nobody
>> will get misunderstood.
>
>Canvas position is no good because canvas_x and canvas_y are used for
>drawing positions (pixels).
>
>If any new nomenclature is needed, it should be "absolute".  In my
>patch, I've used this as a naming convention, i.e. abs_x versus map_x.
>
>The attached patch should be in a usable form.  It fixes the wrapping
>problem for drawing cities as well - the error was identical.  It
>doesn't touch isometric view code, and only fixes GTK.  I don't see any
>reason not apply it :-)
>
>There's still a small bug: when updating units received from the server
>the client will only move them in one position, leaving the other tile
>of the unit in place.  When the client next does a redraw (soon after)
>they'll get updated.  This should only be a problem for people using a
>super-wide window.
>
>jasonIndex: client/gui-gtk/mapview.c
>===================================================================
>RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
>retrieving revision 1.90
>diff -u -r1.90 mapview.c
>--- client/gui-gtk/mapview.c   2001/08/24 07:12:45     1.90
>+++ client/gui-gtk/mapview.c   2001/08/24 08:22:53
>@@ -254,7 +254,7 @@
> Beside setting the results in canvas_x,canvas_y it returns whether the tile
> is inside the visible map.
> **************************************************************************/
>-static int get_canvas_xy(int map_x, int map_y, int *canvas_x, int *canvas_y)
>+static int get_canvas_xy(int abs_x, int abs_y, int *canvas_x, int *canvas_y)
> {
>   if (is_isometric) {
>     /* canvas_x,canvas_y is the top corner of the actual tile, not the
pixmap.
>@@ -265,6 +265,7 @@
>     int diff_xy;
>     int diff_x, diff_y;
>     int width, height;
>+    int map_x = abs_x, map_y = abs_y; /* FIXME: we should use abs coords */
>     gdk_window_get_size(map_canvas->window, &width, &height);
> 
>     map_x %= map.xsize;
>@@ -294,19 +295,10 @@
>       && (*canvas_y > -NORMAL_TILE_HEIGHT)
>       && (*canvas_y < height);
>   } else { /* is_isometric */
>-    if (map_view_x0+map_canvas_store_twidth <= map.xsize)
>-      *canvas_x = map_x-map_view_x0;
>-    else if(map_x >= map_view_x0)
>-      *canvas_x = map_x-map_view_x0;
>-    else if(map_x < map_adjust_x(map_view_x0+map_canvas_store_twidth))
>-      *canvas_x = map_x+map.xsize-map_view_x0;
>-    else *canvas_x = -1;
> 
>-    *canvas_y = map_y - map_view_y0;
>+    *canvas_x = NORMAL_TILE_WIDTH * (abs_x - map_view_x0);
>+    *canvas_y = NORMAL_TILE_HEIGHT * (abs_y - map_view_y0);
> 
>-    *canvas_x *= NORMAL_TILE_WIDTH;
>-    *canvas_y *= NORMAL_TILE_HEIGHT;
>-
>     return *canvas_x >= 0
>       && *canvas_x < map_canvas_store_twidth*NORMAL_TILE_WIDTH
>       && *canvas_y >= 0
>@@ -658,9 +650,7 @@
>     return get_canvas_xy(x, y, &dummy_x, &dummy_y);
>   } else {
>     return (y>=map_view_y0 && y<map_view_y0+map_canvas_store_theight &&
>-          ((x>=map_view_x0 && x<map_view_x0+map_canvas_store_twidth) ||
>-           (x+map.xsize>=map_view_x0 && 
>-            x+map.xsize<map_view_x0+map_canvas_store_twidth)));
>+          x>=map_view_x0 && x<map_view_x0+map_canvas_store_twidth);
>   }
> }
> 
>@@ -1397,13 +1387,10 @@
> 
>     for (y_itr=y; y_itr<y+height; y_itr++) {
>       for (x_itr=x; x_itr<x+width; x_itr++) {
>-      int map_x = map_adjust_x(x_itr);
>-      int map_y = y_itr; /* not adjusted;, we want to draw black tiles */
>-
>-      get_canvas_xy(map_x, map_y, &canvas_x, &canvas_y);
>-      if (tile_visible_mapcanvas(map_x, map_y)) {
>+      get_canvas_xy(x_itr, y_itr, &canvas_x, &canvas_y);
>+      if (tile_visible_mapcanvas(x_itr, y_itr)) {
>         pixmap_put_tile(map_canvas_store,
>-                        map_x, map_y,
>+                        x_itr, y_itr,
>                         canvas_x, canvas_y, 0);
>       }
>       }
>@@ -1466,15 +1453,21 @@
> /**************************************************************************
> ...
> **************************************************************************/
>-static void show_desc_at_tile(int x, int y)
>+static void show_desc_at_tile(int abs_x, int abs_y)
> {
>   static char buffer[512];
>   struct city *pcity;
>-  if ((pcity = map_get_city(x, y))) {
>+  int map_x = abs_x, map_y = abs_y;
>+
>+  /* abs_x/abs_y are absolute coordinates used for drawing;
>+   * map_x/map_y are map coordinates that should be normalized. */
>+  if (!normalize_map_pos(&map_x, &map_y)) return;
>+
>+  if ((pcity = map_get_city(map_x, map_y))) {
>     int canvas_x, canvas_y;
>     int w;
> 
>-    get_canvas_xy(x, y, &canvas_x, &canvas_y);
>+    get_canvas_xy(abs_x, abs_y, &canvas_x, &canvas_y);
>     if (draw_city_names) {
>       my_snprintf(buffer, sizeof(buffer), "%s", pcity->name);
>       w = gdk_string_width(main_font, buffer);
>@@ -1550,12 +1543,10 @@
>     int x, y;
>     int x1, y1;
>     for (x1 = 0; x1 < map_canvas_store_twidth; x1++) {
>-      x = (map_view_x0 + x1) % map.xsize;
>+      x = map_view_x0 + x1;
>       for (y1 = 0; y1 < map_canvas_store_twidth; y1++) {
>       y = map_view_y0 + y1;
>-      if (normalize_map_pos(&x, &y)) {
>-        show_desc_at_tile(x, y);
>-      }
>+      show_desc_at_tile(x, y);
>       }
>     }
>   }
>



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