Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2004:
[Freeciv-Dev] (PR#11119) rewrite MAX_MAP_INDEX
Home

[Freeciv-Dev] (PR#11119) rewrite MAX_MAP_INDEX

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11119) rewrite MAX_MAP_INDEX
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 20 Nov 2004 18:55:16 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=11119 >

This patch:

- Renames MAX_MAP_INDEX as MAP_INDEX_SIZE.  This is more consistent with 
names like MAP_NATIVE_WIDTH or MAP_MAX_WIDTH.  INDEX gives the type of 
coordinate and should go second.  MAX should not be used since it gives 
an absolute maximum (rather than a maximum in this game).  MAP should be 
the prefix.  SIZE is used rather than WIDTH or HEIGHT because this is a 
1-dimensional value (although a better word here would be okay).

- Changes most users of (map.xsize*map.ysize) to be MAP_INDEX_SIZE.  One 
user is instead changed to be map_num_tiles().  map_num_tiles() is the 
only user that is left unchanged.  Many users are changed in other ways: 
one malloc+memset is changed to a calloc; some sizeof(type) are changed 
to sizeof(variable).

The difference between map_num_tiles() and MAP_INDEX_SIZE is rather 
subtle.  At the moment it doesn't really matter but someday it could 
(index positions could be sparse).

jason

Index: ai/aisettler.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aisettler.c,v
retrieving revision 1.10
diff -u -r1.10 aisettler.c
--- ai/aisettler.c      30 Oct 2004 15:57:43 -0000      1.10
+++ ai/aisettler.c      21 Nov 2004 02:50:18 -0000
@@ -441,8 +441,8 @@
 **************************************************************************/
 void ai_settler_init(struct player *pplayer)
 {
-  cachemap = fc_realloc(cachemap, MAX_MAP_INDEX * sizeof(*cachemap));
-  memset(cachemap, -1, MAX_MAP_INDEX * sizeof(*cachemap));
+  cachemap = fc_realloc(cachemap, MAP_INDEX_SIZE * sizeof(*cachemap));
+  memset(cachemap, -1, MAP_INDEX_SIZE * sizeof(*cachemap));
 }
 
 /**************************************************************************
Index: client/goto.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/goto.c,v
retrieving revision 1.78
diff -u -r1.78 goto.c
--- client/goto.c       10 Nov 2004 02:10:36 -0000      1.78
+++ client/goto.c       21 Nov 2004 02:50:18 -0000
@@ -92,8 +92,7 @@
     free_client_goto();
   }
 
-  goto_map.tiles = fc_malloc(map.xsize * map.ysize
-                             * sizeof(*goto_map.tiles));
+  goto_map.tiles = fc_malloc(MAP_INDEX_SIZE * sizeof(*goto_map.tiles));
   goto_map.parts = NULL;
   goto_map.num_parts = 0;
   goto_map.unit_id = -1;
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.213
diff -u -r1.213 tilespec.c
--- client/tilespec.c   20 Nov 2004 17:45:52 -0000      1.213
+++ client/tilespec.c   21 Nov 2004 02:50:19 -0000
@@ -2467,7 +2467,7 @@
 #define LARGE_PRIME 10007
 #define SMALL_PRIME 1009
       assert(count < SMALL_PRIME);
-      assert((int)(LARGE_PRIME * MAX_MAP_INDEX) > 0);
+      assert((int)(LARGE_PRIME * MAP_INDEX_SIZE) > 0);
       count = ((ptile->index
                * LARGE_PRIME) % SMALL_PRIME) % count;
       ADD_SPRITE(draw->layer[l].base.p[count],
Index: client/agents/sha.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/agents/sha.c,v
retrieving revision 1.2
diff -u -r1.2 sha.c
--- client/agents/sha.c 29 Sep 2004 02:24:19 -0000      1.2
+++ client/agents/sha.c 21 Nov 2004 02:50:19 -0000
@@ -96,8 +96,8 @@
 {
   struct agent self;
 
-  previous_tiles = fc_malloc(MAX_MAP_INDEX * sizeof(*previous_tiles));
-  memset(previous_tiles, 0, MAX_MAP_INDEX * sizeof(*previous_tiles));
+  previous_tiles = fc_malloc(MAP_INDEX_SIZE * sizeof(*previous_tiles));
+  memset(previous_tiles, 0, MAP_INDEX_SIZE * sizeof(*previous_tiles));
 
   unit_list_init(&previous_units);
 
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.203
diff -u -r1.203 map.c
--- common/map.c        13 Nov 2004 08:34:17 -0000      1.203
+++ common/map.c        21 Nov 2004 02:50:19 -0000
@@ -319,7 +319,7 @@
 
   if (!set_sizes) {
     /* Set map.size based on map.xsize and map.ysize. */
-    map.size = (float)(map.xsize * map.ysize) / 1000.0 + 0.5;
+    map.size = (float)(map_num_tiles()) / 1000.0 + 0.5;
   }
   
   /* sanity check for iso topologies*/
