Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2004:
[Freeciv-Dev] (PR#9876) PATCH temperature parameters for Earth like gene
Home

[Freeciv-Dev] (PR#9876) PATCH temperature parameters for Earth like gene

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9876) PATCH temperature parameters for Earth like generators 1,5
From: "Marcelo Burda via RT" <mburda@xxxxxxxxx>
Date: Tue, 7 Sep 2004 14:29:00 -0700
Reply-to: RT_CorrespondAddressNotSet@xxxxxxxxxxxxxx

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

after commit 9627 this is the next one

LAST CHANGE;
updated, temperature_map included

Marcelo
diff -ruN -Xfreeciv/diff_ignore freeciv__/common/map.c freeciv_/common/map.c
--- freeciv__/common/map.c      2004-09-07 16:39:44.241572088 +0200
+++ freeciv_/common/map.c       2004-09-07 18:24:29.488069384 +0200
@@ -207,6 +207,7 @@
   map.tinyisles             = MAP_DEFAULT_TINYISLES;
   map.separatepoles         = MAP_DEFAULT_SEPARATE_POLES;
   map.alltemperate          = MAP_DEFAULT_ALLTEMPERATE;
+  map.temperature           = MAP_DEFAULT_TEMPERATURE;
   map.tiles                 = NULL;
   map.num_continents        = 0;
   map.num_oceans            = 0;
diff -ruN -Xfreeciv/diff_ignore freeciv__/common/map.h freeciv_/common/map.h
--- freeciv__/common/map.h      2004-09-07 16:39:44.241572088 +0200
+++ freeciv_/common/map.h       2004-09-07 18:24:29.493068624 +0200
@@ -173,6 +173,7 @@
   bool tinyisles;
   bool separatepoles;
   bool alltemperate;
+  int temperature;
   int num_start_positions;
   bool have_specials;
   bool have_huts;
@@ -675,6 +676,9 @@
 #define MAP_MIN_ALLTEMPERATE       FALSE
 #define MAP_MAX_ALLTEMPERATE       TRUE
 
+#define MAP_DEFAULT_TEMPERATURE   50
+#define MAP_MIN_TEMPERATURE       0
+#define MAP_MAX_TEMPERATURE       100
 
 /*
  * Inline function definitions.  These are at the bottom because they may use
Les fichiers freeciv__/manual/civmanual et freeciv_/manual/civmanual sont 
différents.
diff -ruN -Xfreeciv/diff_ignore freeciv__/server/mapgen.c 
freeciv_/server/mapgen.c
--- freeciv__/server/mapgen.c   2004-09-07 16:39:44.923468424 +0200
+++ freeciv_/server/mapgen.c    2004-09-07 21:27:06.470354888 +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 tmap(x, y) (temperature_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);
@@ -64,7 +65,7 @@
 static void mapgenerator4(void);
 static void mapgenerator5(void);
 static void smooth_map(void);
-static void adjust_hmap(void);
+static void adjust_int_map(int *int_map, int int_map_max);
 static void adjust_terrain_param(void);
 
 #define RIVERS_MAXTRIES 32767
@@ -91,13 +92,35 @@
 static const int hmap_max_level = 1000;
 static int hmap_shore_level, hmap_mountain_level;
 
+/*
+ *  temperature_map[] stores the temperature of each tile
+ *  the temperature values are basically 4:
+ *  TT_FRIZZED, TT_COLD, TT_TEMPERATE, TT_TROPICAL
+ *  but for coding separatepoles i split FRIZZED in 3
+ *  TT_FRIZZED1, TT_FRIZZED2, TT_FRIZZED3 
+ *  values on tmap can get one of these 6 values
+ *  there is 5 extra values as macros combining these 6 basics ones
+ */
+typedef enum {
+    TT_FRIZZED1 = 1 , TT_FRIZZED2 = 2, TT_FRIZZED3 = 4,
+    TT_COLD = 8, TT_TEMPERATE = 16, TT_TROPICAL = 32
+} temperature_type;
+#define TT_NFRIZZED (TT_COLD | TT_TEMPERATE | TT_TROPICAL)
+#define TT_FRIZZED  (TT_FRIZZED1 | TT_FRIZZED2 | TT_FRIZZED3)
+#define TT_ALL (TT_FRIZZED | TT_NFRIZZED)
+#define TT_NHOT (TT_FRIZZED | TT_COLD)
+#define TT_HOT (TT_TEMPERATE, TT_TROPICAL)
+static int *temperature_map;
+#define tmap_is(x, y, tt) (BOOL_VAL(tmap((x), (y)) & (tt)))
+
 struct isledata {
   int goodies;
   int starters;
 };
 static struct isledata *islands;
 
-/* this is the maximal temperature at equators returned by map_temperature */
+/* this is the maximal temperature at equators returned by  but 
+   map_colatitude and tmap */
 #define MAX_TEMP 1000
 
 /* An estimate of the linear (1-dimensional) size of the map. */
@@ -117,18 +140,26 @@
    and a dry region, this last one can ovelap others 
    DRY_MIN_LEVEL- DRY_MAX_LEVEL
  */
-#define COLD_LEVEL (10 * MAX_TEMP / 100)
-#define TROPICAL_LEVEL (70 * MAX_TEMP / 100)
-#define DRY_MIN_LEVEL (65 * MAX_TEMP / 100)
-#define DRY_MAX_LEVEL (80 * MAX_TEMP / 100)
+#define COLD_LEVEL \
+ (MAX(0,        MAX_TEMP * (60*7 - map.temperature * 6 ) / 700))
+#define TROPICAL_LEVEL\
+ (MIN(MAX_TEMP, MAX_TEMP * (143*7 - map.temperature * 10) / 700))
+#define DRY_MIN_LEVEL (MAX_TEMP * (7300 - map.temperature * 18 ) / 10000)
+#define DRY_MAX_LEVEL (MAX_TEMP * (7300 + map.temperature * 17 ) / 10000)
 
 /* used to create the poles and for separating them.  In a
  * mercator projection map we don't want the poles to be too big. */
 #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)              \
-   : COLD_LEVEL / 2  /* for all maps */)
+   /* 5% for little maps; 2% for big ones, if map.temperature == 50 */\
+   ? (MAX(0, 100 * COLD_LEVEL / 3 - 2 *  MAX_TEMP) + 2 *  MAX_TEMP * SQSIZE)\
+      / (100 * SQSIZE)                                               \
+   : COLD_LEVEL / 3  /* for all maps */)
+/*
+ * at some map.temperature there is no more poles at all
+ * COLD_LEVEL > 0 if HAS_POLES
+ */
+#define HAS_POLES (map.temperature < 70 && !map.alltemperate  )
 
 /****************************************************************************
   Used to initialize an array 'a' of size 'size' with value 'val' in each
@@ -164,6 +195,7 @@
 ****************************************************************************/
 static void destroy_placed_map(void)
 {
+  assert( placed_map != NULL);
   free(placed_map);
   placed_map = NULL;
 }
