Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2003:
[Freeciv-Dev] (PR#3576) remove get_mapview_dimensions
Home

[Freeciv-Dev] (PR#3576) remove get_mapview_dimensions

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#3576) remove get_mapview_dimensions
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 2 Mar 2003 02:15:35 -0800
Reply-to: rt@xxxxxxxxxxxxxx

[I thought I sent this patch before, but I guess not.  Oops...]

As promised, this patch removes get_mapview_dimensions.  This function
was useful for a while, but is no longer needed because all of this
information is stored directly in the mapview_canvas struct.

jason

Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.35
diff -u -r1.35 mapview_common.c
--- client/mapview_common.c     2003/03/01 21:03:55     1.35
+++ client/mapview_common.c     2003/03/02 10:11:43
@@ -306,13 +306,9 @@
 **************************************************************************/
 bool get_canvas_xy(int map_x, int map_y, int *canvas_x, int *canvas_y)
 {
-  int map_view_x0, map_view_y0, map_win_width, map_win_height;
-
-  get_mapview_dimensions(&map_view_x0, &map_view_y0,
-                        &map_win_width, &map_win_height);
   return map_pos_to_canvas_pos(map_x, map_y, canvas_x, canvas_y,
-                              map_view_x0, map_view_y0,
-                              map_win_width, map_win_height);
+                              mapview_canvas.map_x0, mapview_canvas.map_y0,
+                              mapview_canvas.width, mapview_canvas.height);
 }
 
 /**************************************************************************
@@ -320,12 +316,8 @@
 **************************************************************************/
 void get_map_xy(int canvas_x, int canvas_y, int *map_x, int *map_y)
 {
-  int map_view_x0, map_view_y0, map_win_width, map_win_height;
-
-  get_mapview_dimensions(&map_view_x0, &map_view_y0,
-                        &map_win_width, &map_win_height);
   canvas_pos_to_map_pos(canvas_x, canvas_y, map_x, map_y,
-                       map_view_x0, map_view_y0);
+                       mapview_canvas.map_x0, mapview_canvas.map_y0);
 }
 
 /**************************************************************************
@@ -333,13 +325,9 @@
 **************************************************************************/
 void get_center_tile_mapcanvas(int *map_x, int *map_y)
 {
-  int map_view_x0, map_view_y0, map_win_width, map_win_height;
-
-  get_mapview_dimensions(&map_view_x0, &map_view_y0,
-                        &map_win_width, &map_win_height);
-
   /* This sets the pointers map_x and map_y */
-  get_map_xy(map_win_width / 2, map_win_height / 2, map_x, map_y);
+  get_map_xy(mapview_canvas.width / 2, mapview_canvas.height / 2,
+            map_x, map_y);
 }
 
 /**************************************************************************
@@ -401,14 +389,6 @@
 **************************************************************************/
 bool tile_visible_and_not_on_border_mapcanvas(int map_x, int map_y)
 {
-  int map_view_x0, map_view_y0, map_win_width, map_win_height;
-  int map_tile_width, map_tile_height;
-
-  get_mapview_dimensions(&map_view_x0, &map_view_y0,
-                        &map_win_width, &map_win_height);
-  map_tile_width = (map_win_width - 1) / NORMAL_TILE_WIDTH + 1;
-  map_tile_height = (map_win_height - 1) / NORMAL_TILE_HEIGHT + 1;
-
   if (is_isometric) {
     int canvas_x, canvas_y;
 
@@ -416,23 +396,23 @@
      * screen, and the 1.5-tiles on the right and bottom. */
     return (get_canvas_xy(map_x, map_y, &canvas_x, &canvas_y)
            && canvas_x > NORMAL_TILE_WIDTH / 2
-           && canvas_x < map_win_width - 3 * NORMAL_TILE_WIDTH / 2
+           && canvas_x < mapview_canvas.width - 3 * NORMAL_TILE_WIDTH / 2
            && canvas_y >= NORMAL_TILE_HEIGHT
-           && canvas_y < map_win_height - 3 * NORMAL_TILE_HEIGHT / 2);
+           && canvas_y < mapview_canvas.height - 3 * NORMAL_TILE_HEIGHT / 2);
   } else {
+    int x0 = mapview_canvas.map_x0, y0 = mapview_canvas.map_y0;
+    int twidth = mapview_canvas.tile_width;
+    int theight = mapview_canvas.tile_height;
+
     /* The border consists of the two tiles on the edge of the
      * mapview.  But we take into account the border of the map. */
-    return ((map_y >= map_view_y0 + 2 || (map_y >= map_view_y0
-                                         && map_view_y0 == 0))
-           && (map_y < map_view_y0 + map_tile_height - 2
-               || (map_y < map_view_y0 + map_tile_height
-                   && (map_view_y0 + map_tile_height
-                       - EXTRA_BOTTOM_ROW == map.ysize)))
-           && ((map_x >= map_view_x0 + 2
-                && map_x < map_view_x0 + map_tile_width - 2)
-               || (map_x + map.xsize >= map_view_x0 + 2
-                   && (map_x + map.xsize
-                       < map_view_x0 + map_tile_width - 2))));
+    return ((map_y > y0 + 2 || (map_y >= y0 && y0 == 0))
+           && (map_y < y0 + theight - 2
+               || (map_y < y0 + theight
+                   && (y0 + theight - EXTRA_BOTTOM_ROW == map.ysize)))
+           && ((map_x >= x0 + 2 && map_x < x0 + twidth - 2)
+               || (map_x + map.xsize >= x0 + 2
+                   && (map_x + map.xsize < x0 + twidth - 2))));
   }
 }
 