@@ -448,7 +448,7 @@
     return NULL;
   }
 
-  if (index >= 0 && index < MAX_MAP_INDEX) {
+  if (index >= 0 && index < MAP_INDEX_SIZE) {
     return map.tiles + index;
   } else {
     /* Unwrapped index coordinates are impossible, so the best we can do is
@@ -495,7 +495,7 @@
          map.tiles, map.xsize, map.ysize);
 
   assert(map.tiles == NULL);
-  map.tiles = fc_malloc(map.xsize * map.ysize * sizeof(struct tile));
+  map.tiles = fc_malloc(MAP_INDEX_SIZE * sizeof(*map.tiles));
   whole_map_iterate(ptile) {
     int index, nat_x, nat_y, map_x, map_y;
 
@@ -1601,18 +1601,18 @@
 {
   struct tile *ptile;
   int tries = 0;
-  const int max_tries = map.xsize * map.ysize / ACTIVITY_FACTOR;
+  const int max_tries = MAP_INDEX_SIZE / ACTIVITY_FACTOR;
 
   /* First do a few quick checks to find a spot.  The limit on number of
    * tries could use some tweaking. */
   do {
-    ptile = map.tiles + myrand(map.xsize * map.ysize);
+    ptile = map.tiles + myrand(MAP_INDEX_SIZE);
   } while (filter && !filter(ptile, data) && ++tries < max_tries);
 
   /* If that fails, count all available spots and pick one.
    * Slow but reliable. */
   if (tries == max_tries) {
-    int count = 0, positions[map.xsize * map.ysize];
+    int count = 0, positions[MAP_INDEX_SIZE];
 
     whole_map_iterate(ptile) {
       if (filter(ptile, data)) {
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.225
diff -u -r1.225 map.h
--- common/map.h        13 Nov 2004 08:34:17 -0000      1.225
+++ common/map.h        21 Nov 2004 02:50:19 -0000
@@ -229,14 +229,14 @@
 void initialize_move_costs(void);
 void reset_move_costs(struct tile *ptile);
 
-/* Maximum value of index (for sanity checks and allocations) */
-#define MAX_MAP_INDEX (map.xsize * map.ysize)
+/* Number of index coordinates (for sanity checks and allocations) */
+#define MAP_INDEX_SIZE (map.xsize * map.ysize)
 
 #ifdef DEBUG
 #define CHECK_MAP_POS(x,y) assert(is_normal_map_pos((x),(y)))
 #define CHECK_NATIVE_POS(x, y) assert((x) >= 0 && (x) < map.xsize \
                                      && (y) >= 0 && (y) < map.ysize)
-#define CHECK_INDEX(index) assert((index) >= 0 && (index) < MAX_MAP_INDEX)
+#define CHECK_INDEX(index) assert((index) >= 0 && (index) < MAP_INDEX_SIZE)
 #else
 #define CHECK_MAP_POS(x,y) ((void)0)
 #define CHECK_NATIVE_POS(x, y) ((void)0)
@@ -568,7 +568,7 @@
 #define whole_map_iterate(ptile)                                           \
 {                                                                           \
   int _index; /* We use index positions for cache efficiency. */           \
-  for (_index = 0; _index < MAX_MAP_INDEX; _index++) {                     \
+  for (_index = 0; _index < MAP_INDEX_SIZE; _index++) {                        
    \
     struct tile *ptile = map.tiles + _index;                               \
 
 #define whole_map_iterate_end                                               \
Index: common/aicore/citymap.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/citymap.c,v
retrieving revision 1.5
diff -u -r1.5 citymap.c
--- common/aicore/citymap.c     30 Sep 2004 12:17:16 -0000      1.5
+++ common/aicore/citymap.c     21 Nov 2004 02:50:19 -0000
@@ -62,8 +62,8 @@
   /* The citymap is reinitialized at the start of ever turn.  This includes
    * a call to realloc, which only really matters if this is the first turn
    * of the game (but it's easier than a separate function to do this). */
-  citymap = fc_realloc(citymap, MAX_MAP_INDEX * sizeof(*citymap));
-  memset(citymap, 0, MAX_MAP_INDEX * sizeof(*citymap));
+  citymap = fc_realloc(citymap, MAP_INDEX_SIZE * sizeof(*citymap));
+  memset(citymap, 0, MAP_INDEX_SIZE * sizeof(*citymap));
 
   players_iterate(pplayer) {
     city_list_iterate(pplayer->cities, pcity) {
Index: common/aicore/path_finding.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/path_finding.c,v
retrieving revision 1.25
diff -u -r1.25 path_finding.c
--- common/aicore/path_finding.c        23 Oct 2004 19:15:19 -0000      1.25
+++ common/aicore/path_finding.c        21 Nov 2004 02:50:19 -0000
@@ -423,14 +423,14 @@
 {
   struct pf_map *pf_map = fc_calloc(1, sizeof(struct pf_map));
 
-  pf_map->lattice = fc_malloc(MAX_MAP_INDEX * sizeof(struct pf_node));
+  pf_map->lattice = fc_malloc(MAP_INDEX_SIZE * sizeof(struct pf_node));
   pf_map->queue = pq_create(INITIAL_QUEUE_SIZE);
-  pf_map->status = fc_calloc(MAX_MAP_INDEX, sizeof(*(pf_map->status)));
+  pf_map->status = fc_calloc(MAP_INDEX_SIZE, sizeof(*(pf_map->status)));
 
   if (with_danger) {
     /* Initialize stuff for dangerous positions.
      * Otherwise they stay NULL */
-    pf_map->d_lattice = fc_calloc(MAX_MAP_INDEX, sizeof(struct danger_node));
+    pf_map->d_lattice = fc_calloc(MAP_INDEX_SIZE, sizeof(struct danger_node));
     pf_map->danger_queue = pq_create(INITIAL_QUEUE_SIZE);
   }
 
@@ -491,7 +491,7 @@
     int i;
 
     /* Need to clean up the dangling danger_sements */
-    for (i = 0; i < MAX_MAP_INDEX; i++) {
+    for (i = 0; i < MAP_INDEX_SIZE; i++) {
       if (pf_map->d_lattice[i].danger_segment) {
        free(pf_map->d_lattice[i].danger_segment);
       }
Index: server/gotohand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/gotohand.c,v
retrieving revision 1.187
diff -u -r1.187 gotohand.c
--- server/gotohand.c   31 Oct 2004 22:32:33 -0000      1.187
+++ server/gotohand.c   21 Nov 2004 02:50:20 -0000
@@ -194,14 +194,14 @@
 **************************************************************************/
 static void init_warmap(struct tile *orig_tile, enum unit_move_type move_type)
 {
-  if (warmap.size != MAX_MAP_INDEX) {
+  if (warmap.size != MAP_INDEX_SIZE) {
     warmap.cost = fc_realloc(warmap.cost,
-                            MAX_MAP_INDEX * sizeof(*warmap.cost));
+                            MAP_INDEX_SIZE * sizeof(*warmap.cost));
     warmap.seacost = fc_realloc(warmap.seacost,
-                               MAX_MAP_INDEX * sizeof(*warmap.seacost));
+                               MAP_INDEX_SIZE * sizeof(*warmap.seacost));
     warmap.vector = fc_realloc(warmap.vector,
-                              MAX_MAP_INDEX * sizeof(*warmap.vector));
-    warmap.size = MAX_MAP_INDEX;
+                              MAP_INDEX_SIZE * sizeof(*warmap.vector));
+    warmap.size = MAP_INDEX_SIZE;
   }
 
   init_queue();
@@ -211,12 +211,12 @@
   case HELI_MOVING:
   case AIR_MOVING:
     assert(sizeof(*warmap.cost) == sizeof(char));
-    memset(warmap.cost, MAXCOST, map.xsize * map.ysize);
+    memset(warmap.cost, MAXCOST, MAP_INDEX_SIZE * sizeof(char));
     WARMAP_COST(orig_tile) = 0;
     break;
   case SEA_MOVING:
     assert(sizeof(*warmap.seacost) == sizeof(char));
-    memset(warmap.seacost, MAXCOST, map.xsize * map.ysize);
+    memset(warmap.seacost, MAXCOST, MAP_INDEX_SIZE * sizeof(char));
     WARMAP_SEACOST(orig_tile) = 0;
     break;
   default:
@@ -572,7 +572,7 @@
   int maxcost = MAXCOST;
   int move_cost, total_cost;
   int straight_dir = 0;        /* init to silence compiler warning */
-  dir_vector local_vector[MAX_MAP_INDEX];
+  dir_vector local_vector[MAP_INDEX_SIZE];
 #define LOCAL_VECTOR(ptile) local_vector[(ptile)->index]
   struct unit *pcargo;
   /* 
@@ -818,7 +818,7 @@
   /*** Succeeded. The vector at the destination indicates which way we get 
there.
      Now backtrack to remove all the blind paths ***/
   assert(sizeof(*warmap.vector) == sizeof(char));
-  memset(warmap.vector, 0, map.xsize * map.ysize);
+  memset(warmap.vector, 0, MAP_INDEX_SIZE * sizeof(char));
 
   init_queue();
   add_to_mapqueue(0, dest_tile);
Index: server/maphand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/maphand.c,v
retrieving revision 1.150
diff -u -r1.150 maphand.c
--- server/maphand.c    15 Oct 2004 09:39:05 -0000      1.150
+++ server/maphand.c    21 Nov 2004 02:50:21 -0000
@@ -1016,8 +1016,8 @@
 ****************************************************************/
 void player_map_allocate(struct player *pplayer)
 {
-  pplayer->private_map =
-    fc_malloc(map.xsize*map.ysize*sizeof(struct player_tile));
+  pplayer->private_map
+    = fc_malloc(MAP_INDEX_SIZE * sizeof(*pplayer->private_map));
   whole_map_iterate(ptile) {
     player_tile_init(ptile, pplayer);
   } whole_map_iterate_end;
Index: server/score.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/score.c,v
retrieving revision 1.8
diff -u -r1.8 score.c
--- server/score.c      29 Sep 2004 02:24:24 -0000      1.8
+++ server/score.c      21 Nov 2004 02:50:21 -0000
@@ -145,9 +145,7 @@
 {
   int nbytes;
 
-  nbytes = map.xsize * map.ysize * sizeof(struct claim_cell);
-  pcmap->claims = fc_malloc(nbytes);
-  memset(pcmap->claims, 0, nbytes);
+  pcmap->claims = fc_calloc(MAP_INDEX_SIZE, sizeof(*pcmap->claims));
 
   nbytes = game.nplayers * sizeof(int);
   pcmap->player_landarea = fc_malloc(nbytes);
@@ -157,7 +155,7 @@
   pcmap->player_owndarea = fc_malloc(nbytes);
   memset(pcmap->player_owndarea, 0, nbytes);
 
-  nbytes = 2 * map.xsize * map.ysize * sizeof(*pcmap->edges);
+  nbytes = 2 * MAP_INDEX_SIZE * sizeof(*pcmap->edges);
   pcmap->edges = fc_malloc(nbytes);
 
   players_iterate(pplayer) {
@@ -244,7 +242,7 @@
   struct tile **thisedge;
   struct tile **nextedge;
 
-  midedge = &pcmap->edges[map.xsize * map.ysize];
+  midedge = &pcmap->edges[MAP_INDEX_SIZE];
 
   for (accum = 1, turn = 1; accum > 0; turn++) {
     thisedge = ((turn & 0x1) == 1) ? pcmap->edges : midedge;
Index: server/settlers.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v
retrieving revision 1.211
diff -u -r1.211 settlers.c
--- server/settlers.c   16 Nov 2004 21:25:41 -0000      1.211
+++ server/settlers.c   21 Nov 2004 02:50:21 -0000
@@ -137,7 +137,7 @@
   /* (Re)allocate map arrays.  Note that the server may run more than one
    * game so the realloc() is necessary. */
   territory = fc_realloc(territory,
-                         map.xsize * map.ysize * sizeof(*territory));
+                         MAP_INDEX_SIZE * sizeof(*territory));
 }
 
 /**************************************************************************
@@ -1420,7 +1420,7 @@
 **************************************************************************/
 static void assign_territory(void)
 {
-  memset(territory, 0, map.xsize * map.ysize * sizeof(*territory));
+  memset(territory, 0, MAP_INDEX_SIZE * sizeof(*territory));
 
   players_iterate(pplayer) {
     assign_territory_player(pplayer);
Index: server/generator/height_map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/height_map.c,v
retrieving revision 1.7
diff -u -r1.7 height_map.c
--- server/generator/height_map.c       16 Oct 2004 22:29:13 -0000      1.7
+++ server/generator/height_map.c       21 Nov 2004 02:50:21 -0000
@@ -72,9 +72,9 @@
 void make_random_hmap(int smooth)
 {
   int i = 0;
-  height_map = fc_malloc (sizeof(int) * MAX_MAP_INDEX);
+  height_map = fc_malloc(sizeof(int) * MAP_INDEX_SIZE);
 
-  INITIALIZE_ARRAY(height_map, MAX_MAP_INDEX, myrand(1000 * smooth) );
+  INITIALIZE_ARRAY(height_map, MAP_INDEX_SIZE, myrand(1000 * smooth));
 
   for (; i < smooth; i++) {
     smooth_int_map(height_map, TRUE);
@@ -183,10 +183,10 @@
   /* edges are avoided more strongly as this increases */
   int avoidedge = (100 - map.landpercent) * step / 100 + step / 3; 
 
-  height_map = fc_malloc(sizeof(int) * MAX_MAP_INDEX);
+  height_map = fc_malloc(sizeof(int) * MAP_INDEX_SIZE);
 
  /* initialize map */
-  INITIALIZE_ARRAY(height_map, MAX_MAP_INDEX, 0);
+  INITIALIZE_ARRAY(height_map, MAP_INDEX_SIZE, 0);
 
   /* set initial points */
   for (xn = 0; xn < xdiv2; xn++) {
Index: server/generator/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/mapgen.c,v
retrieving revision 1.16
diff -u -r1.16 mapgen.c
--- server/generator/mapgen.c   13 Nov 2004 08:34:17 -0000      1.16
+++ server/generator/mapgen.c   21 Nov 2004 02:50:21 -0000
@@ -802,8 +802,6 @@
   /* The number of river tiles that have been set. */
   int current_riverlength = 0;
 
-  int i; /* Loop variable. */
-
   /* Counts the number of iterations (should increase with 1 during
      every iteration of the main loop in this function).
      Is needed to stop a potentially infinite loop. */
@@ -812,7 +810,7 @@
   create_placed_map(); /* needed bu rand_map_characteristic */
   set_all_ocean_tiles_placed();
 
-  river_map = fc_malloc(sizeof(int) * MAX_MAP_INDEX);
+  river_map = fc_malloc(sizeof(*river_map) * MAP_INDEX_SIZE);
 
   /* The main loop in this function. */
   while (current_riverlength < desirable_riverlength
@@ -865,9 +863,7 @@
            || iteration_counter == RIVERS_MAXTRIES / 10 * 9)) {
 
       /* Reset river_map before making a new river. */
-      for (i = 0; i < map.xsize * map.ysize; i++) {
-       river_map[i] = 0;
-      }
+      memset(river_map, 0, MAP_INDEX_SIZE * sizeof(*river_map));
 
       freelog(LOG_DEBUG,
              "Found a suitable starting tile for a river at (%d, %d)."
@@ -1468,7 +1464,7 @@
   bool j;
   struct tile *ptile = native_pos_to_tile(map.xsize / 2, map.ysize / 2);
 
-  memset(height_map, '\0', sizeof(int) * map.xsize * map.ysize);
+  memset(height_map, '\0', MAP_INDEX_SIZE * sizeof(*height_map));
   hmap(native_pos_to_tile(map.xsize / 2, map.ysize / 2)) = 1;
   pstate->n = ptile->nat_y - 1;
   pstate->w = ptile->nat_x - 1;
@@ -1649,7 +1645,7 @@
 **************************************************************************/
 static void initworld(struct gen234_state *pstate)
 {
-  height_map = fc_malloc(sizeof(int) * map.ysize * map.xsize);
+  height_map = fc_malloc(MAP_INDEX_SIZE * sizeof(*height_map));
   create_placed_map(); /* land tiles which aren't placed yet */
   create_tmap(FALSE);
   
Index: server/generator/mapgen_topology.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/mapgen_topology.h,v
retrieving revision 1.3
diff -u -r1.3 mapgen_topology.h
--- server/generator/mapgen_topology.h  29 Sep 2004 02:24:24 -0000      1.3
+++ server/generator/mapgen_topology.h  21 Nov 2004 02:50:21 -0000
@@ -19,7 +19,7 @@
 #define MAX_COLATITUDE 1000
 
 /* An estimate of the linear (1-dimensional) size of the map. */
-#define SQSIZE MAX(1, sqrt(map.xsize * map.ysize / 1000))
+#define SQSIZE MAX(1, sqrt(MAP_INDEX_SIZE / 1000))
 
 /* size safe Unit of colatitude */ 
 #define L_UNIT (MAX_COLATITUDE / (30 * SQSIZE) )
Index: server/generator/startpos.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/startpos.c,v
retrieving revision 1.6
diff -u -r1.6 startpos.c
--- server/generator/startpos.c 8 Nov 2004 15:15:54 -0000       1.6
+++ server/generator/startpos.c 21 Nov 2004 02:50:21 -0000
@@ -183,7 +183,7 @@
   struct tile *ptile;
   int k, sum;
   struct start_filter_data data;
-  int tile_value_aux[MAX_MAP_INDEX], tile_value[MAX_MAP_INDEX];
+  int tile_value_aux[MAP_INDEX_SIZE], tile_value[MAP_INDEX_SIZE];
   int min_goodies_per_player = 2000;
   int total_goodies = 0;
   /* this is factor is used to maximize land used in extreme little maps */
Index: server/generator/temperature_map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/temperature_map.c,v
retrieving revision 1.4
diff -u -r1.4 temperature_map.c
--- server/generator/temperature_map.c  15 Oct 2004 21:45:17 -0000      1.4
+++ server/generator/temperature_map.c  21 Nov 2004 02:50:21 -0000
@@ -80,7 +80,7 @@
     return;
   }
 
-  temperature_map = fc_malloc(sizeof(int) * MAX_MAP_INDEX);
+  temperature_map = fc_malloc(sizeof(*temperature_map) * MAP_INDEX_SIZE);
   whole_map_iterate(ptile) {
   
      /* the base temperature is equal to base map_colatitude */
@@ -107,7 +107,7 @@
     adjust_int_map(temperature_map, MAX_COLATITUDE);
   }
   /* now simplify to 4 base values */ 
-  for (i = 0; i < MAX_MAP_INDEX; i++) {
+  for (i = 0; i < MAP_INDEX_SIZE; i++) {
     int t = temperature_map[i];
 
     if (t >= TROPICAL_LEVEL) {
Index: server/generator/utilities.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/generator/utilities.c,v
retrieving revision 1.12
diff -u -r1.12 utilities.c
--- server/generator/utilities.c        21 Oct 2004 20:06:15 -0000      1.12
+++ server/generator/utilities.c        21 Nov 2004 02:50:21 -0000
@@ -38,8 +38,8 @@
 void create_placed_map(void)                               
 {                                                          
   assert(!placed_map_is_initialized());                              
-  placed_map = fc_malloc (sizeof(bool) * MAX_MAP_INDEX);   
-  INITIALIZE_ARRAY(placed_map, MAX_MAP_INDEX, FALSE );     
+  placed_map = fc_malloc (sizeof(bool) * MAP_INDEX_SIZE);   
+  INITIALIZE_ARRAY(placed_map, MAP_INDEX_SIZE, FALSE );     
 }
 
 /**************************************************************************** 
@@ -162,7 +162,7 @@
 
 /****************************************************************************
  * Apply a Gaussian difusion filtre on the map
- * the size of the map is MAX_MAP_INDEX and the map is indexed by 
+ * the size of the map is MAP_INDEX_SIZE and the map is indexed by 
  * native_pos_to_index function
  * if zeroes_at_edges is set, any unreal position on difusion has 0 value
  * if zeroes_at_edges in unset the unreal position are not counted.
@@ -172,7 +172,7 @@
   float weight[5] =  {0.35,  0.5 ,1 , 0.5, 0.35};
   float total_weight = 2.70;
   bool axe = TRUE;
-  int alt_int_map[MAX_MAP_INDEX];
+  int alt_int_map[MAP_INDEX_SIZE];
   int *target_map, *source_map;
 
   assert(int_map != NULL);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#11119) rewrite MAX_MAP_INDEX, Jason Short <=