[Freeciv-Dev] (PR#9797) RfP: use T_UNKNOWN instead of T_GRASSLAND for no
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=9797 >
> [jdorje - Mar. Aoû. 24 18:02:00 2004]:
>
> Mapgen inits all tiles to T_GRASSLAND, then overwrites them with other
> terrains. T_GRASSLAND is thus just a flag meaning
> "terrain-not-placed-here". This should be T_UNKNOWN instead.
>
> See also PR#9627. That patch has a
>
> #define T_NOT_PLACED T_UNKNOWN
>
> and
>
> #define not_placed(x, y) (map_get_terrain(x, y) == T_NOT_PLACED)
>
> jason
>
this patch maybe work (but a this time cvs not compile) i thest it
later, if not more comments this work
Marcelo
diff -ruN -Xfreeciv/diff_ignore freeciv/server/mapgen.c freeciv_/server/mapgen.c
--- freeciv/server/mapgen.c 2004-08-27 12:14:41.190951440 +0200
+++ freeciv_/server/mapgen.c 2004-08-27 13:13:41.377761240 +0200
@@ -85,6 +85,13 @@
};
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
@@ -367,9 +374,9 @@
T = map_temperature(map_x, map_y); /* temperature parameter */
ptile = map_get_tile(map_x, map_y);
if (T < 1.5 * ICE_BASE_LEVEL) {
- ptile->terrain = T_GRASSLAND;
+ ptile->terrain = T_NOT_PLACED;
} else if ((T <= 2 * ICE_BASE_LEVEL) && myrand(10) > 4 ) {
- ptile->terrain = T_GRASSLAND;
+ ptile->terrain = T_NOT_PLACED;
}
} whole_map_iterate_end;
}
@@ -384,7 +391,7 @@
whole_map_iterate(x, y) {
int T = map_temperature(x, y);
- if (map_get_terrain(x, y) == T_GRASSLAND
+ if (not_placed(x,y)
&& (2 * ICE_BASE_LEVEL > T || myrand(MAX_TEMP/5) > T)) {
map_set_terrain(x, y, T_TUNDRA);
}
@@ -399,7 +406,7 @@
whole_map_iterate(x, y) {
int T = map_temperature(x, y);
- if (map_get_terrain(x, y) == T_GRASSLAND
+ if (not_placed(x,y)
&& myrand(15 * MAX_TEMP / 100) > T - ICE_BASE_LEVEL
&& T <= 3 * ICE_BASE_LEVEL) {
map_set_terrain(x, y, T_ARCTIC);
@@ -422,7 +429,7 @@
const int DeltaT = MAX_TEMP / (3 * SQSIZE);
if (abs(hmap(x, y) - height) < diff
- && map_get_terrain(x, y) == T_GRASSLAND) {
+ && not_placed(x,y)) {
map_set_terrain(x, y, T_DESERT);
cardinal_adjc_iterate(x, y, x1, y1) {
make_desert(x1, y1, height,
@@ -445,7 +452,7 @@
map_to_native_pos(&nat_x, &nat_y, map_x, map_y);
T = map_temperature(map_x, map_y);
- if (map_get_terrain(map_x, map_y) == T_GRASSLAND) {
+ if (not_placed(map_x, map_y)) {
if (T > 8 * MAX_TEMP / 10
&& myrand(1000) > 500 - 300 * (T * 1000 / MAX_TEMP - 800)) {
map_set_terrain(map_x, map_y, T_JUNGLE);
@@ -478,7 +485,7 @@
/* Place one forest clump anywhere. */
if (rand_map_pos_temperature(&x, &y,
MAX_TEMP / 10, MAX_TEMP,
- T_GRASSLAND)) {
+ T_NOT_PLACED)) {
make_forest(x, y, hmap(x, y), 25);
} else {
/* If rand_map_pos_temperature returns FALSE we may as well stop
@@ -489,14 +496,14 @@
/* Now add another tropical forest clump (70-100% temperature). */
if (rand_map_pos_temperature(&x, &y,
7 *MAX_TEMP / 10, MAX_TEMP,
- T_GRASSLAND)) {
+ T_NOT_PLACED)) {
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_GRASSLAND)) {
+ T_NOT_PLACED)) {
make_forest(x, y, hmap(x, y), 25);
}
} while (forests < forestsize);
@@ -519,7 +526,7 @@
return;
}
rand_map_pos(&x, &y);
- if (map_get_terrain(x, y) == T_GRASSLAND
+ if (not_placed(x, y)
&& hmap(x, y) < (maxval * 60) / 100) {
map_set_terrain(x, y, T_SWAMP);
cardinal_adjc_iterate(x, y, x1, y1) {
@@ -551,7 +558,7 @@
* them). */
if (rand_map_pos_temperature(&x, &y,
65 * MAX_TEMP / 100, 80 * MAX_TEMP / 100,
- T_GRASSLAND)){
+ T_NOT_PLACED)){
make_desert(x, y, hmap(x, y), 50, map_temperature(x, y));
i--;
} else {
@@ -1026,14 +1033,19 @@
}
/**************************************************************************
- make_plains converts 50% of the remaining grassland to plains, this should
- maybe be lowered to 30% or done in batches, like the swamps?
+ make_plains converts 50% of the remaining terrains to plains and 50%
+ grassland,
**************************************************************************/
static void make_plains(void)
{
whole_map_iterate(x, y) {
- if (map_get_terrain(x, y) == T_GRASSLAND && myrand(100) > 50)
- map_set_terrain(x, y, T_PLAINS);
+ if (not_placed(x, y)) {
+ if(myrand(100) > 50) {
+ map_set_terrain(x, y, T_GRASSLAND);
+ } else {
+ map_set_terrain(x, y, T_PLAINS);
+ }
+ }
} whole_map_iterate_end;
}
/****************************************************************************
@@ -1140,7 +1152,7 @@
if (hmap(x, y) < tres)
map_set_terrain(x, y, T_OCEAN);
else {
- map_set_terrain(x, y, T_GRASSLAND);
+ map_set_terrain(x, y, T_NOT_PLACED);
count++;
}
} whole_map_iterate_end;
@@ -1901,7 +1913,7 @@
get_random_map_position_from_state(&x, &y, pstate);
if (map_get_continent(x, y) == pstate->isleindex &&
- map_get_terrain(x, y) == T_GRASSLAND) {
+ not_placed(x, y)) {
/* the first condition helps make terrain more contiguous,
the second lets it avoid the coast: */
@@ -1923,7 +1935,7 @@
? warm0 : warm1);
}
}
- if (map_get_terrain(x,y) != T_GRASSLAND) i--;
+ if (not_placed(x,y)) i--;
}
}
}
@@ -1950,7 +1962,7 @@
while (i > 0 && (failsafe--) > 0) {
get_random_map_position_from_state(&x, &y, pstate);
if (map_get_continent(x, y) == pstate->isleindex &&
- map_get_terrain(x, y) == T_GRASSLAND) {
+ not_placed(x, y)) {
/* the first condition helps make terrain more contiguous,
the second lets it avoid the coast: */
@@ -2053,7 +2065,7 @@
return i != 0;
}
- map_set_terrain(map_x, map_y, T_GRASSLAND);
+ map_set_terrain(map_x, map_y, T_NOT_PLACED);
map_set_continent(map_x, map_y, pstate->isleindex);
i++;
}
|
|