@@ -189,7 +221,7 @@
   Returns the temperature of this map position.  This is a value in the
   range of 0 to MAX_TEMP (inclusive).
 ****************************************************************************/
-static int map_temperature(int map_x, int map_y)
+static int map_colatitude(int map_x, int map_y)
 {
   double x, y;
   
@@ -315,38 +347,86 @@
                     - 0.5 * (x * x * x + y * y * y) 
                     + 1.5 * (x * x + y * y));
 }
+/**************************************************************************** 
+  Free the tmap
+****************************************************************************/
+static void destroy_tmap(void)
+{
+  assert( temperature_map != NULL);
+  free( temperature_map);
+  temperature_map = NULL;
+}
+
+/***************************************************************************
+ * create_tmap initialize the temperature_map
+ * if arg is FALSE, create a dumy tmap == map_colattitude
+ * to be used if hmap or oceans are not placed gen 2-4
+ ***************************************************************************/
+static void create_tmap(bool real)
+{
+  int i;
+
+  /* if map is defined this is not changed */
+  /* TO DO load if from scenario game with tmap */
+  if( temperature_map != NULL ) {
+    return;
+  }
+
+  temperature_map = fc_malloc (sizeof(int) * MAX_MAP_INDEX);
+  whole_map_iterate(x, y) {
+  
+     /* the base temperature is equal to base map_colatitude */
+    int t = map_colatitude(x, y) ;
+    if (!real) {
+      tmap(x, y) =  t;
+    } else {
+      /* height land can be 30% collest */
+      float height = - 0.3 * MAX(0, hmap(x,y) - hmap_shore_level) 
+         / (hmap_max_level - hmap_shore_level); 
+      /* near ocean temperature can be 15 % more "temperate" */
+      float temperate = 0.15 * (map.temperature / 100 - t / MAX_TEMP) * 
+         2 * MAX (map.num_valid_dirs / 2 ,count_ocean_near_tile(x,y,FALSE)) /
+         map.num_valid_dirs;
+      
+      tmap(x, y) =  t * (1.0 + temperate) * (1.0 + height) ;
+    }
+  } whole_map_iterate_end;
+  /* adjust to get well sizes frequencies */
+  adjust_int_map(temperature_map, MAX_TEMP);
+  /* now simplify to 6 base values */ 
+  for (i = 0; i < MAX_MAP_INDEX; i++) {
+    int t = temperature_map[i];
+
+    if( t >= TROPICAL_LEVEL ) {
+      temperature_map[i] = TT_TROPICAL;
+    } else if ( t >= COLD_LEVEL) {
+      temperature_map[i] = TT_TEMPERATE;
+    } else if ( t >= 2 * ICE_BASE_LEVEL) {
+      temperature_map[i] = TT_COLD;
+    } else 
+       /* this is a little to much but needed by separate poles */
+      if ( t >= 1.5 * ICE_BASE_LEVEL){
+       temperature_map[i] = TT_FRIZZED3;
+      } else if ( t >= 1 * ICE_BASE_LEVEL){
+       temperature_map[i] = TT_FRIZZED2;
+      } else {
+       temperature_map[i] = TT_FRIZZED1;
+      }
+  } 
+}
 
 /****************************************************************************
  * Conditions used mainly in rand_map_pos_characteristic()
  ****************************************************************************/
 /* WETNESS */
 
