Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2004:
[Freeciv-Dev] (PR#9918) create a pleced map and rename map_temperature h
Home

[Freeciv-Dev] (PR#9918) create a pleced map and rename map_temperature h

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9918) create a pleced map and rename map_temperature has map_lattitude
From: "Marcelo Burda via RT" <mburda@xxxxxxxxx>
Date: Fri, 3 Sep 2004 05:39:42 -0700
Reply-to: RT_CorrespondAddressNotSet@xxxxxxxxxxxxxx

<URL: http://RT::WebBaseURL.not.configured:80/Ticket/Display.html?id=9918 >

Hi,
uset T_NOT_PLACED was a good idea but is not very different to the old
system.

experience working in generator show me this system for not_placed() is
not a good one.

I create a placed_map, and some tool macreos and fucntions has
create_placed_map, remove_placed_map, map_set_placed, map_unset_placed
to work in a clear with on these map.

this is used to place terrains and hut.

i am rewrited map_temperature and others related functions to wotk with
it and rename it as map_lattitude, has a temeperature map will be created.

i am a ready patch for temperature map a this do very nice things.

this patch is a important patch has all generators patch will depends!!

Marcelo
diff -ruN -Xfreeciv/diff_ignore freeciv/server/mapgen.c freeciv_/server/mapgen.c
--- freeciv/server/mapgen.c     2004-09-03 09:03:06.589841744 +0200
+++ freeciv_/server/mapgen.c    2004-09-03 12:33:29.272902240 +0200
@@ -54,6 +54,7 @@
 #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)])
+#define pmap(x, y) (placed_map[map_pos_to_index(x, y)])
 
 static void make_huts(int number);
 static void add_specials(int prob);
@@ -98,15 +99,8 @@
 };
 static struct isledata *islands;
 
-#define T_NOT_PLACED T_UNKNOWN
-
-/**************************************************************************
-  Checks if land has not yet been placed on tile at (x, y) 
- **************************************************************************/
-#define not_placed(x, y) (map_get_terrain(x, y) == T_NOT_PLACED)
-
-/* this is the maximal temperature at equators returned by map_temperature */
-#define MAX_TEMP 1000
+/* this is the maximal latitude at equators returned by map_latitude */
+#define MAX_LATITUDE 1000
 
 /* An estimate of the linear (1-dimensional) size of the map. */
 #define SQSIZE MAX(1, sqrt(map.xsize * map.ysize / 1000))
@@ -116,8 +110,8 @@
 #define ICE_BASE_LEVEL                                         \
   ((!topo_has_flag(TF_WRAPX) || !topo_has_flag(TF_WRAPY))      \
    /* 5% for little maps; 2% for big ones */                   \
-   ? MAX_TEMP * (3 + 2 * SQSIZE) / (100 * SQSIZE)              \
-   : 5 * MAX_TEMP / 100  /* 5% for all maps */)
+   ? MAX_LATITUDE * (3 + 2 * SQSIZE) / (100 * SQSIZE)          \
+   : 5 * MAX_LATITUDE / 100  /* 5% for all maps */)
 
 /****************************************************************************
   Used to initialize an array 'a' of size 'size' with value 'val' in each
@@ -133,10 +127,43 @@
   }
 
 /****************************************************************************
-  Returns the temperature of this map position.  This is a value in the
-  range of 0 to MAX_TEMP (inclusive).
+ * Placed map
+ * this can be used to many things, placed terrains on lands, placed huts, etc
+ ****************************************************************************/
+static bool *placed_map;
+
+/* 
+ * Create a clean pmap
+ */
+static void create_placed_map(void)
+{
+ placed_map = fc_malloc (sizeof(bool) * MAX_MAP_INDEX);
+ INITIALIZE_ARRAY(placed_map, MAX_MAP_INDEX, FALSE );
+}
+
+/*
+ * free the pmap
+ */
+static void remove_placed_map(void)
+{
+  free(placed_map);
+  placed_map = NULL;
+}
+/*
+ * Checks if land has not yet been placed on pmap at (x, y)
+ */
+#define not_placed(x, y) (!pmap((x), (y)))
+/*
+ * set has placed or not placed position in the pmap
+ */
+#define map_set_placed(x, y) (pmap((x), (y)) = TRUE)
+#define map_unset_placed(x, y) (pmap((x), (y)) = FALSE)
+
+/****************************************************************************
+  Returns the latitude of this map position.  This is a value in the
+  range of 0 to MAX_LATITUDE (inclusive).
 ****************************************************************************/
