Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2003:
[Freeciv-Dev] Re: is_real_tile -> is_real_map_pos (PR#1227)
Home

[Freeciv-Dev] Re: is_real_tile -> is_real_map_pos (PR#1227)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: is_real_tile -> is_real_map_pos (PR#1227)
From: "Raimar Falke" <rf13@xxxxxxxxxxxxxxxxx>
Date: Sat, 15 Feb 2003 09:23:51 -0800
Reply-to: rt@xxxxxxxxxxxxxx

On Sat, Jan 12, 2002 at 07:21:54PM -0800, jdorje@xxxxxxxxxxxxxxxxxxxxx wrote:
> Ross W. Wetmore wrote:
> 
> >This should not be just a rename, but fix the definition and use as well.
> 
> Many/most of the uses need fixing, but I'm not sure if this should all 
> be done in the same patch.  For one thing some of the implementations 
> are disagreed on.
> 
> In reality, most of the "fixes" here can just get rid of the 
> is_real_map_pos check entirely.  Some can be replaced with 
> CHECK_MAP_POS, some with normalize_map_pos, and some just removed.  But 
> there will be no agreement on how to do this, so I'll leave it be for now.

And the patch.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  "With a PC, I always felt limited by the software available.
   On Unix, I am limited by my knowledge."
    -- Peter J. Schoenster <pschon@xxxxxxxxxxxxxxxxx>

Index: client/goto.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/goto.c,v
retrieving revision 1.45
diff -u -u -r1.45 goto.c
--- client/goto.c       2003/02/13 17:03:55     1.45
+++ client/goto.c       2003/02/15 17:13:51
@@ -664,7 +664,7 @@
   bool is_real;
 
   /* Replace with check for is_normal_tile later */  
-  assert(is_real_tile(x, y));
+  assert(is_real_map_pos(x, y));
   normalize_map_pos(&x, &y);
 
   is_real = MAPSTEP(x1, y1, x, y, dir);
@@ -824,7 +824,7 @@
   assert(is_active);
 
   /* Replace with check for is_normal_tile later */
-  assert(is_real_tile(dest_x, dest_y));
+  assert(is_real_map_pos(dest_x, dest_y));
   normalize_map_pos(&dest_x, &dest_y);
 
   if (VECTOR(dest_x, dest_y) == 0) {
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.29
diff -u -u -r1.29 mapview_common.c
--- client/mapview_common.c     2003/02/08 22:52:45     1.29
+++ client/mapview_common.c     2003/02/15 17:13:53
@@ -34,7 +34,7 @@
 **************************************************************************/
 void refresh_tile_mapcanvas(int x, int y, bool write_to_screen)
 {
-  assert(is_real_tile(x, y));
+  assert(is_real_map_pos(x, y));
   if (!normalize_map_pos(&x, &y)) {
     return;
   }
@@ -111,9 +111,9 @@
       player_in_city_radius(game.player_ptr, x1, y1);
   bool pos2_is_in_city_radius = FALSE;
 
-  assert(is_real_tile(x1, y1));
+  assert(is_real_map_pos(x1, y1));
 
-  if (is_real_tile(x2, y2)) {
+  if (is_real_map_pos(x2, y2)) {
     normalize_map_pos(&x2, &y2);
     assert(is_tiles_adjacent(x1, y1, x2, y2));
 
Index: client/gui-gtk/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/dialogs.c,v
retrieving revision 1.122
diff -u -u -r1.122 dialogs.c
--- client/gui-gtk/dialogs.c    2003/02/12 22:49:51     1.122
+++ client/gui-gtk/dialogs.c    2003/02/15 17:13:58
@@ -349,7 +349,7 @@
   GtkWidget *notify_dialog_shell, *notify_command, *notify_goto_command;
   GtkWidget *notify_label;
   
-  if (!is_real_tile(x, y)) {
+  if (!is_normal_map_pos(x, y)) {
     popup_notify_dialog(_("Message:"), headline, lines);
     return;
   }
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.155
diff -u -u -r1.155 mapview.c
--- client/gui-gtk/mapview.c    2003/02/08 22:52:46     1.155
+++ client/gui-gtk/mapview.c    2003/02/15 17:14:02
@@ -195,7 +195,7 @@
 
   if (!citymode) {
     /* put any goto lines on the tile. */
-    if (is_real_tile(x, y)) {
+    if (is_real_map_pos(x, y)) {
       int dir;
       for (dir = 0; dir < 8; dir++) {
        if (get_drawn(x, y, dir)) {
@@ -1610,7 +1610,7 @@
   }
 
   /* Replace with check for is_normal_tile later */
-  assert(is_real_tile(x, y));
+  assert(is_real_map_pos(x, y));
   normalize_map_pos(&x, &y);
 
   fog = tile_get_known(x, y) == TILE_KNOWN_FOGGED && draw_fog_of_war;
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.43
diff -u -u -r1.43 mapview.c
--- client/gui-gtk-2.0/mapview.c        2003/02/08 22:52:46     1.43
+++ client/gui-gtk-2.0/mapview.c        2003/02/15 17:14:06
@@ -194,7 +194,7 @@
 
   if (!citymode) {
     /* put any goto lines on the tile. */
-    if (is_real_tile(x, y)) {
+    if (is_real_map_pos(x, y)) {
       int dir;
       for (dir = 0; dir < 8; dir++) {
        if (get_drawn(x, y, dir)) {
@@ -1683,7 +1683,7 @@
   }
 
   /* Replace with check for is_normal_tile later */
-  assert(is_real_tile(x, y));
+  assert(is_real_map_pos(x, y));
   normalize_map_pos(&x, &y);
 
   fog = tile_get_known(x, y) == TILE_KNOWN_FOGGED && draw_fog_of_war;
Index: client/gui-mui/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/graphics.c,v
retrieving revision 1.31
diff -u -u -r1.31 graphics.c
--- client/gui-mui/graphics.c   2003/02/02 00:15:52     1.31
+++ client/gui-mui/graphics.c   2003/02/15 17:14:09
@@ -970,7 +970,7 @@
 
   if (!citymode) {
     /* put any goto lines on the tile. */
-    if (is_real_tile(x, y)) {
+    if (is_real_map_pos(x, y)) {
       int dir;
       for (dir = 0; dir < 8; dir++) {
        if (get_drawn(x, y, dir)) {
@@ -1239,7 +1239,7 @@
     return;
   }
 
-  assert(is_real_tile(x, y));
+  assert(is_real_map_pos(x, y));
   normalize_map_pos(&x, &y);
   fog = tile_get_known(x, y) == TILE_KNOWN_FOGGED && draw_fog_of_war;
   pcity = map_get_city(x, y);
Index: client/gui-sdl/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/mapview.c,v
retrieving revision 1.20
diff -u -u -r1.20 mapview.c
--- client/gui-sdl/mapview.c    2003/02/10 21:43:41     1.20
+++ client/gui-sdl/mapview.c    2003/02/15 17:14:13
@@ -1436,7 +1436,7 @@
   
 #if 0
   /* Replace with check for is_normal_tile later */
-  assert(is_real_tile(map_col, map_row));
+  assert(is_real_map_pos(map_col, map_row));
 #endif
   
   /* normalize_map_pos(&map_col, &map_wier); */
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.55
diff -u -u -r1.55 mapview.c
--- client/gui-win32/mapview.c  2003/02/08 22:52:46     1.55
+++ client/gui-win32/mapview.c  2003/02/15 17:14:20
@@ -358,7 +358,7 @@
 
   if (!citymode) {
     /* put any goto lines on the tile. */
-    if (is_real_tile(x, y)) {
+    if (is_real_map_pos(x, y)) {
       int dir;
       for (dir = 0; dir < 8; dir++) {
         if (get_drawn(x, y, dir)) {
Index: client/gui-xaw/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/dialogs.c,v
retrieving revision 1.80
diff -u -u -r1.80 dialogs.c
--- client/gui-xaw/dialogs.c    2003/02/12 22:49:52     1.80
+++ client/gui-xaw/dialogs.c    2003/02/15 17:14:22
@@ -345,7 +345,7 @@
   Widget notify_headline, notify_label;
   Dimension width, width2, width_1, width_2;
   
-  if (!is_real_tile(x, y)) {
+  if (!is_normal_map_pos(x, y)) {
     popup_notify_dialog("Message:", headline, lines);
     return;
   }
Index: client/gui-xaw/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/mapview.c,v
retrieving revision 1.122
diff -u -u -r1.122 mapview.c
--- client/gui-xaw/mapview.c    2003/02/08 22:52:46     1.122
+++ client/gui-xaw/mapview.c    2003/02/15 17:14:24
@@ -979,7 +979,7 @@
 
   if (!citymode) {
     /* put any goto lines on the tile. */
-    if (is_real_tile(x, y)) {
+    if (is_real_map_pos(x, y)) {
       int dir;
       for (dir = 0; dir < 8; dir++) {
        if (get_drawn(x, y, dir)) {
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.183
diff -u -u -r1.183 city.c
--- common/city.c       2003/02/12 22:22:33     1.183
+++ common/city.c       2003/02/15 17:14:29
@@ -106,7 +106,7 @@
                                 int city_center_x, int city_center_y,
                                 int map_x, int map_y)
 {
-  assert(is_real_tile(map_x, map_y));
+  CHECK_MAP_POS(map_x, map_y);
   city_map_checked_iterate(city_center_x, city_center_y, cx, cy, mx, my) {
     if (mx == map_x && my == map_y) {
       *city_map_x = cx;
@@ -2313,7 +2313,7 @@
                                *result_city_tile_type,
                                struct city **result_pcity)
 {
-  assert(is_real_tile(map_x, map_y));
+  CHECK_MAP_POS(map_x, map_y);
 
   *result_pcity = map_get_tile(map_x, map_y)->worked;
   if (*result_pcity) {
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.134
diff -u -u -r1.134 map.c
--- common/map.c        2003/02/10 21:43:41     1.134
+++ common/map.c        2003/02/15 17:14:32
@@ -1050,7 +1050,7 @@
 static int tile_move_cost_ai(struct tile *tile0, struct tile *tile1,
                             int x, int y, int x1, int y1, int maxcost)
 {
-  assert(is_real_tile(x, y));
+  CHECK_MAP_POS(x, y);
   assert(!is_server
         || (tile0->terrain != T_UNKNOWN && tile1->terrain != T_UNKNOWN));
 
@@ -1295,7 +1295,7 @@
   return (x1 == x2 && y1 == y2);
 }
 
-bool is_real_tile(int x, int y)
+bool is_real_map_pos(int x, int y)
 {
   return normalize_map_pos(&x, &y);
 }
@@ -1397,7 +1397,7 @@
     DIR8_SOUTHWEST, DIR8_SOUTH, DIR8_SOUTHEAST
   };
 
-  assert(is_real_tile(x0, y0));
+  CHECK_MAP_POS(x0, y0);
 
   /* This clever loop by Trent Piepho will take no more than
    * 8 tries to find a valid direction. */
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.135
diff -u -u -r1.135 map.h
--- common/map.h        2003/02/10 21:43:41     1.135
+++ common/map.h        2003/02/15 17:14:34
@@ -247,7 +247,7 @@
 void map_set_terrain(int x, int y, enum tile_terrain_type ter);
 void map_set_special(int x, int y, enum tile_special_type spe);
 void map_clear_special(int x, int y, enum tile_special_type spe);
-bool is_real_tile(int x, int y);
+bool is_real_map_pos(int x, int y);
 bool is_normal_map_pos(int x, int y);
 
 /* special testing */
Index: server/barbarian.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/barbarian.c,v
retrieving revision 1.59
diff -u -u -r1.59 barbarian.c
--- server/barbarian.c  2003/01/09 02:36:37     1.59
+++ server/barbarian.c  2003/02/15 17:14:41
@@ -154,7 +154,7 @@
 **************************************************************************/
 static bool is_free_land(int x, int y, struct player *who)
 {
-  return (is_real_tile(x, y) && !is_ocean(map_get_terrain(x, y))
+  return (!is_ocean(map_get_terrain(x, y))
          && !is_non_allied_unit_tile(map_get_tile(x, y), who));
 }
 
@@ -163,7 +163,7 @@
 **************************************************************************/
 static bool is_free_sea(int x, int y, struct player *who)
 {
-  return (is_real_tile(x, y) && is_ocean(map_get_terrain(x, y))
+  return (is_ocean(map_get_terrain(x, y))
          && !is_non_allied_unit_tile(map_get_tile(x, y), who));
 }
 
Index: server/gamehand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gamehand.c,v
retrieving revision 1.122
diff -u -u -r1.122 gamehand.c
--- server/gamehand.c   2003/02/10 21:43:42     1.122
+++ server/gamehand.c   2003/02/15 17:14:42
@@ -119,15 +119,17 @@
        dx = x;
        dy = y;
       } else {
+       bool is_real;
+
        do {
          dx = x + myrand(2 * game.dispersion + 1) - game.dispersion;
          dy = y + myrand(2 * game.dispersion + 1) - game.dispersion;
-         (void) normalize_map_pos(&dx, &dy);
-       } while (!(is_real_tile(dx, dy)
-                   && map_get_continent(x, y) == map_get_continent(dx, dy)
-                   && !is_ocean(map_get_terrain(dx, dy))
-                   && !is_non_allied_unit_tile(map_get_tile(dx, dy),
-                                              get_player(i))));
+         is_real = normalize_map_pos(&dx, &dy);
+       } while (!(is_real
+                  && map_get_continent(x, y) == map_get_continent(dx, dy)
+                  && !is_ocean(map_get_terrain(dx, dy))
+                  && !is_non_allied_unit_tile(map_get_tile(dx, dy),
+                                              get_player(i))));
       }
       /* For scenarios or dispersion, huts may coincide with player
         starts (in other cases, huts are avoided as start positions).
Index: server/sanitycheck.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/sanitycheck.c,v
retrieving revision 1.27
diff -u -u -r1.27 sanitycheck.c
--- server/sanitycheck.c        2003/02/10 21:43:42     1.27
+++ server/sanitycheck.c        2003/02/15 17:14:42
@@ -219,7 +219,7 @@
       struct city *pcity;
 
       assert(unit_owner(punit) == pplayer);
-      assert(is_real_tile(x, y));
+      CHECK_MAP_POS(x, y);
 
       if (punit->homecity != 0) {
        pcity = player_find_city_by_id(pplayer, punit->homecity);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: is_real_tile -> is_real_map_pos (PR#1227), Raimar Falke <=