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: Mon, 17 Feb 2003 15:46:37 -0800
Reply-to: rt@xxxxxxxxxxxxxx

[jdorje - Mon Feb 17 02:45:59 2003]:


> > 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.

Updated patch attached.

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 23:44:27
@@ -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 23:44:27
@@ -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 23:44:28
@@ -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.138
diff -u -r1.138 map.h
--- common/map.h        2003/02/17 12:54:23     1.138
+++ common/map.h        2003/02/17 23:44:28
@@ -224,10 +224,11 @@
 #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)
 
-/* index_to_map_pos(int *, int *, int) inverts map_inx */
+/* index_to_map_pos(int *, int *, int) inverts map_pos_to_index */
 #define index_to_map_pos(pmap_x, pmap_y, index) \
   (CHECK_INDEX(index),                          \
    *(pmap_x) = (index) % map.xsize,             \
Index: server/gotohand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gotohand.c,v
retrieving revision 1.167
diff -u -r1.167 gotohand.c
--- server/gotohand.c   2003/02/17 22:49:28     1.167
+++ server/gotohand.c   2003/02/17 23:44:30
@@ -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.26
diff -u -r1.26 gotohand.h
--- server/gotohand.h   2003/02/17 22:49:28     1.26
+++ server/gotohand.h   2003/02/17 23:44:30
@@ -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.109
diff -u -r1.109 mapgen.c
--- server/mapgen.c     2003/02/17 12:46:43     1.109
+++ server/mapgen.c     2003/02/17 23:44:32
@@ -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);
@@ -1303,7 +1303,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 23:44:32
@@ -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]