@@ -763,30 +743,24 @@
 **************************************************************************/
 void update_map_canvas_visible(void)
 {
-  int map_view_x0, map_view_y0, map_win_width, map_win_height;
-  int map_tile_width, map_tile_height;
-
-  get_mapview_dimensions(&map_view_x0, &map_view_y0,
-                        &map_win_width, &map_win_height);
-  map_tile_width = (map_win_width - 1) / NORMAL_TILE_WIDTH + 1;
-  map_tile_height = (map_win_height - 1) / NORMAL_TILE_HEIGHT + 1;
-
   if (is_isometric) {
     /* just find a big rectangle that includes the whole visible area. The
        invisible tiles will not be drawn. */
     int width, height;
 
-    width = height = map_tile_width + map_tile_height;
-    update_map_canvas(map_view_x0, map_view_y0 - map_tile_width, width,
-                     height, FALSE);
+    width = height = mapview_canvas.tile_width + mapview_canvas.tile_height;
+    update_map_canvas(mapview_canvas.map_x0,
+                     mapview_canvas.map_y0 - mapview_canvas.tile_width,
+                     width, height, FALSE);
   } else {
-    update_map_canvas(map_view_x0, map_view_y0, map_tile_width,
-                     map_tile_height, FALSE);
+    update_map_canvas(mapview_canvas.map_x0, mapview_canvas.map_y0,
+                     mapview_canvas.tile_width, mapview_canvas.tile_height,
+                     FALSE);
   }
 
   show_city_descriptions();
 
-  flush_mapcanvas(0, 0, map_win_width, map_win_height);
+  flush_mapcanvas(0, 0, mapview_canvas.width, mapview_canvas.height);
 }
 
 /**************************************************************************
@@ -794,8 +768,6 @@
 **************************************************************************/
 void show_city_descriptions(void)
 {
-  int map_view_x0, map_view_y0, map_win_width, map_win_height;
-  int map_tile_width, map_tile_height;
   int canvas_x, canvas_y;
 
   if (!draw_city_names && !draw_city_productions) {
@@ -804,19 +776,14 @@
 
   prepare_show_city_descriptions();
 
-  get_mapview_dimensions(&map_view_x0, &map_view_y0, &map_win_width,
-                        &map_win_height);
-  map_tile_width = (map_win_width - 1) / NORMAL_TILE_WIDTH + 1;
-  map_tile_height = (map_win_height - 1) / NORMAL_TILE_HEIGHT + 1;
-
   if (is_isometric) {
     int w, h;
 
-    for (h = -1; h < map_tile_height * 2; h++) {
-      int x_base = map_view_x0 + h / 2 + (h != -1 ? h % 2 : 0);
-      int y_base = map_view_y0 + h / 2 + (h == -1 ? -1 : 0);
+    for (h = -1; h < mapview_canvas.tile_height * 2; h++) {
+      int x_base = mapview_canvas.map_x0 + h / 2 + (h != -1 ? h % 2 : 0);
+      int y_base = mapview_canvas.map_y0 + h / 2 + (h == -1 ? -1 : 0);
 
-      for (w = 0; w <= map_tile_width; w++) {
+      for (w = 0; w <= mapview_canvas.tile_width; w++) {
        int x = x_base + w;
        int y = y_base - w;
        struct city *pcity;
@@ -831,10 +798,10 @@
   } else {                     /* is_isometric */
     int x1, y1;
 
-    for (x1 = 0; x1 < map_tile_width; x1++) {
-      for (y1 = 0; y1 < map_tile_height; y1++) {
-       int x = map_view_x0 + x1;
-       int y = map_view_y0 + y1;
+    for (x1 = 0; x1 < mapview_canvas.tile_width; x1++) {
+      for (y1 = 0; y1 < mapview_canvas.tile_height; y1++) {
+       int x = mapview_canvas.map_x0 + x1;
+       int y = mapview_canvas.map_y0 + y1;
        struct city *pcity;
 
        if (normalize_map_pos(&x, &y)
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.162
diff -u -r1.162 mapview.c
--- client/gui-gtk/mapview.c    2003/03/01 21:03:55     1.162
+++ client/gui-gtk/mapview.c    2003/03/02 10:11:44
@@ -90,22 +90,6 @@
 static GtkObject *map_hadj, *map_vadj;
 
 
-/***********************************************************************
-  This function can be used by mapview_common code to determine the
-  location and dimensions of the mapview canvas.
-***********************************************************************/
-void get_mapview_dimensions(int *map_view_topleft_map_x,
-                           int *map_view_topleft_map_y,
-                           int *map_view_pixel_width,
-                           int *map_view_pixel_height)
-{
-  *map_view_topleft_map_x = map_view_x0;
-  *map_view_topleft_map_y = map_view_y0;
-  gdk_window_get_size(map_canvas->window,
-                     map_view_pixel_width,
-                     map_view_pixel_height);
-}
-
 /**************************************************************************
  This function is called to decrease a unit's HP smoothly in battle
  when combat_animation is turned on.
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.50
diff -u -r1.50 mapview.c
--- client/gui-gtk-2.0/mapview.c        2003/03/01 21:03:56     1.50
+++ client/gui-gtk-2.0/mapview.c        2003/03/02 10:11:45
@@ -91,21 +91,6 @@
 static GtkObject *map_hadj, *map_vadj;
 
 
-/***********************************************************************
-  This function can be used by mapview_common code to determine the
-  location and dimensions of the mapview canvas.
-***********************************************************************/
-void get_mapview_dimensions(int *map_view_topleft_map_x,
-                           int *map_view_topleft_map_y,
-                           int *map_view_pixel_width,
-                           int *map_view_pixel_height)
-{
-  *map_view_topleft_map_x = map_view_x0;
-  *map_view_topleft_map_y = map_view_y0;
-  gdk_window_get_size(map_canvas->window,
-                     map_view_pixel_width, map_view_pixel_height);
-}
-
 /**************************************************************************
  This function is called to decrease a unit's HP smoothly in battle
  when combat_animation is turned on.
Index: client/gui-mui/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/mapview.c,v
retrieving revision 1.59
diff -u -r1.59 mapview.c
--- client/gui-mui/mapview.c    2003/03/01 21:03:56     1.59
+++ client/gui-mui/mapview.c    2003/03/02 10:11:46
@@ -79,21 +79,6 @@
   return xget(main_map_area, MUIA_Map_VertVisible);
 }
 
-/***********************************************************************
-  This function can be used by mapview_common code to determine the
-  location and dimensions of the mapview canvas.
-***********************************************************************/
-void get_mapview_dimensions(int *map_view_topleft_map_x,
-                           int *map_view_topleft_map_y,
-                           int *map_view_pixel_width,
-                           int *map_view_pixel_height)
-{
-  *map_view_topleft_map_x = xget(main_map_area, MUIA_Map_HorizFirst);
-  *map_view_topleft_map_y = xget(main_map_area, MUIA_Map_VertFirst);
-  *map_view_pixel_width = _mwidth(main_map_area);      /* !! */
-  *map_view_pixel_height = _mheight(main_map_area);    /* !! */
-}
-
 /**************************************************************************
  This function is called to decrease a unit's HP smoothly in battle
  when combat_animation is turned on.
Index: client/gui-sdl/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/mapview.c,v
retrieving revision 1.35
diff -u -r1.35 mapview.c
--- client/gui-sdl/mapview.c    2003/03/01 21:03:56     1.35
+++ client/gui-sdl/mapview.c    2003/03/02 10:11:47
@@ -111,22 +111,6 @@
 /* ================================================================ */
 
 
-
-/**************************************************************************
-  This function can be used by mapview_common code to determine the
-  location and dimensions of the mapview canvas.
-**************************************************************************/
-void get_mapview_dimensions(int *map_view_topleft_map_x,
-                           int *map_view_topleft_map_y,
-                           int *map_view_pixel_width,
-                           int *map_view_pixel_height)
-{
-  *map_view_topleft_map_x = map_view_x0;
-  *map_view_topleft_map_y = map_view_y0;
-  *map_view_pixel_width = Main.screen->w;
-  *map_view_pixel_height = Main.screen->h;
-}
-
 /**************************************************************************
   Draw some or all of a tile onto the mapview canvas.
 **************************************************************************/
Index: client/gui-stub/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-stub/mapview.c,v
retrieving revision 1.30
diff -u -r1.30 mapview.c
--- client/gui-stub/mapview.c   2003/03/01 21:03:56     1.30
+++ client/gui-stub/mapview.c   2003/03/02 10:11:47
@@ -27,26 +27,6 @@
 #include "mapctrl.h"
 #include "mapview.h"
 
-/* Mapview dimensions. */
-int map_view_x0, map_view_y0;
-int canvas_width, canvas_height;
-int mapview_tile_width, mapview_tile_height;
-
-/**************************************************************************
-  This function can be used by mapview_common code to determine the
-  location and dimensions of the mapview canvas.
-**************************************************************************/
-void get_mapview_dimensions(int *map_view_topleft_map_x,
-                           int *map_view_topleft_map_y,
-                           int *map_view_pixel_width,
-                           int *map_view_pixel_height)
-{
-  /* PORTME */
-  *map_view_topleft_map_x = map_view_x0;
-  *map_view_topleft_map_y = map_view_y0;
-  *map_view_pixel_width = canvas_width;
-  *map_view_pixel_height = canvas_height;
-}
 
 /**************************************************************************
   Typically an info box is provided to tell the player about the state
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.62
diff -u -r1.62 mapview.c
--- client/gui-win32/mapview.c  2003/03/01 21:03:56     1.62
+++ client/gui-win32/mapview.c  2003/03/02 10:11:48
@@ -83,20 +83,6 @@
                     int dir, bool write_to_screen);
 static void draw_rates(HDC hdc);
 
-/***********************************************************************
-  This function can be used by mapview_common code to determine the
-  location and dimensions of the mapview canvas.
-***********************************************************************/
-void get_mapview_dimensions(int *map_view_topleft_map_x,
-                           int *map_view_topleft_map_y,
-                           int *map_view_pixel_width,
-                           int *map_view_pixel_height)
-{
-  *map_view_topleft_map_x = map_view_x;
-  *map_view_topleft_map_y = map_view_y;
-  *map_view_pixel_width = map_win_width;
-  *map_view_pixel_height = map_win_height;
-}
 
 /**************************************************************************
 
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.129
diff -u -r1.129 mapview.c
--- client/gui-xaw/mapview.c    2003/03/01 21:03:56     1.129
+++ client/gui-xaw/mapview.c    2003/03/02 10:11:48
@@ -62,25 +62,6 @@
 int scaled_intro_pixmap_width, scaled_intro_pixmap_height;
 
 
-/***********************************************************************
-  This function can be used by mapview_common code to determine the
-  location and dimensions of the mapview canvas.
-***********************************************************************/
-void get_mapview_dimensions(int *map_view_topleft_map_x,
-                           int *map_view_topleft_map_y,
-                           int *map_view_pixel_width,
-                           int *map_view_pixel_height)
-{
-  Dimension width, height;
-
-  *map_view_topleft_map_x = map_view_x0;
-  *map_view_topleft_map_y = map_view_y0;
-  XtVaGetValues(map_canvas, XtNwidth, &width, XtNheight, &height, NULL);
-
-  *map_view_pixel_width = (Dimension)width;
-  *map_view_pixel_height = (Dimension)height;
-}
-
 /**************************************************************************
  This function is called to decrease a unit's HP smoothly in battle
  when combat_animation is turned on.
Index: client/include/mapview_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/mapview_g.h,v
retrieving revision 1.35
diff -u -r1.35 mapview_g.h
--- client/include/mapview_g.h  2003/03/01 21:03:57     1.35
+++ client/include/mapview_g.h  2003/03/02 10:11:49
@@ -19,11 +19,6 @@
 struct unit;
 struct city;
 
-void get_mapview_dimensions(int *map_view_topleft_map_x,
-                           int *map_view_topleft_map_y,
-                           int *map_view_pixel_width,
-                           int *map_view_pixel_height);
-
 void update_info_label(void);
 void update_unit_info_label(struct unit *punit);
 void update_timeout_label(void);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#3576) remove get_mapview_dimensions, Jason Short <=