Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] (PR#7204) completing iso-map support
Home

[Freeciv-Dev] (PR#7204) completing iso-map support

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jshort@xxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#7204) completing iso-map support
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 22 Jan 2004 22:16:31 -0800
Reply-to: rt@xxxxxxxxxxx

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

> [jshort@xxxxxxxxxxxxxx - Tue Jan 06 06:32:48 2004]:
> 
> Attached is the most recent version of the gen-topologies patch.  This 
> enables support for iso-maps (topologies 4-7).  There may be a few bugs 
> (it is hard to test all parameters) but it is generally quite stable.
> 
> Unfortunately most of the remaining changes are either very ugly 
> (mapgen) or not agreed on (climisc).  So I'm not quite sure where to go 
> from here.

This version is updated for current CVS and has support for all generators.

jason

Version 65 of the patch.

Index: client/climisc.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/climisc.c,v
retrieving revision 1.125
diff -u -r1.125 climisc.c
--- client/climisc.c    2004/01/11 17:45:03     1.125
+++ client/climisc.c    2004/01/23 06:14:54
@@ -362,20 +362,27 @@
     assert(punit != NULL);
     center_tile_mapcanvas(punit->x, punit->y);
   } else {
-    /* Just any known tile will do; search near the middle first. */
-    iterate_outward(map.xsize / 2, map.ysize / 2,
-                   MAX(map.xsize / 2, map.ysize / 2), x, y) {
+    int map_x, map_y, center_map_x, center_map_y, dist = -1;
+
+    native_to_map_pos(&map_x, &map_y, map.xsize / 2, map.ysize / 2);
+    center_map_x = map_x;
+    center_map_y = map_y;
+
+    /* Look for any known tile - preferably close to the map center.  The
+     * default is the map center. */
+    whole_map_iterate(x, y) {
       if (tile_get_known(x, y) != TILE_UNKNOWN) {
-       center_tile_mapcanvas(x, y);
-       goto OUT;
+       int mydist = sq_map_distance(x, y, center_map_x, center_map_y);
+
+       if (dist == -1 || mydist < dist) {
+         dist = mydist;
+         map_x = x;
+         map_y = y;
+       }
       }
-    }
-    iterate_outward_end;
-    /* If we get here we didn't find a known tile.
-       Refresh a random place to clear the intro gfx. */
-    center_tile_mapcanvas(map.xsize / 2, map.ysize / 2);
-  OUT:
-    ;                          /* do nothing */
+    } whole_map_iterate_end;
+
+    center_tile_mapcanvas(map_x, map_y);
   }
 }
 
Index: common/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.153
diff -u -r1.153 capstr.c
--- common/capstr.c     2004/01/22 23:52:20     1.153
+++ common/capstr.c     2004/01/23 06:14:55
@@ -75,7 +75,7 @@
  */
 
 #define CAPABILITY "+1.14.delta +last_turns_shield_surplus veteran +orders " \
-                   "+starter"
+                   "+starter +iso_maps"
 
 /* "+1.14.delta" is the new delta protocol for 1.14.0-dev.
  *
@@ -88,6 +88,9 @@
  * "veteran" means the extended veteran system.
  *
  * "starter" means the Starter terrain flag is supported.
+ *
+ * "iso_maps" means there is support for isometric maps (topology values
+ * 4-7).
  */
 
 void init_our_capability(void)
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.156
diff -u -r1.156 map.c
--- common/map.c        2004/01/22 23:52:21     1.156
+++ common/map.c        2004/01/23 06:14:55
@@ -67,6 +67,7 @@
 };
 
 #define MAP_TILE(x,y)  (map.tiles + map_pos_to_index(x, y))
+#define NAT_TILE(x, y)  (map.tiles + native_pos_to_index(x, y))
 
 /***************************************************************
 ...
@@ -1149,6 +1150,14 @@
   return MAP_TILE(x, y)->terrain;
 }
 
+/****************************************************************************
+  Return the terrain type of the given tile (in native coordinates).
+****************************************************************************/
+enum tile_terrain_type nat_get_terrain(int nat_x, int nat_y)
+{
+  return NAT_TILE(nat_x, nat_y)->terrain;
+}
+
 /***************************************************************
 ...
 ***************************************************************/
