summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2015-07-11 10:46:25 +0000
committerfrosch <frosch@openttd.org>2015-07-11 10:46:25 +0000
commita11ae39437ccc7a62221b5fa1087c044a9b327bd (patch)
treeed1e30b7cbf4c3ffb8d4dd066f4b9d86295c17b5 /src
parentb303ba750577701ab30e39cc58fda2b3c972912a (diff)
downloadopenttd-a11ae39437ccc7a62221b5fa1087c044a9b327bd.tar.xz
(svn r27330) -Fix [FS#6335]: Make variety distribution not assume that sea level is at height 0.2 / 3 * TGPGetMaxHeight().
Diffstat (limited to 'src')
-rw-r--r--src/tgp.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/tgp.cpp b/src/tgp.cpp
index fb835c43c..3cfbe4951 100644
--- a/src/tgp.cpp
+++ b/src/tgp.cpp
@@ -573,7 +573,7 @@ static void HeightMapSineTransform(height_t h_min, height_t h_max)
*/
static void HeightMapCurves(uint level)
{
- height_t mh = TGPGetMaxHeight();
+ height_t mh = TGPGetMaxHeight() - I2H(1); // height levels above sea level only
/** Basically scale height X to height Y. Everything in between is interpolated. */
struct control_point_t {
@@ -582,10 +582,10 @@ static void HeightMapCurves(uint level)
};
/* Scaled curve maps; value is in height_ts. */
#define F(fraction) ((height_t)(fraction * mh))
- const control_point_t curve_map_1[] = { { F(0.0), F(0.0) }, { F(0.6 / 3), F(0.1) }, { F(2.4 / 3), F(0.4 / 3) }, { F(1.0), F(0.4) } };
- const control_point_t curve_map_2[] = { { F(0.0), F(0.0) }, { F(0.2 / 3), F(0.1) }, { F(1.6 / 3), F(0.4 / 3) }, { F(2.4 / 3), F(0.8 / 3) }, { F(1.0), F(0.6) } };
- const control_point_t curve_map_3[] = { { F(0.0), F(0.0) }, { F(0.2 / 3), F(0.1) }, { F(1.6 / 3), F(0.8 / 3) }, { F(2.4 / 3), F(1.8 / 3) }, { F(1.0), F(0.8) } };
- const control_point_t curve_map_4[] = { { F(0.0), F(0.0) }, { F(0.2 / 3), F(0.1) }, { F(1.2 / 3), F(0.9 / 3) }, { F(2.0 / 3), F(2.4 / 3) } , { F(5.5 / 6), F(0.99) }, { F(1.0), F(0.99) } };
+ const control_point_t curve_map_1[] = { { F(0.0), F(0.0) }, { F(2.4 / 3), F(0.4 / 3) }, { F(1.0), F(0.4) } };
+ const control_point_t curve_map_2[] = { { F(0.0), F(0.0) }, { F(1.6 / 3), F(0.4 / 3) }, { F(2.4 / 3), F(0.8 / 3) }, { F(1.0), F(0.6) } };
+ const control_point_t curve_map_3[] = { { F(0.0), F(0.0) }, { F(1.6 / 3), F(0.8 / 3) }, { F(2.4 / 3), F(1.8 / 3) }, { F(1.0), F(0.8) } };
+ const control_point_t curve_map_4[] = { { F(0.0), F(0.0) }, { F(1.2 / 3), F(0.9 / 3) }, { F(2.0 / 3), F(2.4 / 3) } , { F(5.5 / 6), F(0.99) }, { F(1.0), F(0.99) } };
#undef F
/** Helper structure to index the different curve maps. */
@@ -663,6 +663,12 @@ static void HeightMapCurves(uint level)
height_t *h = &_height_map.height(x, y);
+ /* Do not touch sea level */
+ if (*h < I2H(1)) continue;
+
+ /* Only scale above sea level */
+ *h -= I2H(1);
+
/* Apply all curve maps that are used on this tile. */
for (uint t = 0; t < lengthof(curve_maps); t++) {
if (!HasBit(corner_bits, t)) continue;
@@ -684,6 +690,9 @@ static void HeightMapCurves(uint level)
/* Apply interpolation of curve map results. */
*h = (height_t)((ht[corner_a] * yri + ht[corner_b] * yr) * xri + (ht[corner_c] * yri + ht[corner_d] * yr) * xr);
+
+ /* Readd sea level */
+ *h += I2H(1);
}
}
}