Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] remove map_canvas_adjust_[xy] (PR#1129)
Home

[Freeciv-Dev] remove map_canvas_adjust_[xy] (PR#1129)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] remove map_canvas_adjust_[xy] (PR#1129)
From: jdorje@xxxxxxxxxxxxxxxxxxxxx
Date: Thu, 13 Dec 2001 01:46:46 -0800 (PST)

The functions map_canvas_adjust_x and map_canvas_adjust_y are GUI-specific functions listed in the interface specification (i.e. include in gui-stub), but not used anywhere outside of the GUI-specific code.

The functions are supposed to wrap X and Y coordinates, and then translate them to fit within the GUI window. This means they are the functional equivalent of Ross's unnormalize_map_pos or my find_representative_map_pos, plus a subtraction of the window origin (I'm sure Ross would point out that they mix concepts badly :-). The major problem is that the interface uses different functions for X and Y coordinates, and will therefore be worthless under any map that doesn't wrap along the X and Y axes.

Furthermore, these functions are used very little. gui-gtk and gui-xaw don't even define them. gui-beos has the stub functions in place, but no more. gui-mui does _not_ have the functions defined, but tries to use them anyway in some #defined-out code. gui-win32 does define the functions, and uses them in one place.

I therefore see no problem with simply removing them. This will take things one step further toward iso-rectangular maps. In this patch I therefore remove the stub functions from gui-stub and gui-beos, change the pretend usage in gui-mui, remove the functions from gui-win32 and replace their usage with simply get_canvas_xy. This last is the only questionable part of the patch AFAICT, but it looks to me like get_canvas_xy is the more appropriate function to use here anyway. It definitely needs testing, though (since I can't even compile win32...).

Please test and review.

jason
? diff
? old
? other_patches
? topology
? data/nation/old
Index: client/gui-beos/mapview.cpp
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-beos/mapview.cpp,v
retrieving revision 1.2
diff -u -r1.2 mapview.cpp
--- client/gui-beos/mapview.cpp 2000/07/04 23:29:39     1.2
+++ client/gui-beos/mapview.cpp 2001/12/13 09:45:37
@@ -7,25 +7,6 @@
 #include "mapview.h"
 
 int
-map_canvas_adjust_x(int x)     // HOOK
-{
-       // @@@@ will probably require some direct accesses
-       NOT_FINISHED( "map_canvas_adjust_x(int" );
-       return 0;
-}
-
-
-int
-map_canvas_adjust_y(int y)     // HOOK
-{
-       // @@@@ will probably require some direct accesses
-       NOT_FINISHED( "map_canvas_adjust_y(int" );
-       return 0;
-}
-
-
-
-int
 tile_visible_mapcanvas(int x, int y)   // HOOK
 {
        // @@@@ will probably require some direct accesses
Index: client/gui-mui/mapclass.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/mapclass.c,v
retrieving revision 1.70
diff -u -r1.70 mapclass.c
--- client/gui-mui/mapclass.c   2001/12/08 15:15:52     1.70
+++ client/gui-mui/mapclass.c   2001/12/13 09:45:39
@@ -1194,7 +1194,7 @@
       {
        /* Draw City Workers */
        APTR cliphandle = MUI_AddClipping(muiRenderInfo(o), _mleft(o), 
_mtop(o), _mwidth(o), _mheight(o));
-       int color;
+       int color, is_real;
        int x,y;
        struct city *pcity = data->worker_pcity;
 
@@ -1206,8 +1206,13 @@
          if (data->worker_colornum == 3) data->worker_colornum = 0;
        }
 
-       x = map_canvas_adjust_x(pcity->x);
-       y = map_canvas_adjust_y(pcity->y);
+       /* This used to use map_canvas_adjust_[xy], but that system is
+          no good.  I've adjusted it to use a manual system instead. */
+       is_real = normalize_map_pos(&pcity->x, &pcity->y);
+       assert(is_real);
+       if (pcity->x < map_view_x0) {
+         pcity->x += map.xsize;
+       }
 
        SetAPen(_rp(o),color);
 
Index: client/gui-stub/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-stub/mapview.c,v
retrieving revision 1.8
diff -u -r1.8 mapview.c
--- client/gui-stub/mapview.c   2001/10/30 12:11:45     1.8
+++ client/gui-stub/mapview.c   2001/12/13 09:45:39
@@ -4,20 +4,6 @@
 
 
 int
-map_canvas_adjust_x(int x)
-{
-       /* PORTME */
-       return 0;
-}
-
-int
-map_canvas_adjust_y(int y)
-{
-       /* PORTME */
-       return 0;
-}
-
-int
 tile_visible_mapcanvas(int x, int y)
 {
        /* PORTME */
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.15
diff -u -r1.15 mapview.c
--- client/gui-win32/mapview.c  2001/12/11 16:16:35     1.15
+++ client/gui-win32/mapview.c  2001/12/13 09:45:40
@@ -411,31 +411,6 @@
 {
   frame = CLIP(0, frame, NUM_TILES_CITIZEN-1);
   return sprites.citizen[frame];
-}           
-
-/**************************************************************************
-
-**************************************************************************/
-int
-map_canvas_adjust_x(int x)
-{
-  if (map_view_x+map_view_width<=map.xsize)
-    return x-map_view_x;
-  else if (x>=map_view_x)
-    return x-map_view_x;
-  else if (x<map_adjust_x(map_view_x+map_view_width))
-    return x+map.xsize-map_view_x;
-  return -1;
-}
-
-
-/**************************************************************************
-
-**************************************************************************/
-int
-map_canvas_adjust_y(int y)
-{
-  return y-map_view_y;
 }
 
 /**************************************************************************
@@ -1232,11 +1207,13 @@
   hdc=GetDC(root_window);
   for(y=0; y<3; y++) {
     for(x=0; x<3; x++) {
-      int map_x = map_canvas_adjust_x(x-1+abs_x0)*NORMAL_TILE_WIDTH;
-      int map_y = map_canvas_adjust_y(y-1+abs_y0)*NORMAL_TILE_HEIGHT;
+      int canvas_x, canvas_y;
       struct Sprite *mysprite = sprites.explode.nuke[y][x];
-      if (mysprite)
-       draw_sprite(mysprite,hdc,map_win_x+map_x,map_win_y+map_y);
+      /* Find the canvas position of the tile to draw, and return
+         if this is not on the screen. */
+      if (mysprite &&
+          get_canvas_xy(abs_x0, abs_y0, &canvas_x, &canvas_y))
+       draw_sprite(mysprite,hdc,canvas_x,canvas_y);
     }
   }
   

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