-/* necessary condition of deserts placement */
-#define map_pos_is_dry(x, y) ((map_temperature((x), (y)) <= DRY_MAX_LEVEL) &&\
-                              (map_temperature((x), (y)) > DRY_MIN_LEVEL) && \
+/* necessary condition of deserts placement, this use map_colatitude 
+   and not tmap */
+#define map_pos_is_dry(x, y) ((map_colatitude((x), (y)) <= DRY_MAX_LEVEL) &&\
+                              (map_colatitude((x), (y)) > DRY_MIN_LEVEL) && \
                               (count_ocean_near_tile((x),(y),FALSE) <= 2))
 typedef enum { WC_ALL = 200, WC_DRY, WC_NDRY } wetness_c;
 
-/* TEMPERATURE */
-
-/* necessary condition of jungle placement */
-#define map_pos_is_tropical(x, y) (map_temperature((x), (y)) > TROPICAL_LEVEL)
-
-
-/* necessary condition of arctic placement */
-#define map_pos_is_frizzed(x, y) \
-             (map_temperature((x), (y)) <= 2 * ICE_BASE_LEVEL)
-
-/* necessary condition of tundra placement */
-#define map_pos_is_cold(x, y) (map_temperature((x), (y)) <= COLD_LEVEL && \
-                               !map_pos_is_frizzed((x), (y)))
-/* used by generator 2-4 */
-#define map_pos_is_cold_or_frizzed(x, y) \
-                              (map_temperature((x), (y)) <= COLD_LEVEL)
-
-typedef enum { TC_ALL = 100, TC_FRIZZED, TC_NFRIZZED, TC_COLD, 
-                  TC_TROPICAL, TC_NTROPICAL} temperature_c;
-
 /* MISCELANEOUS (OTHER CONDITIONS) */
 
 /* necessary condition of swamp placement */
@@ -382,29 +462,6 @@
 }
 
 /***************************************************************************
-  Checks if the given location satisfy some temperature condition
-***************************************************************************/
-static bool test_temperature(int x, int y, temperature_c c)
-{
-    switch(c) {
-       case TC_ALL:
-           return TRUE;
-       case TC_FRIZZED:
-           return map_pos_is_frizzed(x, y);
-       case TC_NFRIZZED:
-           return !map_pos_is_frizzed(x, y);
-       case TC_COLD:
-           return map_pos_is_cold(x, y);
-       case TC_TROPICAL:
-           return map_pos_is_tropical(x, y);
-       case TC_NTROPICAL:
-           return !map_pos_is_tropical(x, y);
-       default:
-           assert(0);
-    }
-}
-
-/***************************************************************************
   Checks if the given location satisfy some miscellaneous condition
 ***************************************************************************/
 static bool test_miscellaneous(int x, int y, miscellaneous_c c)