-static int map_temperature(int map_x, int map_y)
+static int map_latitude(int map_x, int map_y)
 {
   double x, y;
   
@@ -144,7 +171,7 @@
     /* An all-temperate map has "average" temperature everywhere.
      *
      * TODO: perhaps there should be a random temperature variation. */
-    return MAX_TEMP / 2;
+    return MAX_LATITUDE / 2;
   }
 
   do_in_natural_pos(ntl_x, ntl_y, map_x, map_y) {
@@ -154,7 +181,7 @@
        * We assume this is a partial planetary map.  A polar zone is placed
        * at the top and the equator is at the bottom.  The user can specify
        * all-temperate to avoid this. */
-      return MAX_TEMP * ntl_y / (NATURAL_HEIGHT - 1);
+      return MAX_LATITUDE * ntl_y / (NATURAL_HEIGHT - 1);
     }
 
     /* Otherwise a wrapping map is assumed to be a global planetary map. */
@@ -168,7 +195,7 @@
      * :c__c:
      * ......
      *
-     * C are the corners.  In all cases the 4 corners have equal temperature.
+     * C are the corners.  In all cases the 4 corners have equal latitude.
      * So we fold the map over in both directions and determine
      * x and y vars in the range [0.0, 1.0].
      *
@@ -193,7 +220,7 @@
   if (topo_has_flag(TF_WRAPX) && !topo_has_flag(TF_WRAPY)) {
     /* In an Earth-like topology the polar zones are at north and south.
      * This is equivalent to a Mercator projection. */
-    return MAX_TEMP * y;
+    return MAX_LATITUDE * y;
   }
   
   if (!topo_has_flag(TF_WRAPX) && topo_has_flag(TF_WRAPY)) {
@@ -201,7 +228,7 @@
      * This isn't really the way Uranus is; it's the way Earth would look
      * if you tilted your head sideways.  It's still a Mercator
      * projection. */
-    return MAX_TEMP * x;
+    return MAX_LATITUDE * x;
   }
 
   /* Otherwise we have a torus topology.  We set it up as an approximation
@@ -258,38 +285,35 @@
    *
    * This is explained more fully at
    * http://rt.freeciv.org/Ticket/Display.html?id=8624. */
-  return MAX_TEMP * (1.5 * (x * x * y + x * y * y) 
+  return MAX_LATITUDE * (1.5 * (x * x * y + x * y * y) 
                     - 0.5 * (x * x * x + y * y * y) 
                     + 1.5 * (x * x + y * y));
 }
 
 struct DataFilter {
-  int T_min, T_max;
-  Terrain_type_id terrain;
+  int L_min, L_max;
 };
 
 /****************************************************************************
   A filter function to be passed to rand_map_pos_filtered().  See
-  rand_map_pos_temperature for more explanation.
+  rand_map_pos_latitude for more explanation.
 ****************************************************************************/
-static bool temperature_filter(int map_x, int map_y, void *data)
+static bool latitude_filter(int map_x, int map_y, void *data)
 {
   struct DataFilter *filter = data;
-  const int T = map_temperature(map_x, map_y);
+  const int L = map_latitude(map_x, map_y);
 
-  return (T >= filter->T_min && T <= filter->T_max 
-         && (T_ANY == filter->terrain
-             || map_get_terrain(map_x, map_y) == filter->terrain));
+  return (L >= filter->L_min) && (L <= filter->L_max) 
+         && not_placed(map_x, map_y) ;
 }
 
 /****************************************************************************
-  Return random map coordinates which have temperature within the selected
-  range and which match the terrain choice (which may be T_ANY).  Returns
-  FALSE if there is no such position.
+  Return random map coordinates which have latitude within the selected
+  range and which are not yet placed. Returns FALSE if there is no such
+  position.
 ****************************************************************************/