@@ -1199,6 +1208,14 @@
 void map_set_terrain(int x, int y, enum tile_terrain_type ter)
 {
   MAP_TILE(x, y)->terrain = ter;
+}
+
+/****************************************************************************
+  Set the terrain of the given tile (in native coordinates).
+****************************************************************************/
+void nat_set_terrain(int nat_x, int nat_y, enum tile_terrain_type ter)
+{
+  NAT_TILE(nat_x, nat_y)->terrain = ter;
 }
 
 /***************************************************************
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.169
diff -u -r1.169 map.h
--- common/map.h        2004/01/20 21:52:08     1.169
+++ common/map.h        2004/01/23 06:14:55
@@ -247,8 +247,10 @@
 struct city *map_get_city(int x, int y);
 void map_set_city(int x, int y, struct city *pcity);
 enum tile_terrain_type map_get_terrain(int x, int y);
+enum tile_terrain_type nat_get_terrain(int nat_x, int nat_y);
 enum tile_special_type map_get_special(int x, int y);
 void map_set_terrain(int x, int y, enum tile_terrain_type ter);
+void nat_set_terrain(int nat_x, int nat_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);
 void map_clear_all_specials(int x, int y);
@@ -610,7 +612,7 @@
 #define MAP_ORIGINAL_TOPO        TF_WRAPX
 #define MAP_DEFAULT_TOPO         TF_WRAPX
 #define MAP_MIN_TOPO             0
-#define MAP_MAX_TOPO             3
+#define MAP_MAX_TOPO             7
 
 #define MAP_DEFAULT_SEED         0
 #define MAP_MIN_SEED             0
Index: server/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v
retrieving revision 1.125
diff -u -r1.125 mapgen.c
--- server/mapgen.c     2004/01/17 17:21:20     1.125
+++ server/mapgen.c     2004/01/23 06:14:56
@@ -32,8 +32,45 @@
 
 #include "mapgen.h"
 
+/* Provide a block to convert from native to map coordinates.  For instance
+ *   do_in_map_pos(mx, my, x, y) {
+ *     map_set_terrain(mx, my, T_OCEAN);
+ *   } do_in_map_pos_end;
+ */
+#define do_in_map_pos(map_x, map_y, nat_x, nat_y)                           \
+{                                                                           \
+  int _map_x, _map_y;                                                       \
+  native_to_map_pos(&_map_x, &_map_y, nat_x, nat_y);                        \
+  {                                                                         \
+    /* Changing map_x and map_y would probably be an error. */              \
+    const int map_x = _map_x, map_y = _map_y;                               \
+    {
+
+#define do_in_map_pos_end                                                   \
+    }                                                                       \
+  }                                                                         \
+}
+
+/* Provide a block to convert from native to map coordinates, and back.
+ * For instance
+ *   do_with_map_pos(mx, my, x, y) {
+ *     MAPSTEP(mx, my, DIR8_NORTH);
+ *   } do_with_map_pos_end;
+ */
+#define do_with_map_pos(map_x, map_y, nat_x, nat_y)                         \
+{                                                                           \
+  int map_x, map_y;                                                         \
+  native_to_map_pos(&map_x, &map_y, nat_x, nat_y);                          \
+  {                                                                         \
+
+#define do_with_map_pos_end(max_x, map_y, nat_x, nat_y)                        
    \
+  }                                                                         \
+  map_to_native_pos(&nat_x, &nat_y, map_x, map_y);                          \
+}
+
 /* Wrapper for easy access.  It's a macro so it can be a lvalue. */
 #define hmap(x, y) (height_map[map_pos_to_index(x, y)])
+#define hnat(x, y) (height_map[native_pos_to_index(x, y)])
 #define rmap(x, y) (river_map[map_pos_to_index(x, y)])
 
 static void make_huts(int number);
