summaryrefslogtreecommitdiff
path: root/src/tgp.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2015-07-16 17:05:40 +0000
committerfrosch <frosch@openttd.org>2015-07-16 17:05:40 +0000
commitd77935f788bf19a27a9f3c14d08084a1ee3a9234 (patch)
tree5ce92e1341f6b7003c7f704c400b484b3cef5b10 /src/tgp.cpp
parentb7c136d038e45525031e2860193c6d01f01e2973 (diff)
downloadopenttd-d77935f788bf19a27a9f3c14d08084a1ee3a9234.tar.xz
(svn r27334) -Revert (r27232) [FS#6342]: No idea what the plan was, but making the main noise coefficients the same for all smoothness types certainly wasn't.
Diffstat (limited to 'src/tgp.cpp')
-rw-r--r--src/tgp.cpp57
1 files changed, 11 insertions, 46 deletions
diff --git a/src/tgp.cpp b/src/tgp.cpp
index 1e736c638..436870b41 100644
--- a/src/tgp.cpp
+++ b/src/tgp.cpp
@@ -248,41 +248,16 @@ static height_t TGPGetMaxHeight()
*/
static amplitude_t GetAmplitude(int frequency)
{
- /* Base noise amplitudes (multiplied by 1024) and indexed by "smoothness setting" and log2(frequency).
- * Used for maps that have their smallest side smaller than 512. */
- static const amplitude_t amplitudes_small[][10] = {
+ /* Base noise amplitudes (multiplied by 1024) and indexed by "smoothness setting" and log2(frequency). */
+ static const amplitude_t amplitudes[][7] = {
/* lowest frequency ...... highest (every corner) */
- {60000, 2273, 4142, 2253, 421, 213, 137, 177, 37, 16}, ///< Very smooth
- {50000, 2273, 4142, 2253, 421, 213, 137, 177, 37, 61}, ///< Smooth
- {40000, 2273, 4142, 2253, 421, 213, 137, 177, 37, 91}, ///< Rough
- {30000, 2273, 4142, 2253, 421, 213, 137, 177, 37, 161}, ///< Very rough
+ {16000, 5600, 1968, 688, 240, 16, 16}, ///< Very smooth
+ {24000, 12800, 6400, 2700, 1024, 128, 16}, ///< Smooth
+ {32000, 19200, 12800, 8000, 3200, 256, 64}, ///< Rough
+ {48000, 24000, 19200, 16000, 8000, 512, 320}, ///< Very rough
};
-
- /* Base noise amplitudes (multiplied by 1024) and indexed by "smoothness setting" and log2(frequency).
- * Used for maps that have their smallest side equal to 512. */
- static const amplitude_t amplitudes_middle[][10] = {
- {55000, 2273, 5142, 253, 2421, 213, 137, 177, 37, 16}, ///< Very smooth
- {45000, 2273, 5142, 253, 2421, 213, 137, 177, 37, 61}, ///< Smooth
- {35000, 2273, 5142, 253, 2421, 213, 137, 177, 37, 91}, ///< Rough
- {25000, 2273, 5142, 253, 2421, 213, 137, 177, 37, 161}, ///< Very rough
- };
-
- /* Base noise amplitudes (multiplied by 1024) and indexed by "smoothness setting" and log2(frequency).
- * Used for maps that have their smallest side bigger than 512. */
- static const amplitude_t amplitudes_large[][10] = {
- /* lowest frequency ...... highest (every corner) */
- {55000, 2273, 5142, 253, 421, 2213, 137, 177, 37, 16}, ///< Very smooth
- {45000, 2273, 5142, 253, 421, 2213, 137, 177, 37, 61}, ///< Smooth
- {35000, 2273, 5142, 253, 421, 2213, 137, 177, 37, 91}, ///< Rough
- {25000, 2273, 5142, 253, 421, 2213, 137, 177, 37, 161}, ///< Very rough
- };
-
- /* Make sure arrays cover all smoothness settings. */
- assert_compile(lengthof(amplitudes_small) == TGEN_SMOOTHNESS_END);
- assert_compile(lengthof(amplitudes_middle) == TGEN_SMOOTHNESS_END);
- assert_compile(lengthof(amplitudes_large) == TGEN_SMOOTHNESS_END);
-
- /* Extrapolation factors for ranges before the table.
+ /*
+ * Extrapolation factors for ranges before the table.
* The extrapolation is needed to account for the higher map heights. They need larger
* areas with a particular gradient so that we are able to create maps without too
* many steep slopes up to the wanted height level. It's definitely not perfect since
@@ -294,20 +269,10 @@ static amplitude_t GetAmplitude(int frequency)
static const double extrapolation_factors[] = { 3.3, 2.8, 2.3, 1.8 };
int smoothness = _settings_game.game_creation.tgen_smoothness;
- int smallest_size = min(_settings_game.game_creation.map_x, _settings_game.game_creation.map_y);
- int index;
- amplitude_t amplitude;
- if (smallest_size < 9) { // Smallest map side is less than 2^9 == 512.
- index = frequency - MAX_TGP_FREQUENCIES + lengthof(amplitudes_small[0]);
- amplitude = amplitudes_small[smoothness][max(0, index)];
- } else if (smallest_size == 9) {
- index = frequency - MAX_TGP_FREQUENCIES + lengthof(amplitudes_middle[0]);
- amplitude = amplitudes_middle[smoothness][max(0, index)];
- } else {
- index = frequency - MAX_TGP_FREQUENCIES + lengthof(amplitudes_large[0]);
- amplitude = amplitudes_large[smoothness][max(0, index)];
- }
+ /* Get the table index, and return that value if possible. */
+ int index = frequency - MAX_TGP_FREQUENCIES + lengthof(amplitudes[smoothness]);
+ amplitude_t amplitude = amplitudes[smoothness][max(0, index)];
if (index >= 0) return amplitude;
/* We need to extrapolate the amplitude. */