[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" <mburda@xxxxxxxxx> |
Date: |
Fri, 10 Sep 2004 12:04:59 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9876 >
> [mburda - Ven. Sep. 10 07:29:03 2004]:
>
> Update
>
Finally i simplify the TT_FRIZZED, now i am happy
diff -ruN -Xfreeciv/diff_ignore freeciv/common/map.c freeciv__/common/map.c
--- freeciv/common/map.c 2004-09-03 17:12:25.000000000 +0200
+++ freeciv__/common/map.c 2004-09-10 13:19:05.000000000 +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-03 17:12:25.000000000 +0200
+++ freeciv__/common/map.h 2004-09-10 13:19:05.000000000 +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-10 05:55:02.000000000 +0200
+++ freeciv__/server/mapgen.c 2004-09-10 18:58:13.786484056 +0200
@@ -60,6 +60,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);
@@ -70,7 +71,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
@@ -97,13 +98,41 @@
static const int hmap_max_level = 1000;
static int hmap_shore_level, hmap_mountain_level;
+/*
+ * temperature_map[] stores the temperature of each tile
+ * values on tmap can get one of these 4 values
+ * there is 4 extra values as macros combining the 4 basics ones
+ */
+typedef enum {
+ TT_FRIZZED = 1, TT_COLD = 2, TT_TEMPERATE = 4, TT_TROPICAL = 8
+} temperature_type;
+#define TT_NFRIZZED (TT_COLD | TT_TEMPERATE | TT_TROPICAL)
+#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)))
+/*****************************************************************
+ return true if at last one tile has tt temperature type
+****************************************************************/
+static bool ajdc_tmap_has(int x, int y, temperature_type tt)
+{
+ adjc_iterate(x, y, x1, y1) {
+ if(BOOL_VAL(tmap((x1), (y1)) & (tt))) {
+ return TRUE;
+ };
+ } adjc_iterate_end;
+ return FALSE;
+}
+
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
+ map_colatitude and tmap */
#define MAX_TEMP 1000
/* An estimate of the linear (1-dimensional) size of the map. */
@@ -123,18 +152,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
@@ -170,6 +207,7 @@
****************************************************************************/
static void destroy_placed_map(void)
{
+ assert( placed_map != NULL);
free(placed_map);
placed_map = NULL;
}
@@ -181,13 +219,13 @@
#define map_set_placed(x, y) (pmap((x), (y)) = TRUE)
#define map_unset_placed(x, y) (pmap((x), (y)) = FALSE)
/****************************************************************************
- Unset all oceanics tiles in placed_map
+ set all oceanics tiles in placed_map
****************************************************************************/
-static void unset_placed_all_oceans(void)
+static void set_placed_all_oceans(void)
{
whole_map_iterate(x, y) {
if (is_ocean(map_get_terrain(x,y))) {
- map_unset_placed(x, y);
+ map_set_placed(x, y);
}
} whole_map_iterate_end;
}
@@ -195,7 +233,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;
@@ -322,6 +360,72 @@
+ 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 */
+ assert( temperature_map == NULL ); /* to debug, never load a this time */
+ 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 * MIN (50 ,count_ocean_near_tile(x, y, FALSE, TRUE)) /
+ 100;
+
+ tmap(x, y) = t * (1.0 + temperate) * (1.0 + height) ;
+ }
+ } whole_map_iterate_end;
+ /* adjust to get well sizes frequencies */
+ /* Notice: if colatitude is load from a scenario never call adjust has
+ scenario maybe has a odd colatitude ditribution and adjust will
+ brack it */
+ adjust_int_map(temperature_map, MAX_TEMP);
+ /* now simplify to 4 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 {
+ temperature_map[i] = TT_FRIZZED;
+ }
+ }
+}
+
/****************************************************************************
* Conditions used mainly in rand_map_pos_characteristic()
****************************************************************************/
@@ -329,42 +433,23 @@
/* 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
\
- && count_ocean_near_tile((x), (y), FALSE, TRUE) <= 50)
+ (map_colatitude((x), (y)) <= DRY_MAX_LEVEL \
+ && map_colatitude((x), (y)) > DRY_MIN_LEVEL \
+ && count_ocean_near_tile((x), (y), FALSE, TRUE) <= 35)
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 */
static int hmap_low_level = 0;
#define ini_hmap_low_level() \
{ \
-hmap_low_level = (2 * map.swampsize * \
+hmap_low_level = (2 * map.swampsize * \
(hmap_max_level - hmap_shore_level)) / 100 + hmap_shore_level; \
}
/* should be used after having hmap_low_level initialized */
-#define map_pos_is_low(x, y) ( hmap((x), (y)) < hmap_low_level )
+#define map_pos_is_low(x, y) ((hmap((x), (y)) < hmap_low_level) || \
+ is_ocean_near_tile((x), (y)))
typedef enum { MC_NONE, MC_LOW, MC_NLOW } miscellaneous_c;
@@ -389,29 +474,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)
@@ -433,7 +495,7 @@
***************************************************************************/
struct DataFilter {
wetness_c wc;
- temperature_c tc;
+ temperature_type tc;
miscellaneous_c mc;
};
@@ -446,7 +508,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) ;
}
@@ -458,7 +520,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;
@@ -546,8 +608,7 @@
|| terrain_is_too_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 {
@@ -565,34 +626,13 @@
****************************************************************************/
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 */
- 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(map_x, map_y) {
+ if (tmap_is(map_x, map_y, TT_FRIZZED )
+ ||
+ (tmap_is(map_x, map_y, TT_COLD ) &&
+ (myrand(10) > 7) &&
+ ajdc_tmap_has(map_x, map_y, TT_FRIZZED))) {
+ map_set_terrain(map_x, map_y, T_ARCTIC);
}
} whole_map_iterate_end;
}
@@ -616,44 +656,21 @@
/****************************************************************************
Place untextured land at the poles. This is used by generators 1 and 5.
- The land is textured by make_tundra, make_arctic, and make_mountains.
****************************************************************************/
static void make_polar_land(void)
{
- struct tile *ptile;
- int T;
-
assign_continent_numbers();
whole_map_iterate(map_x, map_y) {
- T = map_temperature(map_x, map_y); /* temperature parameter */
- ptile = map_get_tile(map_x, map_y);
- if (T < 1.5 * ICE_BASE_LEVEL && 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)) {
- ptile->terrain = T_UNKNOWN;
- map_unset_placed(map_x, map_y);
- map_set_continent(map_x, map_y, 0);
- }
- } whole_map_iterate_end;
-}
-
-/****************************************************************************
- Create arctic in cold zones. Used by generators 1 and 5.
-****************************************************************************/
-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) {
- map_set_terrain(x, y, T_ARCTIC);
- map_set_placed(x, y);
- }
+ if ((tmap_is(map_x, map_y, TT_FRIZZED ) &&
+ ok_for_separate_poles(map_x, map_y))
+ ||
+ (tmap_is(map_x, map_y, TT_COLD ) &&
+ (myrand(10) > 7) &&
+ ajdc_tmap_has(map_x, map_y, TT_FRIZZED) &&
+ ok_for_separate_poles(map_x, map_y))) {
+ map_set_terrain(map_x, map_y, T_UNKNOWN);
+ map_set_continent(map_x, map_y, 0);
+ }
} whole_map_iterate_end;
}
@@ -663,7 +680,7 @@
static void place_terrain(int x, int y, int diff,
Terrain_type_id ter, int *to_be_placed,
wetness_c wc,
- temperature_c tc,
+ temperature_type tc,
miscellaneous_c mc)
{
if (*to_be_placed <= 0) {
@@ -675,11 +692,11 @@
(*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) {
@@ -694,9 +711,10 @@
**************************************************************************/
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_FRIZZED)) {
+ map_set_terrain(x, y, T_ARCTIC);
+ } else if (tmap_is(x, y, TT_COLD)) {
map_set_terrain(x, y, T_TUNDRA);
} else {
if (myrand(100) > 50) {
@@ -782,22 +800,22 @@
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);
/* make the plains and tundras */
if (plains_count > 0) {
int x, y;
/* Don't use any restriction here ! */
- 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
@@ -1039,7 +1057,7 @@
if (count_special_near_tile(x, y, TRUE, TRUE, S_RIVER) > 0
|| count_ocean_near_tile(x, y, TRUE, 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);
@@ -1163,7 +1181,7 @@
int iteration_counter = 0;
create_placed_map(); /* needed bu rand_map_characteristic */
- unset_placed_all_oceans();
+ set_placed_all_oceans();
river_map = fc_malloc(sizeof(int) * MAX_MAP_INDEX);
@@ -1172,7 +1190,7 @@
&& iteration_counter < RIVERS_MAXTRIES) {
if (!rand_map_pos_characteristic(&x, &y,
- WC_NDRY, TC_NFRIZZED, MC_NLOW)) {
+ WC_ALL, TT_NFRIZZED, MC_NLOW)) {
break; /* mo more spring places */
}
@@ -1270,13 +1288,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;
}
@@ -1288,15 +1306,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;
}
@@ -1308,9 +1326,8 @@
**************************************************************************/
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;
@@ -1319,18 +1336,26 @@
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);
- 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) { /* this is a hack to terrains set with not frizzed oceans*/
make_polar_land(); /* make extra land at poles*/
}
+
+ create_placed_map(); /* here it means land terrains to be placed */
+ set_placed_all_oceans();
make_relief(); /* base relief on map */
- make_arctic();
- make_terrains(); /* place forest/desert/swamp/grass/tundra and plains */
+ make_terrains(); /* place all exept mountains and hill */
destroy_placed_map();
- make_rivers();
+
+ make_rivers(); /* use a new placed_map. destroy older before call */
+
assign_continent_numbers();
}
@@ -1439,7 +1464,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;
}
@@ -1774,6 +1799,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*/
@@ -1783,6 +1812,7 @@
/* restore previous random state: */
set_myrand_state(rstate);
+ destroy_tmap();
}
/**************************************************************************
@@ -1807,22 +1837,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;
@@ -1830,24 +1858,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]];
+ };
}
}
@@ -1867,7 +1895,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 {
@@ -1966,7 +1994,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 {
@@ -2107,7 +2135,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);
@@ -2479,6 +2507,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);
@@ -2486,7 +2515,7 @@
map_clear_all_specials(x, y);
map_set_owner(x, y, NULL);
} whole_map_iterate_end;
- if (!map.alltemperate) {
+ if (HAS_POLES) {
make_polar();
}
@@ -2786,7 +2815,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); \
} \
@@ -2866,7 +2895,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-04 23:25:57.000000000 +0200
+++ freeciv__/server/savegame.c 2004-09-10 13:19:05.000000000 +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-04 22:36:10.000000000 +0200
+++ freeciv__/server/settings.c 2004-09-10 13:19:05.000000000 +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,
- [Freeciv-Dev] (PR#9876) PATCH temperature parameters for Earth like generators 1,5, Marcelo Burda via RT, 2004/09/02
- [Freeciv-Dev] (PR#9876) PATCH temperature parameters for Earth like generators 1,5, Marcelo Burda via RT, 2004/09/07
- [Freeciv-Dev] (PR#9876) PATCH temperature parameters for Earth like generators 1,5, Marcelo Burda via RT, 2004/09/08
- [Freeciv-Dev] (PR#9876) PATCH temperature parameters for Earth like generators 1,5, Marcelo Burda via RT, 2004/09/10
- [Freeciv-Dev] (PR#9876) PATCH temperature parameters for Earth like generators 1,5,
Marcelo Burda <=
- [Freeciv-Dev] (PR#9876) PATCH temperature parameters for Earth like generators 1,5, Marcelo Burda via RT, 2004/09/12
- [Freeciv-Dev] (PR#9876) PATCH temperature parameters for Earth like generators 1,5, Mateusz Stefek, 2004/09/12
|
|