@@ -113,24 +150,26 @@
 
   for (y=0;y<map.ysize/10;y++) {
     for (x=0;x<map.xsize;x++) {
-      if ((hmap(x, y)+(map.ysize/10-y*25)>myrand(maxval) &&
-          map_get_terrain(x,y)==T_GRASSLAND) || y==0) { 
+      if ((hnat(x, y) + (map.ysize / 10 - y * 25) > myrand(maxval)
+          && nat_get_terrain(x, y) == T_GRASSLAND) || y == 0) { 
        if (y<2)
-         map_set_terrain(x, y, T_ARCTIC);
+         nat_set_terrain(x, y, T_ARCTIC);
        else
-         map_set_terrain(x, y, T_TUNDRA);
+         nat_set_terrain(x, y, T_TUNDRA);
          
       } 
     }
   }
   for (y=map.ysize*9/10;y<map.ysize;y++) {
     for (x=0;x<map.xsize;x++) {
-      if ((hmap(x, y)+(map.ysize/10-(map.ysize-y)*25)>myrand(maxval) &&
-          map_get_terrain(x, y)==T_GRASSLAND) || y==map.ysize-1) {
+      if (((hnat(x, y) + (map.ysize / 10 - (map.ysize - y) * 25)
+           > myrand(maxval))
+          && nat_get_terrain(x, y) == T_GRASSLAND)
+         || y == map.ysize - 1) {
        if (y>map.ysize-3)
-         map_set_terrain(x, y, T_ARCTIC);
+         nat_set_terrain(x, y, T_ARCTIC);
        else
-         map_set_terrain(x, y, T_TUNDRA);
+         nat_set_terrain(x, y, T_TUNDRA);
       }
     }
   }
@@ -140,12 +179,14 @@
      turn every land tile on the second lines that is not arctic into tundra,
      since the first lines has already been set to all arctic above. */
   for (x=0;x<map.xsize;x++) {
-    if (map_get_terrain(x, 1)!=T_ARCTIC &&
-       !is_ocean(map_get_terrain(x, 1)))
-      map_set_terrain(x, 1, T_TUNDRA);
-    if (map_get_terrain(x, map.ysize-2)!=T_ARCTIC && 
-       !is_ocean(map_get_terrain(x, map.ysize-2)))
-      map_set_terrain(x, map.ysize-2, T_TUNDRA);
+    if (nat_get_terrain(x, 1) != T_ARCTIC
+       && !is_ocean(nat_get_terrain(x, 1))) {
+      nat_set_terrain(x, 1, T_TUNDRA);
+    }
+    if (nat_get_terrain(x, map.ysize - 2) != T_ARCTIC
+       && !is_ocean(nat_get_terrain(x, map.ysize - 2))) {
+      nat_set_terrain(x, map.ysize - 2, T_TUNDRA);
+    }
   }
 }
 
@@ -174,21 +215,27 @@
   enough forest has been planted. diff is again the block function.
   if we're close to equator it will with 50% chance generate jungle instead
 **************************************************************************/
-static void make_forest(int x, int y, int height, int diff)
+static void make_forest(int map_x, int map_y, int height, int diff)
 {
-  if (y==0 || y==map.ysize-1)
+  int nat_x, nat_y;
+
+  map_to_native_pos(&nat_x, &nat_y, map_x, map_y);
+  if (nat_y == 0 || nat_y == map.ysize - 1) {
     return;
+  }
 
-  if (map_get_terrain(x, y)==T_GRASSLAND) {
-    if (y>map.ysize*42/100 && y<map.ysize*58/100 && myrand(100)>50)
-      map_set_terrain(x, y, T_JUNGLE);
-    else 
-      map_set_terrain(x, y, T_FOREST);
-      if (abs(hmap(x, y)-height)<diff) {
-       cartesian_adjacent_iterate(x, y, x1, y1) {
-         if (myrand(10)>5) make_forest(x1, y1, height, diff-5);
-       } cartesian_adjacent_iterate_end;
-      }
+  if (map_get_terrain(map_x, map_y) == T_GRASSLAND) {
+    if (nat_y > map.ysize * 42 / 100
+       && nat_y < map.ysize * 58 / 100 && myrand(100) > 50) {
+      map_set_terrain(map_x, map_y, T_JUNGLE);
+    } else {
+      map_set_terrain(map_x, map_y, T_FOREST);
+    }
+    if (abs(hmap(map_x, map_y) - height) < diff) {
+      cartesian_adjacent_iterate(map_x, map_y, x1, y1) {
+       if (myrand(10)>5) make_forest(x1, y1, height, diff-5);
+      } cartesian_adjacent_iterate_end;
+    }
     forests++;
   }
 }
@@ -212,7 +259,8 @@
     if (has_poles && myrand(100) > 75) {
       y = (myrand(map.ysize * 2 / 10)) + map.ysize * 4 / 10;
       x = myrand(map.xsize);
-      if (map_get_terrain(x, y) == T_GRASSLAND) {
+      if (nat_get_terrain(x, y) == T_GRASSLAND) {
+       native_to_map_pos(&x, &y, x, y);
        make_forest(x, y, hmap(x, y), 25);
       }
     }
@@ -266,6 +314,7 @@
       if (myrand(2) != 0) {
        y = map.ysize - 1 - y;
       }
+      native_to_map_pos(&x, &y, x, y);
     } else {
       /* If there are no poles we can pick any location to be a desert. */
       rand_map_pos(&x, &y);
@@ -772,12 +821,24 @@
   int x;
   
   for (x=0;x<map.xsize;x++) {
-    map_set_terrain(x, 2, T_OCEAN);
-    if (myrand(100)>50) map_set_terrain(x,1,T_OCEAN);
-    if (myrand(100)>50) map_set_terrain(x,3,T_OCEAN);
-    map_set_terrain(x, map.ysize-3, T_OCEAN);
-    if (myrand(100)>50) map_set_terrain(x,map.ysize-2,T_OCEAN);
-    if (myrand(100)>50) map_set_terrain(x,map.ysize-4,T_OCEAN);
+    nat_set_terrain(x, 2, T_OCEAN);
+
+    if (myrand(2) != 0) {
+      nat_set_terrain(x, 1, T_OCEAN);
+    }
+
+    if (myrand(2) != 0) {
+      nat_set_terrain(x, 3, T_OCEAN);
+    }
+
+    nat_set_terrain(x, map.ysize - 3, T_OCEAN);
+
+    if (myrand(2) != 0) {
+      nat_set_terrain(x, map.ysize - 2, T_OCEAN);
+    }
+    if (myrand(2) != 0) {
+      nat_set_terrain(x, map.ysize - 4, T_OCEAN);
+    }
   } 
   
 }
@@ -859,11 +920,11 @@
     return FALSE;
   }
 
-  cartesian_adjacent_iterate(x, y, x1, y1) {
+  adjc_iterate(x, y, x1, y1) {
     if (!is_ocean(map_get_terrain(x1, y1))) {
       return FALSE;
     }
-  } cartesian_adjacent_iterate_end;
+  } adjc_iterate_end;
 
   return TRUE;
 }