@@ -426,7 +483,7 @@
 ***************************************************************************/
 struct DataFilter {
   wetness_c        wc;
-  temperature_c    tc;
+  temperature_type tc;
   miscellaneous_c  mc;
 };
 
@@ -439,7 +496,7 @@
   struct DataFilter *filter = data;
 
   return  not_placed(map_x, map_y) 
-      &&  test_temperature(map_x, map_y, filter->tc) 
+      &&  tmap_is(map_x, map_y, filter->tc) 
       &&  test_wetness(map_x, map_y, filter->wc) 
       &&  test_miscellaneous(map_x, map_y, filter->mc) ;
 }
@@ -451,7 +508,7 @@
 ****************************************************************************/
 static bool rand_map_pos_characteristic(int *map_x, int *map_y,
                                   wetness_c        wc,
-                                  temperature_c    tc,
+                                  temperature_type tc,
                                   miscellaneous_c  mc )
 {
   struct DataFilter filter;
@@ -539,8 +596,7 @@
         || terrain_is_to_flat(x, y, hmap_mountain_level, hmap(x, y)))) {
       /* Randomly place hills and mountains on "high" tiles.  But don't
        * put hills near the poles (they're too green). */
-      if (myrand(100) > 70 
-         || map_temperature(x, y) <= COLD_LEVEL) {
+      if (myrand(100) > 70 || tmap_is(x, y, TT_NHOT)) {
        map_set_terrain(x, y, T_MOUNTAINS);
        map_set_placed(x, y);
       } else {
@@ -559,35 +615,33 @@
 static void make_polar(void)
 {
   struct tile *ptile;
-  int T;
 
-  whole_map_iterate(map_x, map_y) {
-    T = map_temperature(map_x, map_y); /* temperature parameter */
+  whole_map_iterate(map_x, map_y) {  
     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) {
+    switch( tmap(map_x, map_y)) { /* get the coldest part of the map */
+      case TT_FRIZZED1:
+       if (ptile->terrain != T_MOUNTAINS) {
+         ptile->terrain = T_ARCTIC;
+       };
+       break;
+      case TT_FRIZZED2:
+       if (ptile->terrain == T_OCEAN ) {  
          ptile->terrain = T_ARCTIC;
-         map_set_placed(map_x, map_y);
-       } else if (myrand(10) > 6) {
+       };
+       break;
+      case TT_FRIZZED3:
+       if (ptile->terrain == T_OCEAN) {
+           if (myrand(10) > 5) {
+             ptile->terrain = T_ARCTIC;
+           } else if (myrand(10) > 6) {
+             ptile->terrain = T_TUNDRA;
+           }
+       } else if ( ptile->terrain != T_MOUNTAINS) {
          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;
+       };
+       break;
+    } whole_map_iterate_end;
+  }
 }
 /*************************************************************************
  if separatepoles is set, return false if this tile has to kip ocean
@@ -619,14 +673,15 @@
 
   assign_continent_numbers();
   whole_map_iterate(map_x, map_y) {
-    T = map_temperature(map_x, map_y); /* temperature parameter */
+    T = tmap(map_x, map_y);
     ptile = map_get_tile(map_x, map_y);
-    if (T < 1.5 * ICE_BASE_LEVEL && ok_for_separate_poles(map_x, map_y)) {
+    if ((T == TT_FRIZZED1 || T == TT_FRIZZED2) &&
+       ok_for_separate_poles(map_x, map_y)) {
       ptile->terrain = T_UNKNOWN;
       map_unset_placed(map_x, map_y);
       map_set_continent(map_x, map_y, 0);
-    } else if ((T <= 2 * ICE_BASE_LEVEL) 
-              && myrand(10) > 4 && ok_for_separate_poles(map_x, map_y)) { 
+    } else if ((T == TT_FRIZZED3) && myrand(10) > 4 &&
+              ok_for_separate_poles(map_x, map_y)) { 
       ptile->terrain = T_UNKNOWN;
       map_unset_placed(map_x, map_y);
       map_set_continent(map_x, map_y, 0);
@@ -640,11 +695,7 @@
 static void make_arctic(void)
 {
   whole_map_iterate(x, y) {
-    int T = map_temperature(x, y);
-
-    if (not_placed(x, y)
-       && myrand(1.5 * COLD_LEVEL) > T -  ICE_BASE_LEVEL 
-       && T <= 3 * ICE_BASE_LEVEL) {
+    if (not_placed(x, y) && tmap_is(x, y, TT_FRIZZED)) {
       map_set_terrain(x, y, T_ARCTIC);
       map_set_placed(x, y);
     }
@@ -658,7 +709,7 @@
 static void place_terrain(int x, int y, int diff, 
                         enum tile_terrain_type ter, int *to_be_placed,
                          wetness_c        wc,
-                         temperature_c    tc,
+                         temperature_type tc,
                          miscellaneous_c  mc)
 {
   if(*to_be_placed <= 0) { return; }
@@ -667,11 +718,11 @@
   map_set_placed(x, y);
   (*to_be_placed)--;
   cardinal_adjc_iterate(x, y, x1, y1) {
-    int Delta = abs(map_temperature(x1, y1) - map_temperature(x, y)) / T_UNIT
+    int Delta = abs(map_colatitude(x1, y1) - map_colatitude(x, y)) / T_UNIT
        + abs(hmap(x1, y1) - (hmap(x, y))) /  H_UNIT;
     if (not_placed(x1, y1) 
+       && tmap_is(x1, y1, tc) 
        && test_wetness(x1, y1, wc)
-       && test_temperature(x1, y1, tc) 
        && test_miscellaneous(x1, y1, mc)
        && Delta < diff 
        && myrand(10) > 4) {
@@ -686,9 +737,8 @@
 **************************************************************************/
 static void make_plain(int x, int y, int *to_be_placed )
 {
-  int T = map_temperature(x, y);
   /* in cold place we get tundra instead */
-  if((COLD_LEVEL > T)) {
+  if(tmap_is(x, y, TT_COLD)) {
     map_set_terrain(x, y, T_TUNDRA); 
   } else {
     if(myrand(100) > 50) {
@@ -773,15 +823,15 @@
   do {
     
     PLACE_ONE_TYPE(forests_count , plains_count, T_FOREST,
-                  WC_ALL, TC_NFRIZZED, MC_NONE, 60);
+                  WC_ALL, TT_NFRIZZED, MC_NONE, 60);
     PLACE_ONE_TYPE(jungles_count, forests_count , T_JUNGLE,
-                  WC_ALL, TC_TROPICAL, MC_NONE, 50);
+                  WC_ALL, TT_TROPICAL, MC_NONE, 50);
     PLACE_ONE_TYPE(swamps_count, forests_count , T_SWAMP,
-                  WC_NDRY, TC_NFRIZZED, MC_LOW, 50);
+                  WC_NDRY, TT_NFRIZZED, MC_LOW, 50);
     PLACE_ONE_TYPE(deserts_count, alt_deserts_count , T_DESERT,
-                  WC_DRY, TC_NFRIZZED, MC_NLOW, 80);
+                  WC_DRY, TT_NFRIZZED, MC_NLOW, 80);
     PLACE_ONE_TYPE(alt_deserts_count, plains_count , T_DESERT,
-                  WC_ALL, TC_NFRIZZED, MC_NLOW, 40);
+                  WC_ALL, TT_NFRIZZED, MC_NLOW, 40);
  
   /* there is very important: this place all terrains when there
      is not posibe for other types kip the WC_ALL, TC_ALL, MC_NONE range. */
@@ -789,7 +839,7 @@
     if(plains_count > 0) {
       int x, y;
 
-      if (rand_map_pos_characteristic(&x, &y,  WC_ALL, TC_ALL, MC_NONE)){
+      if (rand_map_pos_characteristic(&x, &y,  WC_ALL, TT_ALL, MC_NONE)){
        make_plain(x,y, &plains_count);
       } else {
        /* If rand_map_pos_temperature returns FALSE we may as well stop
@@ -1047,7 +1097,7 @@
     if (count_special_near_tile(x, y, TRUE, S_RIVER) != 0
        || count_ocean_near_tile(x, y, TRUE) != 0
         || (map_get_terrain(x, y) == T_ARCTIC 
-           && map_temperature(x, y) < 0.8 * COLD_LEVEL)) { 
+           && map_colatitude(x, y) < 0.8 * COLD_LEVEL)) { 
 
       freelog(LOG_DEBUG,
              "The river ended at (%d, %d).\n", x, y);
@@ -1179,7 +1229,7 @@
   while (current_riverlength < desirable_riverlength
         && iteration_counter < RIVERS_MAXTRIES) {
 
-    if( !rand_map_pos_characteristic(&x, &y, WC_NDRY, TC_NFRIZZED, MC_NLOW))
+    if( !rand_map_pos_characteristic(&x, &y, WC_NDRY, TT_NFRIZZED, MC_NLOW))
     {
        break; /* mo more start places */
     };
@@ -1278,13 +1328,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_colatitude(x, y) < 2 * ICE_BASE_LEVEL) {
+      hmap(x, y) *= map_colatitude(x, y) / (2.5 * ICE_BASE_LEVEL);
     } else if (map.separatepoles 
-              && map_temperature(x, y) <= 2.5 * ICE_BASE_LEVEL) {
+              && map_colatitude(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_colatitude(x, y) <= 2.5 * ICE_BASE_LEVEL) {
+      hmap(x, y) *= map_colatitude(x, y) / (2.5 * ICE_BASE_LEVEL);
     }
   } whole_map_iterate_end;
 }
@@ -1296,15 +1346,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_colatitude(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_colatitude(x, y) < 2 * ICE_BASE_LEVEL) {
+      hmap(x, y) *= (2.5 * ICE_BASE_LEVEL) / map_colatitude(x, y);
     } else if (map.separatepoles 
-              && map_temperature(x, y) <= 2.5 * ICE_BASE_LEVEL) {
+              && map_colatitude(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_colatitude(x, y) <= 2.5 * ICE_BASE_LEVEL) {
+      hmap(x, y) *= (2.5 * ICE_BASE_LEVEL) /  map_colatitude(x, y);
     }
   } whole_map_iterate_end;
 }
@@ -1317,8 +1367,9 @@
 static void make_land(void)
 {
   create_placed_map(); /* here it means land terrains to be placed */
-  adjust_hmap();
-  if(!map.alltemperate) {
+  adjust_int_map(height_map, hmap_max_level);
+  
+  if(HAS_POLES) {
     normalize_hmap_poles();
   }
   hmap_shore_level = (hmap_max_level * (100 - map.landpercent)) / 100;
@@ -1330,15 +1381,18 @@
       map_set_placed(x, y); /* placed, not a land target */
     }
   } whole_map_iterate_end;
-  if(!map.alltemperate) {
-    renormalize_hmap_poles(); 
+  if(HAS_POLES) {
+    renormalize_hmap_poles();
+  } 
+  create_tmap(TRUE); /* base temperature map, need hmap and oceans */
+  if(HAS_POLES) {
     make_polar_land(); /* make extra land at poles*/
   }
   make_relief(); /* base relief on map */
   make_arctic(); 
   make_terrains();/* place forest/dessert/swamp/grass/tundra and plains */
   destroy_placed_map();
-  make_rivers();
+  make_rivers(); /* use a new placed_map ! destroy older before call */
   assign_continent_numbers();
 }
 
@@ -1447,7 +1501,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_colatitude(x1, y1) <= 2 * ICE_BASE_LEVEL) { 
        /* Not land, or too cold. */
         continue;
       }
@@ -1782,6 +1836,10 @@
       assign_continent_numbers();
   }
 
+  if(temperature_map == NULL) {
+    create_tmap(FALSE);
+  }
+
   if(!map.have_specials) /* some scenarios already provide specials */
     add_specials(map.riches); /* hvor mange promiller specials oensker vi*/
 
@@ -1791,6 +1849,7 @@
 
   /* restore previous random state: */
   set_myrand_state(rstate);
+  destroy_tmap();
 }
 
 /**************************************************************************
@@ -1815,22 +1874,20 @@
 }
 
 /**************************************************************************
-  Change the values of the height map, so that they contain ranking of each 
-  tile scaled to [0 .. hmap_max_level].
-  The lowest 20% of tiles will have values lower than 0.2 * hmap_max_level.
+  Change the values of the integer map, so that they contain ranking of each 
+  tile scaled to [0 .. int_map_max].
+  The lowest 20% of tiles will have values lower than 0.2 * int_map_max.
 
-  slope can globally be estimated as
-        hmap_max_level * sqrt(number_of_islands) / linear_size_of_map
 **************************************************************************/
-static void adjust_hmap(void)
+static void adjust_int_map(int *int_map, int int_map_max)
 {
-  int minval = hnat(0, 0), maxval = minval;
+  int i, minval = *int_map, maxval = minval;
 
-  /* Determine minimum and maximum heights. */
-  whole_map_iterate(x, y) {
-    maxval = MAX(maxval, hmap(x, y));
-    minval = MIN(minval, hmap(x, y));
-  } whole_map_iterate_end;
+  /* Determine minimum and maximum value. */
+  for (i = 0; i < MAX_MAP_INDEX; i++) {
+    maxval = MAX(maxval, int_map[i]);
+    minval = MIN(minval, int_map[i]);
+  }
 
   {
     int const size = 1 + maxval - minval;
@@ -1838,24 +1895,24 @@
 
     INITIALIZE_ARRAY(frequencies, size, 0);
 
-    /* Translate heights so the minimum height is 0
+    /* Translate value so the minimum value is 0
        and count the number of occurencies of all values to initialize the 
        frequencies[] */
-    whole_map_iterate(x, y) {
-      hmap(x, y) = (hmap(x, y) - minval);
-      frequencies[hmap(x, y)]++;
-    } whole_map_iterate_end;
+    for (i = 0; i < MAX_MAP_INDEX; i++) {
+      int_map[i] = (int_map[i] - minval);
+      frequencies[int_map[i]]++;
+    }
 
     /* create the linearize function as "incremental" frequencies */
     for(i =  0; i < size; i++) {
       count += frequencies[i]; 
-      frequencies[i] = (count * hmap_max_level) / MAX_MAP_INDEX;
+      frequencies[i] = (count * int_map_max) / MAX_MAP_INDEX;
     }
 
     /* apply the linearize function */
-    whole_map_iterate(x, y) {
-      hmap(x, y) = frequencies[hmap(x, y)];
-    } whole_map_iterate_end; 
+    for (i = 0; i < MAX_MAP_INDEX; i++) {
+      int_map[i] = frequencies[int_map[i]];
+    }; 
   }
 }
 
@@ -1875,7 +1932,7 @@
     rand_map_pos(&x, &y);
 
     if (near_singularity(x, y)
-       || map_temperature(x, y) <= ICE_BASE_LEVEL / 2) { 
+       || map_colatitude(x, y) <= ICE_BASE_LEVEL / 2) { 
       /* Avoid land near singularities or at the poles. */
       hmap(x, y) -= myrand(5000);
     } else { 
@@ -1974,7 +2031,7 @@
 
     /* Add a hut.  But not on a polar area, on an ocean, or too close to
      * another hut. */
-    if (rand_map_pos_characteristic(&x, &y, WC_ALL, TC_NFRIZZED, MC_NONE)) {
+    if (rand_map_pos_characteristic(&x, &y, WC_ALL, TT_NFRIZZED, MC_NONE)) {
       if (is_ocean(map_get_terrain(x, y))) {
        map_set_placed(x, y); /* not good for a hut */
       } else {
@@ -2115,7 +2172,7 @@
             || is_terrain_near_tile(x,y,cold1) 
             )
           &&( !is_cardinally_adj_to_ocean(x, y) || myrand(100) < coast )) {
-       if (map_pos_is_cold_or_frizzed(x, y)) {
+       if (map_colatitude(x, y) < COLD_LEVEL) {
          map_set_terrain(x, y, (myrand(cold0_weight
                                        + cold1_weight) < cold0_weight) 
                          ? cold0 : cold1);
@@ -2487,6 +2544,7 @@
   height_map = fc_malloc(sizeof(int) * map.ysize * map.xsize);
   islands = fc_malloc((MAP_NCONT+1)*sizeof(struct isledata));
   create_placed_map(); /* land tiles which aren't placed yet */
+  create_tmap(FALSE);
   whole_map_iterate(x, y) {
     map_set_terrain(x, y, T_OCEAN);
     map_set_continent(x, y, 0);
@@ -2494,11 +2552,12 @@
     map_clear_all_specials(x, y);
     map_set_owner(x, y, NULL);
   } whole_map_iterate_end;
-  if (!map.alltemperate) { make_polar(); }
-    /* Set poles numbers.  After the map is generated continents will 
-     * be renumbered. */
-    assign_continent_numbers(); 
 
+  if(HAS_POLES) { make_polar(); }
+  /* Set poles numbers.  After the map is generated continents  and srtart
+   * pos will be renumbered. */
+  assign_continent_numbers(); 
+  
   make_island(0, 0, pstate, 0);
   for(i = 0; i <= map.num_continents; i++ ) {
       islands[i].starters = 0;
@@ -2783,7 +2842,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_colatitude(map_x, map_y) >  ICE_BASE_LEVEL/2             \
        && hnat((X), (Y)) == 0) {                                       \
       hnat((X), (Y)) = (V);                                            \
     }                                                                  \
@@ -2863,7 +2922,7 @@
          hmap(x, y) -= avoidedge;
        }
 
-       if (map_temperature(x, y) <= ICE_BASE_LEVEL / 2 ) {
+       if (map_colatitude(x, y) <= ICE_BASE_LEVEL / 2 ) {
          /* separate poles and avoid too much land at poles */
          hmap(x, y) -= myrand(avoidedge);
        }
diff -ruN -Xfreeciv/diff_ignore freeciv__/server/savegame.c 
freeciv_/server/savegame.c
--- freeciv__/server/savegame.c 2004-09-07 16:39:44.848479824 +0200
+++ freeciv_/server/savegame.c  2004-09-07 18:24:29.524063912 +0200
@@ -3104,6 +3104,9 @@
       map.forestsize = secfile_lookup_int(file, "map.forestsize");
       map.have_huts = secfile_lookup_bool_default(file, TRUE,
                                                  "map.have_huts");
+      map.temperature =
+       secfile_lookup_int_default(file,
+                                  MAP_DEFAULT_TEMPERATURE, "map.temperature");
       map.alltemperate
        = secfile_lookup_bool_default(file, MAP_DEFAULT_ALLTEMPERATE,
                                      "map.alltemperate");
@@ -3483,6 +3486,7 @@
     secfile_insert_int(file, map.huts, "map.huts");
     secfile_insert_int(file, map.generator, "map.generator");
     secfile_insert_bool(file, map.have_huts, "map.have_huts");
+    secfile_insert_int(file, map.temperature, "map.temperature");
     secfile_insert_bool(file, map.alltemperate, "map.alltemperate");
     secfile_insert_bool(file, map.tinyisles, "map.tinyisles");
     secfile_insert_bool(file, map.separatepoles, "map.separatepoles");
diff -ruN -Xfreeciv/diff_ignore freeciv__/server/settings.c 
freeciv_/server/settings.c
--- freeciv__/server/settings.c 2004-09-07 16:39:45.032451856 +0200
+++ freeciv_/server/settings.c  2004-09-07 18:28:36.737481760 +0200
@@ -293,6 +293,17 @@
           N_("0 = normal Earth-like planet; 1 = all-temperate planet "),
           NULL, MAP_DEFAULT_ALLTEMPERATE)
 
+  GEN_INT("temperature", map.temperature,
+         SSET_MAP_GEN, SSET_GEOLOGY, SSET_SITUATIONAL, SSET_TO_CLIENT,
+         N_("medium temperature of planet"),
+         N_("100 a very dry and hot planet: no poles, all tropical or dry \n"
+            "70 hot planet, frized poles disapear near this point \n"
+          "50 a temperate planet: poles, cold, temperate and tropical\n"
+          "   zone with a dessert zone overlaping bot tropical and temperate\n"
+            "30 cold planet, tropical disapear near this point \n"
+     "0 very cold planet, big poles, and any else cold and temperate"), NULL,
+         MAP_MIN_TEMPERATURE, MAP_MAX_TEMPERATURE, MAP_DEFAULT_TEMPERATURE)
+ 
   GEN_INT("landmass", map.landpercent,
          SSET_MAP_GEN, SSET_GEOLOGY, SSET_SITUATIONAL, SSET_TO_CLIENT,
          N_("Amount of land vs ocean"), "", NULL,

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