-static bool rand_map_pos_temperature(int *map_x, int *map_y,
-                                    int T_min, int T_max,
-                                    Terrain_type_id terrain)
+static bool rand_map_pos_latitude(int *map_x, int *map_y,
+                                    int L_min, int L_max)
 {
   struct DataFilter filter;
 
@@ -298,10 +322,9 @@
    * extensible.  So instead we just go straight to the rand_map_pos_filtered
    * call. */
 
-  filter.T_min = T_min;
-  filter.T_max = T_max;
-  filter.terrain = terrain;
-  return rand_map_pos_filtered(map_x, map_y, &filter, temperature_filter);
+  filter.L_min = L_min;
+  filter.L_max = L_max;
+  return rand_map_pos_filtered(map_x, map_y, &filter, latitude_filter);
 }
 
 /****************************************************************************
@@ -332,10 +355,12 @@
       /* Randomly place hills and mountains on "high" tiles.  But don't
        * put hills near the poles (they're too green). */
       if (myrand(100) > 75 
-         || map_temperature(x, y) <= MAX_TEMP / 10) {
+         || map_latitude(x, y) <= MAX_LATITUDE / 10) {
        map_set_terrain(x, y, T_MOUNTAINS);
+       map_set_placed(x, y);
       } else if (myrand(100) > 25) {
        map_set_terrain(x, y, T_HILLS);
+       map_set_placed(x, y);
       }
     }
   } whole_map_iterate_end;
@@ -352,24 +377,29 @@
   int T;
 
   whole_map_iterate(map_x, map_y) {
-    T = map_temperature(map_x, map_y); /* temperature parameter */
+    T = map_latitude(map_x, map_y);    /* latitude parameter */
     ptile = map_get_tile(map_x, map_y);
     if (T < ICE_BASE_LEVEL) { /* get the coldest part of the map */
       if (ptile->terrain != T_MOUNTAINS) {
        ptile->terrain = T_ARCTIC;
+       map_set_placed(map_x, map_y);
       }
     } else if ((T <= 1.5 * ICE_BASE_LEVEL) 
               && (ptile->terrain == T_OCEAN) ) {  
       ptile->terrain = T_ARCTIC;
+      map_set_placed(map_x, map_y);
     } else if (T <= 2 * ICE_BASE_LEVEL) {
       if (ptile->terrain == T_OCEAN) {
        if (myrand(10) > 5) {
          ptile->terrain = T_ARCTIC;
+         map_set_placed(map_x, map_y);
        } else if (myrand(10) > 6) {
          ptile->terrain = T_TUNDRA;
+         map_set_placed(map_x, map_y);
        }
       } else if (myrand(10) > 0 && ptile->terrain != T_MOUNTAINS) {
        ptile->terrain = T_TUNDRA;
+       map_set_placed(map_x, map_y);
       }
     }
   } whole_map_iterate_end;
@@ -385,12 +415,14 @@
   int T;
 
   whole_map_iterate(map_x, map_y) {
-    T = map_temperature(map_x, map_y); /* temperature parameter */
+    T = map_latitude(map_x, map_y);    /* latitude parameter */
     ptile = map_get_tile(map_x, map_y);
     if (T < 1.5 * ICE_BASE_LEVEL) {
-      ptile->terrain = T_NOT_PLACED;
+      ptile->terrain = T_UNKNOWN;
+      map_unset_placed(map_x, map_y);
     } else if ((T <= 2 * ICE_BASE_LEVEL) && myrand(10) > 4 ) { 
-      ptile->terrain = T_NOT_PLACED;
+      ptile->terrain = T_UNKNOWN;
+      map_unset_placed(map_x, map_y);
     }
   } whole_map_iterate_end;
 }
@@ -403,11 +435,12 @@
 static void make_tundra(void)
 {
   whole_map_iterate(x, y) {
-    int T = map_temperature(x, y);
+    int T = map_latitude(x, y);
 
     if (not_placed(x,y) 
-       && (2 * ICE_BASE_LEVEL > T || myrand(MAX_TEMP/5) > T)) {
+       && (2 * ICE_BASE_LEVEL > T || myrand(MAX_LATITUDE/5) > T)) {
       map_set_terrain(x, y, T_TUNDRA);
+      map_set_placed(x, y);
     }
   } whole_map_iterate_end;
 }