@@ -921,8 +982,16 @@
   } whole_map_iterate_end;
 
   if (map.generator != 0 && has_poles) {
-    assign_continent_flood(0, 0, 1);
-    assign_continent_flood(0, map.ysize-1, 2);
+    int map_x, map_y;
+
+    native_to_map_pos(&map_x, &map_y, 0, 0);
+    do_in_map_pos(x, y, 0, 0) {
+      assign_continent_flood(x, y, 1);
+    } do_in_map_pos_end;
+
+    do_in_map_pos(x, y, 0, map.ysize - 1) {
+      assign_continent_flood(x, y, 2);
+    } do_in_map_pos_end;
     isle = 3;
   }
       
@@ -1327,10 +1396,12 @@
 
 static void add_specials(int prob)
 {
-  int x,y;
+  int xn,yn;
   enum tile_terrain_type ttype;
-  for (y=1;y<map.ysize-1;y++) {
-    for (x=0;x<map.xsize; x++) {
+  for (yn=1;yn<map.ysize-1;yn++) {
+    for (xn=0;xn<map.xsize; xn++) {
+      int x,y;
+      native_to_map_pos(&x, &y, xn, yn);
       ttype = map_get_terrain(x, y);
       if ((is_ocean(ttype) && is_coastline(x,y)) || !is_ocean(ttype)) {
        if (myrand(1000)<prob) {
@@ -1358,35 +1429,36 @@
   long int totalmass;
 };
 
-static bool is_cold(int x, int y){
+static bool map_pos_is_cold(int x, int y)
+{
+  if (!has_poles) {
+    return FALSE;
+  }
+
+  map_to_native_pos(&x, &y, x, y);
   return ( y * 5 < map.ysize || y * 5 > map.ysize * 4 );
 }
 
 /**************************************************************************
 Returns a random position in the rectangle denoted by the given state.
 **************************************************************************/
-static void get_random_map_position_from_state(int *x, int *y,
+static void get_random_nat_position_from_state(int *x, int *y,
                                               const struct gen234_state
                                               *const pstate)
 {
-  bool is_real;
-
-  *x = pstate->w;
-  *y = pstate->n;
-
-  is_real = normalize_map_pos(x, y);
-  assert(is_real);
-
   assert((pstate->e - pstate->w) > 0);
   assert((pstate->e - pstate->w) < map.xsize);
   assert((pstate->s - pstate->n) > 0);
   assert((pstate->s - pstate->n) < map.ysize);
 
-  *x += myrand(pstate->e - pstate->w);
-  *y += myrand(pstate->s - pstate->n);
+  *x = pstate->w + myrand(pstate->e - pstate->w);
+  *y = pstate->n + myrand(pstate->s - pstate->n);
 
-  is_real = normalize_map_pos(x, y);
-  assert(is_real);
+  do_with_map_pos(map_x, map_y, *x, *y) {
+    if (!normalize_map_pos(&map_x, &map_y)) {
+      die("Invalid map operation.");
+    }
+  } do_with_map_pos_end(map_x, map_y, *x, *y);
 }
 
 /**************************************************************************
@@ -1418,7 +1490,8 @@
     i= 0;
 
   while (i > 0 && (failsafe--) > 0) {
-    get_random_map_position_from_state(&x, &y, pstate);
+    get_random_nat_position_from_state(&x, &y, pstate);
+    native_to_map_pos(&x, &y, x, y);
 
     if (map_get_continent(x, y) == pstate->isleindex &&
        map_get_terrain(x, y) == T_GRASSLAND) {
@@ -1434,7 +1507,7 @@
             )
           &&( !is_at_coast(x, y) || myrand(100) < coast )) {
         if (cold1 != T_RIVER) {
-          if ( is_cold(x,y) )
+          if (map_pos_is_cold(x, y))
             map_set_terrain(x, y, 
(myrand(cold0_weight+cold1_weight)<cold0_weight) 
                            ? cold0 : cold1);
           else
@@ -1472,7 +1545,9 @@
   if(failsafe<0){ failsafe= -failsafe; }
 
   while (i > 0 && (failsafe--) > 0) {
-    get_random_map_position_from_state(&x, &y, pstate);
+    get_random_nat_position_from_state(&x, &y, pstate);
+    native_to_map_pos(&x, &y, x, y);
+
     if (map_get_continent(x, y) == pstate->isleindex &&
        map_get_terrain(x, y) == T_GRASSLAND) {
 
@@ -1504,14 +1579,18 @@
 static bool place_island(struct gen234_state *pstate)
 {
   int x, y, xo, yo, i=0;
+
   rand_map_pos(&xo, &yo);
+  map_to_native_pos(&xo, &yo, xo, yo);
 
   /* this helps a lot for maps with high landmass */
   for (y = pstate->n, x = pstate->w; y < pstate->s && x < pstate->e;
        y++, x++) {
-    int map_x = x + xo - pstate->w;
-    int map_y = y + yo - pstate->n;
+    int map_x, map_y;
 
+    native_to_map_pos(&map_x, &map_y,
+                     x + xo - pstate->w, y + yo - pstate->n);
+
     if (!normalize_map_pos(&map_x, &map_y))
       return FALSE;
     if (hmap(x, y) != 0 && is_coastline(map_x, map_y))
@@ -1520,8 +1599,10 @@
                       
   for (y = pstate->n; y < pstate->s; y++) {
     for (x = pstate->w; x < pstate->e; x++) {
-      int map_x = x + xo - pstate->w;
-      int map_y = y + yo - pstate->n;
+      int map_x, map_y;
+
+      native_to_map_pos(&map_x, &map_y,
+                       x + xo - pstate->w, y + yo - pstate->n);
 
       if (!normalize_map_pos(&map_x, &map_y))
        return FALSE;
@@ -1532,11 +1613,13 @@
 
   for (y = pstate->n; y < pstate->s; y++) {
     for (x = pstate->w; x < pstate->e; x++) {
-      if (hmap(x, y) != 0) {
-       int map_x = x + xo - pstate->w;
-       int map_y = y + yo - pstate->n;
+      if (hnat(x, y) != 0) {
+       int map_x, map_y;
        bool is_real;
 
+       native_to_map_pos(&map_x, &map_y,
+                         x + xo - pstate->w, y + yo - pstate->n);
+
        is_real = normalize_map_pos(&map_x, &map_y);
        assert(is_real);
 
@@ -1571,17 +1654,17 @@
   memset(height_map, '\0', sizeof(int) * map.xsize * map.ysize);
   y = map.ysize / 2;
   x = map.xsize / 2;
-  hmap(x, y) = 1;
+  hnat(x, y) = 1;
   pstate->n = y - 1;
   pstate->w = x - 1;
   pstate->s = y + 2;
   pstate->e = x + 2;
   i = islemass - 1;
   while (i > 0 && tries-->0) {
-    get_random_map_position_from_state(&x, &y, pstate);
-    if (hmap(x, y) == 0 && (hmap(x + 1, y) != 0 || hmap(x - 1, y) != 0 ||
-                           hmap(x, y + 1) != 0 || hmap(x, y - 1) != 0)) {
-      hmap(x, y) = 1;
+    get_random_nat_position_from_state(&x, &y, pstate);
+    if (hnat(x, y) == 0 && (hnat(x + 1, y) != 0 || hnat(x - 1, y) != 0 ||
+                           hnat(x, y + 1) != 0 || hnat(x, y - 1) != 0)) {
+      hnat(x, y) = 1;
       i--;
       if (y >= pstate->s - 1 && pstate->s < map.ysize - 2) pstate->s++;
       if (x >= pstate->e - 1 && pstate->e < map.xsize - 2) pstate->e++;
@@ -1591,10 +1674,10 @@
     if (i < islemass / 10) {
       for (y = pstate->n; y < pstate->s; y++) {
        for (x = pstate->w; x < pstate->e; x++) {
-         if (hmap(x, y) == 0 && i > 0
-             && (hmap(x + 1, y) != 0 && hmap(x - 1, y) != 0
-                 && hmap(x, y + 1) != 0 && hmap(x, y - 1) != 0)) {
-           hmap(x, y) = 1;
+         if (hnat(x, y) == 0 && i > 0
+             && (hnat(x + 1, y) != 0 && hnat(x - 1, y) != 0
+                 && hnat(x, y + 1) != 0 && hnat(x, y - 1) != 0)) {
+           hnat(x, y) = 1;
             i--; 
           }
        }
@@ -1749,33 +1832,36 @@
 **************************************************************************/
 static void initworld(struct gen234_state *pstate)
 {
-  int x, y;
+  int xn, yn, x, y;
   
   height_map = fc_malloc(sizeof(int) * map.ysize * map.xsize);
   islands = fc_malloc((MAP_NCONT+1)*sizeof(struct isledata));
   
-  for (y = 0 ; y < map.ysize ; y++) 
-    for (x = 0 ; x < map.xsize ; x++) {
+  for (yn = 0 ; yn < map.ysize ; yn++) 
+    for (xn = 0 ; xn < map.xsize ; xn++) {
+      native_to_map_pos(&x, &y, xn, yn);
       map_set_terrain(x, y, T_OCEAN);
       map_set_continent(x, y, 0);
       map_clear_all_specials(x, y);
       map_set_owner(x, y, NULL);
     }
   if (has_poles) {
-    for (x = 0; x < map.xsize; x++) {
-      map_set_terrain(x, 0, myrand(9) > 0 ? T_ARCTIC : T_TUNDRA);
-      map_set_continent(x, 0, 1);
+    for (xn = 0; xn < map.xsize; xn++) {
+      native_to_map_pos(&x, &y, xn, 0);
+      map_set_terrain(x, y, myrand(9) > 0 ? T_ARCTIC : T_TUNDRA);
+      map_set_continent(x, y, 1);
       if (myrand(9) == 0) {
-       map_set_terrain(x, 1, myrand(9) > 0 ? T_TUNDRA : T_ARCTIC);
-       map_set_continent(x, 1, 1);
-      }
-      map_set_terrain(x, map.ysize - 1,
-                     myrand(9) > 0 ? T_ARCTIC : T_TUNDRA);
-      map_set_continent(x, map.ysize - 1, 2);
+       native_to_map_pos(&x, &y, xn, 1);
+       map_set_terrain(x, y, myrand(9) > 0 ? T_TUNDRA : T_ARCTIC);
+       map_set_continent(x, y, 1);
+      }
+      native_to_map_pos(&x, &y, xn, map.ysize - 1);
+      map_set_terrain(x, y, myrand(9) > 0 ? T_ARCTIC : T_TUNDRA);
+      map_set_continent(x, y, 2);
       if (myrand(9) == 0) {
-       map_set_terrain(x, map.ysize - 2,
-                       myrand(9) > 0 ? T_TUNDRA : T_ARCTIC);
-       map_set_continent(x, map.ysize - 2, 2);
+       native_to_map_pos(&x, &y, xn, map.ysize - 2);
+       map_set_terrain(x, y, myrand(9) > 0 ? T_TUNDRA : T_ARCTIC);
+       map_set_continent(x, y, 2);
       }
     }
     map.num_continents = 2;
@@ -2049,31 +2135,31 @@
   if (y1 == map.ysize)
     y1wrap = 0;
 
-  val[0][0] = hmap(x0, y0);
-  val[0][1] = hmap(x0, y1wrap);
-  val[1][0] = hmap(x1wrap, y0);
-  val[1][1] = hmap(x1wrap, y1wrap);
+  val[0][0] = hnat(x0, y0);
+  val[0][1] = hnat(x0, y1wrap);
+  val[1][0] = hnat(x1wrap, y0);
+  val[1][1] = hnat(x1wrap, y1wrap);
 
   /* set midpoints of sides to avg of side's vertices plus a random factor */
   /* unset points are zero, don't reset if set */
-  if (hmap((x0 + x1)/2, y0) == 0) {
-    hmap((x0 + x1)/2, y0) = (val[0][0] + val[1][0])/2 + myrand(step) - step/2;
+  if (hnat((x0 + x1)/2, y0) == 0) {
+    hnat((x0 + x1)/2, y0) = (val[0][0] + val[1][0])/2 + myrand(step) - step/2;
   }
-  if (hmap((x0 + x1)/2, y1wrap) == 0) {
-    hmap((x0 + x1)/2, y1wrap) = (val[0][1] + val[1][1])/2 
+  if (hnat((x0 + x1)/2, y1wrap) == 0) {
+    hnat((x0 + x1)/2, y1wrap) = (val[0][1] + val[1][1])/2 
       + myrand(step)- step/2;
   }
-  if (hmap(x0, (y0 + y1)/2) == 0) {
-    hmap(x0, (y0 + y1)/2) = (val[0][0] + val[0][1])/2 + myrand(step) - step/2;
+  if (hnat(x0, (y0 + y1)/2) == 0) {
+    hnat(x0, (y0 + y1)/2) = (val[0][0] + val[0][1])/2 + myrand(step) - step/2;
   }
-  if (hmap(x1wrap, (y0 + y1)/2) == 0) {
-    hmap(x1wrap, (y0 + y1)/2) = (val[1][0] + val[1][1])/2 
+  if (hnat(x1wrap, (y0 + y1)/2) == 0) {
+    hnat(x1wrap, (y0 + y1)/2) = (val[1][0] + val[1][1])/2 
       + myrand(step) - step/2;
   }
 
   /* set middle to average of midpoints plus a random factor, if not set */
-  if (hmap((x0 + x1)/2, (y0 + y1)/2) == 0) {
-    hmap((x0 + x1)/2, (y0 + y1)/2) = (val[0][0] + val[0][1] + val[1][0] 
+  if (hnat((x0 + x1)/2, (y0 + y1)/2) == 0) {
+    hnat((x0 + x1)/2, (y0 + y1)/2) = (val[0][0] + val[0][1] + val[1][0] 
                                      + val[1][1])/4 + myrand(step) - step/2;
   }
 
@@ -2126,7 +2212,7 @@
   /* set initial points */
   for (x = 0; x < xdiv2; x++) {
     for (y = 0; y < ydiv2; y++) {
-      hmap(x * xmax / xdiv, y * ymax / ydiv) =  myrand(2*step) - (2*step)/2;
+      hnat(x * xmax / xdiv, y * ymax / ydiv) =  myrand(2*step) - (2*step)/2;
     }
   }
 
@@ -2134,26 +2220,26 @@
      even harder to avoid the edges naturally if separatepoles is true */
   if (xnowrap) {
     for (y = 0; y < ydiv2; y++) {
-      hmap(0, y * ymax / ydiv) -= avoidedge;
-      hmap(xmax, y * ymax / ydiv) -= avoidedge;
+      hnat(0, y * ymax / ydiv) -= avoidedge;
+      hnat(xmax, y * ymax / ydiv) -= avoidedge;
       if (map.separatepoles && has_poles) {
-       hmap(2, y * ymax / ydiv) = hmap(0, y * ymax / ydiv) 
+       hnat(2, y * ymax / ydiv) = hnat(0, y * ymax / ydiv) 
                                                        - myrand(3*avoidedge);
-       hmap(xmax - 2, y * ymax / ydiv) 
-                         = hmap(xmax, y * ymax / ydiv) - myrand(3*avoidedge);
+       hnat(xmax - 2, y * ymax / ydiv) 
+                         = hnat(xmax, y * ymax / ydiv) - myrand(3*avoidedge);
       }
     }
   }
 
   if (ynowrap) {
     for (x = 0; x < xdiv2; x++) {
-      hmap(x * xmax / xdiv, 0) -= avoidedge;
-      hmap(x * xmax / xdiv, ymax) -= avoidedge;
+      hnat(x * xmax / xdiv, 0) -= avoidedge;
+      hnat(x * xmax / xdiv, ymax) -= avoidedge;
       if (map.separatepoles && has_poles) {
-       hmap(x * xmax / xdiv, 2) = hmap(x * xmax / xdiv, 0) 
+       hnat(x * xmax / xdiv, 2) = hnat(x * xmax / xdiv, 0) 
                                                        - myrand(3*avoidedge);
-       hmap(x * xmax / xdiv, ymax - 2) 
-                         = hmap(x * xmax / xdiv, ymax) - myrand(3*avoidedge);
+       hnat(x * xmax / xdiv, ymax - 2) 
+                         = hnat(x * xmax / xdiv, ymax) - myrand(3*avoidedge);
       }
     }
   }
@@ -2172,8 +2258,8 @@
   } whole_map_iterate_end;
 
   /* and calibrate maxval and minval */
-  maxval = hmap(0, 0);
-  minval = hmap(0, 0);
+  maxval = hnat(0, 0);
+  minval = hnat(0, 0);
   whole_map_iterate(x, y) {
     maxval = MAX(maxval, hmap(x, y));
     minval = MIN(minval, hmap(x, y));

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