Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2003:
[Freeciv-Dev] (PR#3437) rename of map_inx
Home

[Freeciv-Dev] (PR#3437) rename of map_inx

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] (PR#3437) rename of map_inx
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 16 Feb 2003 18:46:00 -0800
Reply-to: rt@xxxxxxxxxxxxxx

[jdorje - Sun Feb 16 22:44:49 2003]:

> [jdorje - Sat Feb 15 17:36:49 2003]:
> 
> > We need to rename map_inx.
> > 
> > Two names have been proposed: map_to_index_pos and map_to_index.  Ross 
> > and I can't agree on which to use.
> > 
> > Raimar points out that the 'pos' here is redundant since it is already 
> > implied by the 'index'.  OTOH I often use the term 'index position',
not 
> > just 'index'.
> > 
> > Does anyone else have a preference?  Once this is decided, I'll make a 
> > patch.
> 
> We have an unexpected growth in popularity of map_pos_to_index.  This
> seems fine to me.  Does anyone object to it?

And the patch.

jason


Index: client/goto.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/goto.c,v
retrieving revision 1.46
diff -u -r1.46 goto.c
--- client/goto.c       2003/02/17 02:11:25     1.46
+++ client/goto.c       2003/02/17 02:41:41
@@ -49,9 +49,9 @@
   int src_x, src_y;
 };
 
-#define MOVE_COST(x, y) (goto_map.tiles[map_inx(x, y)].move_cost)
-#define VECTOR(x, y) (goto_map.tiles[map_inx(x, y)].vector)
-#define DRAWN(x, y, dir) (goto_map.tiles[map_inx(x, y)].drawn[(dir)])
+#define MOVE_COST(x, y) (goto_map.tiles[map_pos_to_index(x, y)].move_cost)
+#define VECTOR(x, y) (goto_map.tiles[map_pos_to_index(x, y)].vector)
+#define DRAWN(x, y, dir) (goto_map.tiles[map_pos_to_index(x, y)].drawn[dir])
 
 static void undraw_line(void);
 static unsigned char *get_drawn_char(int x, int y, int dir);
Index: common/game.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.c,v
retrieving revision 1.157
diff -u -r1.157 game.c
--- common/game.c       2003/02/12 22:22:33     1.157
+++ common/game.c       2003/02/17 02:41:41
@@ -151,11 +151,12 @@
        {
          printf (".know (%d)\n  ", p);
          WRITE_MAP_DATA("%c",
-                        TEST_BIT(pcmap->claims[map_inx(x, y)].know,
+                        TEST_BIT(pcmap->claims[map_pos_to_index(x, y)].know,
                                  p) ? 'X' : '-');
          printf (".cities (%d)\n  ", p);
          WRITE_MAP_DATA("%c",
-                        TEST_BIT(pcmap->claims[map_inx(x, y)].cities,
+                        TEST_BIT(pcmap->
+                                 claims[map_pos_to_index(x, y)].cities,
                                  p) ? 'O' : '-');
        }
     }
@@ -163,13 +164,13 @@
   printf ("Turn %d (%c)...\n", turn, when_char (turn));
 
   printf (".whom\n  ");
-  WRITE_MAP_DATA((pcmap->claims[map_inx(x, y)].whom ==
+  WRITE_MAP_DATA((pcmap->claims[map_pos_to_index(x, y)].whom ==
                  32) ? "%c" : "%X",
-                (pcmap->claims[map_inx(x, y)].whom ==
-                 32) ? '-' : pcmap->claims[map_inx(x, y)].whom);
+                (pcmap->claims[map_pos_to_index(x, y)].whom ==
+                 32) ? '-' : pcmap->claims[map_pos_to_index(x, y)].whom);
 
   printf (".when\n  ");
-  WRITE_MAP_DATA("%c", when_char(pcmap->claims[map_inx(x, y)].when));
+  WRITE_MAP_DATA("%c", when_char(pcmap->claims[map_pos_to_index(x, y)].when));
 }
 
 #endif
@@ -206,7 +207,7 @@
   players_iterate(pplayer) {
     city_list_iterate(pplayer->cities, pcity) {
       map_city_radius_iterate(pcity->x, pcity->y, x, y) {
-       int i = map_inx(x, y);
+       int i = map_pos_to_index(x, y);
        pcmap->claims[i].cities |= (1u << pcity->owner);
       } map_city_radius_iterate_end;
     } city_list_iterate_end;
@@ -228,7 +229,7 @@
   nextedge = pcmap->edges;
 
   whole_map_iterate(x, y) {
-    int i = map_inx(x, y);
+    int i = map_pos_to_index(x, y);
     pclaim = &(pcmap->claims[i]);
     ptile = &(map.tiles[i]);
 
@@ -306,12 +307,12 @@
     for (accum = 0; thisedge->x >= 0; thisedge++) {
       x = thisedge->x;
       y = thisedge->y;
-      i = map_inx (x, y);
+      i = map_pos_to_index (x, y);
       owner = pcmap->claims[i].whom;
 
       if (owner != no_owner) {
        adjc_iterate(x, y, mx, my) {
-         j = map_inx(mx, my);
+         j = map_pos_to_index(mx, my);
          pclaim = &(pcmap->claims[j]);
 
          if (TEST_BIT(pclaim->know, owner)) {
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.135
diff -u -r1.135 map.c
--- common/map.c        2003/02/17 02:11:26     1.135
+++ common/map.c        2003/02/17 02:41:42
@@ -66,7 +66,7 @@
   N_("Fallout")
 };
 
-#define MAP_TILE(x,y)  (map.tiles + map_inx(x, y))
+#define MAP_TILE(x,y)  (map.tiles + map_pos_to_index(x, y))
 
 /***************************************************************
 ...
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.136
diff -u -r1.136 map.h
--- common/map.h        2003/02/17 02:11:26     1.136
+++ common/map.h        2003/02/17 02:41:42
@@ -219,8 +219,9 @@
 #define map_adjust_y(Y) \
   (((Y)<0) ? 0 : (((Y)>=map.ysize) ? map.ysize-1 : (Y)))
 
-#define map_inx(x,y) \
-  (CHECK_MAP_POS((x),(y)), (x)+(y)*map.xsize)
+#define map_pos_to_index(map_x, map_y)        \
+  (CHECK_MAP_POS((map_x), (map_y)),           \
+   (map_x) + (map_y) * map.xsize)
 
 #define DIRSTEP(dest_x, dest_y, dir)   \
 (    (dest_x) = DIR_DX[(dir)],         \
Index: server/gotohand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gotohand.c,v
retrieving revision 1.165
diff -u -r1.165 gotohand.c
--- server/gotohand.c   2003/02/10 21:43:42     1.165
+++ server/gotohand.c   2003/02/17 02:41:44
@@ -777,14 +777,14 @@
 
       /* Add the route to our warmap if it is worth keeping */
       if (total_cost < maxcost) {
-       if (warmap_cost[map_inx(x1, y1)] > total_cost) {
-         warmap_cost[map_inx(x1, y1)] = total_cost;
+       if (warmap_cost[map_pos_to_index(x1, y1)] > total_cost) {
+         warmap_cost[map_pos_to_index(x1, y1)] = total_cost;
          add_to_mapqueue(total_cost, x1, y1);
          local_vector[x1][y1] = 1 << DIR_REVERSE(dir);
          freelog(LOG_DEBUG,
                  "Candidate: %s from (%d, %d) to (%d, %d), cost %d",
                  dir_get_name(dir), x, y, x1, y1, total_cost);
-       } else if (warmap_cost[map_inx(x1, y1)] == total_cost) {
+       } else if (warmap_cost[map_pos_to_index(x1, y1)] == total_cost) {
          local_vector[x1][y1] |= 1 << DIR_REVERSE(dir);
          freelog(LOG_DEBUG,
                  "Co-Candidate: %s from (%d, %d) to (%d, %d), cost %d",
Index: server/gotohand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gotohand.h,v
retrieving revision 1.24
diff -u -r1.24 gotohand.h
--- server/gotohand.h   2003/02/10 19:30:53     1.24
+++ server/gotohand.h   2003/02/17 02:41:44
@@ -57,8 +57,8 @@
 
 extern struct move_cost_map warmap;
 
-#define WARMAP_COST(x, y) (warmap.cost[map_inx((x), (y))])
-#define WARMAP_SEACOST(x, y) (warmap.seacost[map_inx((x), (y))])
-#define WARMAP_VECTOR(x, y) (warmap.vector[map_inx((x), (y))])
+#define WARMAP_COST(x, y) (warmap.cost[map_pos_to_index(x, y)])
+#define WARMAP_SEACOST(x, y) (warmap.seacost[map_pos_to_index(x, y)])
+#define WARMAP_VECTOR(x, y) (warmap.vector[map_pos_to_index(x, y)])
 
 #endif  /* FC__GOTOHAND_H */
Index: server/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v
retrieving revision 1.108
diff -u -r1.108 mapgen.c
--- server/mapgen.c     2003/02/12 22:22:34     1.108
+++ server/mapgen.c     2003/02/17 02:41:46
@@ -32,8 +32,8 @@
 #include "mapgen.h"
 
 /* Wrapper for easy access.  It's a macro so it can be a lvalue. */
-#define hmap(x, y) (height_map[map_inx(x, y)])
-#define rmap(x, y) (river_map[map_inx(x, y)])
+#define hmap(x, y) (height_map[map_pos_to_index(x, y)])
+#define rmap(x, y) (river_map[map_pos_to_index(x, y)])
 
 static void make_huts(int number);
 static void add_specials(int prob);
@@ -1329,7 +1329,7 @@
 
     if (height_sum < 0)
       height_sum = 0;
-    new_hmap[map_inx(x, y)] = height_sum / counter;
+    new_hmap[map_pos_to_index(x, y)] = height_sum / counter;
   } whole_map_iterate_end;
 
   memcpy(height_map, new_hmap, sizeof(int) * map.xsize * map.ysize);
Index: server/maphand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/maphand.c,v
retrieving revision 1.117
diff -u -r1.117 maphand.c
--- server/maphand.c    2003/02/12 22:22:34     1.117
+++ server/maphand.c    2003/02/17 02:41:46
@@ -805,7 +805,7 @@
 ***************************************************************/
 bool map_get_known_and_seen(int x, int y, struct player *pplayer)
 {
-  int offset = map_inx(x, y);
+  int offset = map_pos_to_index(x, y);
 
   return TEST_BIT((map.tiles + offset)->known, pplayer->player_no)
       && ((pplayer->private_map + offset)->seen != 0);
@@ -996,7 +996,7 @@
 ***************************************************************/
 struct player_tile *map_get_player_tile(int x, int y, struct player *pplayer)
 {
-  return pplayer->private_map + map_inx(x, y);
+  return pplayer->private_map + map_pos_to_index(x, y);
 }
 
 /***************************************************************

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