@@ -418,12 +451,13 @@
 static void make_arctic(void)
 {
   whole_map_iterate(x, y) {
-    int T = map_temperature(x, y);
+    int T = map_latitude(x, y);
 
     if (not_placed(x,y) 
-       && myrand(15 * MAX_TEMP / 100) > T -  ICE_BASE_LEVEL 
+       && myrand(15 * MAX_LATITUDE / 100) > T -  ICE_BASE_LEVEL 
        && T <= 3 * ICE_BASE_LEVEL) {
       map_set_terrain(x, y, T_ARCTIC);
+      map_set_placed(x, y);
     }
   } whole_map_iterate_end;
 }
@@ -436,18 +470,19 @@
   is made.  It is reduced more if the desert wants to grow in north or
   south (so we end up with "wide" deserts).
 
-  base_T is the temperature of the original desert.
+  base_T is the latitude of the original desert.
 **************************************************************************/
 static void make_desert(int x, int y, int height, int diff, int base_T)
 {
-  const int DeltaT = MAX_TEMP / (3 * SQSIZE);
+  const int DeltaT = MAX_LATITUDE / (3 * SQSIZE);
 
   if (abs(hmap(x, y) - height) < diff 
       && not_placed(x,y)) {
     map_set_terrain(x, y, T_DESERT);
+    map_set_placed(x, y);
     cardinal_adjc_iterate(x, y, x1, y1) {
       make_desert(x1, y1, height,
-                 diff - 1 - abs(map_temperature(x1, y1) - base_T) / DeltaT,
+                 diff - 1 - abs(map_latitude(x1, y1) - base_T) / DeltaT,
                  base_T);
      
     } cardinal_adjc_iterate_end;
@@ -462,17 +497,15 @@
 **************************************************************************/
 static void make_forest(int map_x, int map_y, int height, int diff)
 {
-  int nat_x, nat_y, T;
-
-  MAP_TO_NATIVE_POS(&nat_x, &nat_y, map_x, map_y);
-  T = map_temperature(map_x, map_y);
+  int T = map_latitude(map_x, map_y);
   if (not_placed(map_x, map_y)) {
-    if (T > 8 * MAX_TEMP / 10 
-       && myrand(1000) > 500 - 300 * (T * 1000 / MAX_TEMP - 800)) {
+    if (T > 8 * MAX_LATITUDE / 10 
+       && myrand(1000) > 500 - 300 * (T * 1000 / MAX_LATITUDE - 800)) {
       map_set_terrain(map_x, map_y, T_JUNGLE);
     } else {
       map_set_terrain(map_x, map_y, T_FOREST);
     }
+    map_set_placed(map_x, map_y);
     if (abs(hmap(map_x, map_y) - height) < diff) {
       cardinal_adjc_iterate(map_x, map_y, x1, y1) {
        if (myrand(10) > 5) {
@@ -497,27 +530,24 @@
 
   do {
     /* Place one forest clump anywhere. */
-    if (rand_map_pos_temperature(&x, &y,
-                                MAX_TEMP / 10, MAX_TEMP,
-                                T_NOT_PLACED)) {
+    if (rand_map_pos_latitude(&x, &y,
+                                MAX_LATITUDE / 10, MAX_LATITUDE)) {
       make_forest(x, y, hmap(x, y), 25);
     } else { 
-      /* If rand_map_pos_temperature returns FALSE we may as well stop
+      /* If rand_map_pos_latitude returns FALSE we may as well stop
        * looking. */
       break;
     }
 
-    /* Now add another tropical forest clump (70-100% temperature). */
-    if (rand_map_pos_temperature(&x, &y,
-                                7 *MAX_TEMP / 10, MAX_TEMP,
-                                T_NOT_PLACED)) {
+    /* Now add another tropical forest clump (70-100% latitude). */
+    if (rand_map_pos_latitude(&x, &y,
+                                7 *MAX_LATITUDE / 10, MAX_LATITUDE)) {
       make_forest(x, y, hmap(x, y), 25);
     }
 
-    /* And add a cold forest clump (10%-30% temperature). */
-    if (rand_map_pos_temperature(&x, &y,
-                                1 * MAX_TEMP / 10, 3 * MAX_TEMP / 10,
-                                T_NOT_PLACED)) {
+    /* And add a cold forest clump (10%-30% latitude). */
+    if (rand_map_pos_latitude(&x, &y,
+                1 * MAX_LATITUDE / 10, 3 * MAX_LATITUDE / 10)) {
       make_forest(x, y, hmap(x, y), 25);
     }
   } while (forests < forestsize);
@@ -547,10 +577,11 @@
     if (not_placed(x, y)
        && hmap(x, y) < hmap_swamp_level) {
       map_set_terrain(x, y, T_SWAMP);
+      map_set_placed(x, y);
       cardinal_adjc_iterate(x, y, x1, y1) {
-       if (myrand(10) > 5 && !is_ocean(map_get_terrain(x1, y1)) 
-           && map_get_terrain(x1, y1) != T_SWAMP ) { 
+       if (myrand(10) > 5 && not_placed(x1, y1)) { 
          map_set_terrain(x1, y1, T_SWAMP);
+         map_set_placed(x1, y1);
          swamps++;
        }
       } cardinal_adjc_iterate_end;
@@ -575,13 +606,12 @@
     /* Choose a random coordinate between 20 and 30 degrees north/south
      * (deserts tend to be between 15 and 35; make_desert will expand
      * them). */
-    if (rand_map_pos_temperature(&x, &y,
-                                65 * MAX_TEMP / 100, 80 * MAX_TEMP / 100,
-                                T_NOT_PLACED)){
-      make_desert(x, y, hmap(x, y), 50, map_temperature(x, y));
+    if (rand_map_pos_latitude(&x, &y,
+          65 * MAX_LATITUDE / 100, 80 * MAX_LATITUDE / 100)){
+      make_desert(x, y, hmap(x, y), 50, map_latitude(x, y));
       i--;
     } else {
-      /* If rand_map_pos_temperature returns FALSE we may as well stop
+      /* If rand_map_pos_latitude returns FALSE we may as well stop
        * looking. */
       break;
     }
@@ -841,7 +871,7 @@
     if (adjacent_river_tiles4(x, y) != 0
        || count_ocean_near_tile(x, y, TRUE) != 0
         || (map_get_terrain(x, y) == T_ARCTIC 
-           && map_temperature(x, y) < 8 * MAX_TEMP / 100)) { 
+           && map_latitude(x, y) < 8 * MAX_LATITUDE / 100)) { 
 
       freelog(LOG_DEBUG,
              "The river ended at (%d, %d).\n", x, y);
@@ -1066,6 +1096,7 @@
       } else {
          map_set_terrain(x, y, T_PLAINS);
       }
+      map_set_placed(x, y);
     }
   } whole_map_iterate_end;
 }
@@ -1118,13 +1149,13 @@
   whole_map_iterate(x, y) {
     if (near_singularity(x, y)) {
       hmap(x, y) = 0;
-    } else if (map_temperature(x, y) < 2 * ICE_BASE_LEVEL) {
-      hmap(x, y) *= map_temperature(x, y) / (2.5 * ICE_BASE_LEVEL);
+    } else if (map_latitude(x, y) < 2 * ICE_BASE_LEVEL) {
+      hmap(x, y) *= map_latitude(x, y) / (2.5 * ICE_BASE_LEVEL);
     } else if (map.separatepoles 
-              && map_temperature(x, y) <= 2.5 * ICE_BASE_LEVEL) {
+              && map_latitude(x, y) <= 2.5 * ICE_BASE_LEVEL) {
       hmap(x, y) *= 0.1;
-    } else if (map_temperature(x, y) <= 2.5 * ICE_BASE_LEVEL) {
-      hmap(x, y) *= map_temperature(x, y) / (2.5 * ICE_BASE_LEVEL);
+    } else if (map_latitude(x, y) <= 2.5 * ICE_BASE_LEVEL) {
+      hmap(x, y) *= map_latitude(x, y) / (2.5 * ICE_BASE_LEVEL);
     }
   } whole_map_iterate_end;
 }
@@ -1136,15 +1167,15 @@
 static void renormalize_hmap_poles(void)
 {
   whole_map_iterate(x, y) {
-    if (hmap(x, y) == 0 || map_temperature(x, y) == 0) {
+    if (hmap(x, y) == 0 || map_latitude(x, y) == 0) {
       /* Nothing. */
-    } else if (map_temperature(x, y) < 2 * ICE_BASE_LEVEL) {
-      hmap(x, y) *= (2.5 * ICE_BASE_LEVEL) / map_temperature(x, y);
+    } else if (map_latitude(x, y) < 2 * ICE_BASE_LEVEL) {
+      hmap(x, y) *= (2.5 * ICE_BASE_LEVEL) / map_latitude(x, y);
     } else if (map.separatepoles 
-              && map_temperature(x, y) <= 2.5 * ICE_BASE_LEVEL) {
+              && map_latitude(x, y) <= 2.5 * ICE_BASE_LEVEL) {
       hmap(x, y) *= 10;
-    } else if (map_temperature(x, y) <= 2.5 * ICE_BASE_LEVEL) {
-      hmap(x, y) *= (2.5 * ICE_BASE_LEVEL) /  map_temperature(x, y);
+    } else if (map_latitude(x, y) <= 2.5 * ICE_BASE_LEVEL) {
+      hmap(x, y) *= (2.5 * ICE_BASE_LEVEL) /  map_latitude(x, y);
     }
   } whole_map_iterate_end;
 }
@@ -1156,14 +1187,15 @@
 **************************************************************************/
 static void make_land(void)
 {
+  create_placed_map(); /* there means land terrains to be placed */
   adjust_hmap();
   normalize_hmap_poles();
   hmap_shore_level = (hmap_max_level * (100 - map.landpercent)) / 100;
   whole_map_iterate(x, y) {
+    map_set_terrain(x, y, T_UNKNOWN); /* set as oceans count is used */
     if (hmap(x, y) < hmap_shore_level) {
       map_set_terrain(x, y, T_OCEAN);
-    } else {
-      map_set_terrain(x, y, T_NOT_PLACED);
+      map_set_placed(x, y); /*placed, not a land target */
     }
   } whole_map_iterate_end;
 
@@ -1178,7 +1210,7 @@
   make_plains();
   make_fair();
   make_rivers();
-
+  remove_placed_map();
   assign_continent_numbers();
 }
 
@@ -1287,7 +1319,7 @@
       /* (x1,y1) is possible location of a future city which will
        * be able to get benefit of the tile (x,y) */
       if (is_ocean(map_get_terrain(x1, y1)) 
-         || map_temperature(x1, y1) <= 2 * ICE_BASE_LEVEL) { 
+         || map_latitude(x1, y1) <= 2 * ICE_BASE_LEVEL) { 
        /* Not land, or too cold. */
         continue;
       }
@@ -1707,7 +1739,7 @@
     rand_map_pos(&x, &y);
 
     if (near_singularity(x, y)
-       || map_temperature(x, y) <= ICE_BASE_LEVEL / 2) { 
+       || map_latitude(x, y) <= ICE_BASE_LEVEL / 2) { 
       /* Avoid land near singularities or at the poles. */
       hmap(x, y) -= myrand(5000);
     } else { 
@@ -1770,15 +1802,11 @@
   Return TRUE iff there's already a hut within 3 tiles of the given map
   position.
 ****************************************************************************/
-static bool is_hut_close(int map_x, int map_y)
+static void set_placed_close_hut(int map_x, int map_y)
 {
   square_iterate(map_x, map_y, 3, x1, y1) {
-    if (map_has_special(x1, y1, S_HUT)) {
-      return TRUE;
-    }
+    map_set_placed(x1, y1);
   } square_iterate_end;
-
-  return FALSE;
 }
 
 /****************************************************************************
@@ -1804,21 +1832,27 @@
 {
   int x, y, count = 0;
 
+  create_placed_map(); /* there means placed huts */
+
   while (number * map_num_tiles() >= 2000 && count++ < map_num_tiles() * 2) {
 
     /* Add a hut.  But not on a polar area, on an ocean, or too close to
      * another hut. */
-    if (rand_map_pos_temperature(&x, &y,
-                                2 * ICE_BASE_LEVEL, MAX_TEMP, T_ANY)
-       && !is_ocean(map_get_terrain(x, y))
-       && !is_hut_close(x, y)) {
-      number--;
-      map_set_special(x, y, S_HUT);
-      /* Don't add to islands[].goodies because islands[] not
-        setup at this point, except for generator>1, but they
-        have pre-set starters anyway. */
+    if (rand_map_pos_latitude(&x, &y,
+                                2 * ICE_BASE_LEVEL, MAX_LATITUDE)) {
+      if(is_ocean(map_get_terrain(x, y))) {
+       map_set_placed(x, y); /* not good for a hut */
+      } else {
+       number--;
+       map_set_special(x, y, S_HUT);
+       set_placed_close_hut(x, y);
+           /* Don't add to islands[].goodies because islands[] not
+              setup at this point, except for generator>1, but they
+              have pre-set starters anyway. */
+      }
     }
   }
+  remove_placed_map();
 }
 
 /****************************************************************************
@@ -1881,7 +1915,7 @@
 
 static bool map_pos_is_cold(int x, int y)
 {  
-  return map_temperature(x, y) <= 2 * MAX_TEMP/ 10;
+  return map_latitude(x, y) <= 2 * MAX_LATITUDE/ 10;
 }
 
 /**************************************************************************
@@ -1955,10 +1989,12 @@
          map_set_terrain(x, y, (myrand(cold0_weight
                                        + cold1_weight) < cold0_weight) 
                          ? cold0 : cold1);
+         map_set_placed(x, y);
        } else {
          map_set_terrain(x, y, (myrand(warm0_weight
                                        + warm1_weight) < warm0_weight) 
                          ? warm0 : warm1);
+         map_set_placed(x, y);
        }
       }
       if (!not_placed(x,y)) i--;
@@ -2094,7 +2130,9 @@
          return i != 0;
        }
 
-        map_set_terrain(map_x, map_y, T_NOT_PLACED);
+        map_set_terrain(map_x, map_y, T_UNKNOWN);
+       map_unset_placed(map_x, map_y);
+
        map_set_continent(map_x, map_y, pstate->isleindex);
         i++;
       }
@@ -2318,10 +2356,11 @@
   int i;
   height_map = fc_malloc(sizeof(int) * map.ysize * map.xsize);
   islands = fc_malloc((MAP_NCONT+1)*sizeof(struct isledata));
-
+  create_placed_map(); /* not yet placed land tiles */
   whole_map_iterate(x, y) {
     map_set_terrain(x, y, T_OCEAN);
     map_set_continent(x, y, 0);
+    map_set_placed(x, y); /* not a land tile */
     map_clear_all_specials(x, y);
     map_set_owner(x, y, NULL);
   } whole_map_iterate_end;
@@ -2415,6 +2454,7 @@
   }
 
   make_plains();  
+  remove_placed_map();
   free(height_map);
   height_map = NULL;
 
@@ -2502,6 +2542,7 @@
   }
 
   make_plains();  
+  remove_placed_map();
   free(height_map);
   height_map = NULL;
     
@@ -2569,6 +2610,7 @@
     make_island(10 * pstate->totalmass / totalweight, 0, pstate, DMSIS);
   }
   make_plains();  
+  remove_placed_map();
   free(height_map);
   height_map = NULL;
 
@@ -2612,7 +2654,7 @@
 #define set_midpoints(X, Y, V)                                         \
   do_in_map_pos(map_x, map_y, (X), (Y)) {                               \
     if (!near_singularity(map_x, map_y)                                        
\
-       && map_temperature(map_x, map_y) >  ICE_BASE_LEVEL/2            \
+       && map_latitude(map_x, map_y) >  ICE_BASE_LEVEL/2               \
        && hnat((X), (Y)) == 0) {                                       \
       hnat((X), (Y)) = (V);                                            \
     }                                                                  \
@@ -2692,7 +2734,7 @@
          hmap(x, y) -= avoidedge;
        }
 
-       if (map_temperature(x, y) <= ICE_BASE_LEVEL / 2 ) {
+       if (map_latitude(x, y) <= ICE_BASE_LEVEL / 2 ) {
          /* separate poles and avoid too much land at poles */
          hmap(x, y) -= myrand(avoidedge);
        }

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