summaryrefslogtreecommitdiff
path: root/src/tgp.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-10-14 17:49:32 +0000
committerrubidium <rubidium@openttd.org>2014-10-14 17:49:32 +0000
commitb4b0b2750c4e81849fa9df22df1a4f5fe1cf60a2 (patch)
treef775439ec36bc3572436f5d09c3d6e5dfa1932fa /src/tgp.cpp
parent54280f45c0ae32c51ce51191d11c31d3f85399ad (diff)
downloadopenttd-b4b0b2750c4e81849fa9df22df1a4f5fe1cf60a2.tar.xz
(svn r27018) -Fix [FS#6141] (r27008): the higher amplitudes needed for higher maps were not ignored properly causing much smoother maps than wanted
Diffstat (limited to 'src/tgp.cpp')
-rw-r--r--src/tgp.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/tgp.cpp b/src/tgp.cpp
index 4e26ffe42..50b2b8083 100644
--- a/src/tgp.cpp
+++ b/src/tgp.cpp
@@ -277,7 +277,7 @@ static amplitude_t GetAmplitude(int frequency)
/* We need to extrapolate the amplitude. */
double extrapolation_factor = extrapolation_factors[smoothness];
- int height_range = 16;
+ int height_range = I2H(16);
do {
amplitude = (amplitude_t)(extrapolation_factor * (double)amplitude);
height_range <<= 1;
@@ -352,12 +352,18 @@ static void HeightMapGenerate()
assert(_height_map.h != NULL);
int start = max(MAX_TGP_FREQUENCIES - (int)min(MapLogX(), MapLogY()), 0);
+ bool first = true;
for (int frequency = start; frequency < MAX_TGP_FREQUENCIES; frequency++) {
const amplitude_t amplitude = GetAmplitude(frequency);
+
+ /* Ignore zero amplitudes; it means our map isn't height enough for this
+ * amplitude, so ignore it and continue with the next set of amplitude. */
+ if (amplitude == 0) continue;
+
const int step = 1 << (MAX_TGP_FREQUENCIES - frequency - 1);
- if (frequency == start) {
+ if (first) {
/* This is first round, we need to establish base heights with step = size_min */
for (int y = 0; y <= _height_map.size_y; y += step) {
for (int x = 0; x <= _height_map.size_x; x += step) {
@@ -365,6 +371,7 @@ static void HeightMapGenerate()
_height_map.height(x, y) = height;
}
}
+ first = false;
continue;
}