summaryrefslogtreecommitdiff
path: root/src/tgp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tgp.cpp')
-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);
}
}
}