diff -r 50f056aa3024 -r 0a91ea45b0e8 src/tgp.cpp --- a/src/tgp.cpp Fri Dec 19 01:38:09 2008 +0200 +++ b/src/tgp.cpp Fri Dec 19 02:13:39 2008 +0200 @@ -372,8 +372,8 @@ int log_frequency; /* Find first power of two that fits, so that later log_frequency == TGP_FREQUENCY_MAX in the last iteration */ - for (log_size_min = TGP_FREQUENCY_MAX; (1U << log_size_min) < size_min; log_size_min++) { } - log_frequency_min = log_size_min - TGP_FREQUENCY_MAX; + for (log_size_min = 2; (1U << log_size_min) < size_min; log_size_min++) { } + log_frequency_min = log_size_min - 2; /* Zero must be part of the iteration, else initialization will fail. */ assert(log_frequency_min >= 0); @@ -383,7 +383,7 @@ log_frequency = iteration_round - log_frequency_min; if (log_frequency >= 0) { /* Apply noise for the next frequency */ - assert(log_frequency <= TGP_FREQUENCY_MAX); + assert(log_frequency <= 2); amplitude = _amplitudes_by_smoothness_and_frequency[_settings_game.game_creation.tgen_smoothness][log_frequency]; } else { /* Amplitude for the low frequencies on big maps is 0, i.e. initialise with zero height */ @@ -392,7 +392,8 @@ continue_iteration = ApplyNoise(iteration_round, amplitude); iteration_round++; } while (continue_iteration); - assert(log_frequency == TGP_FREQUENCY_MAX); + + assert(log_frequency == 2); } /** Returns min, max and average height from height map */ @@ -581,21 +582,25 @@ double max_x; double max_y; + int factor = smallest_size * smallest_size / 16; + /* Lower to sea level */ for (y = 0; y <= _height_map.size_y; y++) { /* Top right */ max_x = abs((perlin_coast_noise_2D(_height_map.size_y - y, y, 0.9, 53) + 0.25) * 5 + (perlin_coast_noise_2D(y, y, 0.35, 179) + 1) * 12); - max_x = max((smallest_size * smallest_size / 16) + max_x, (smallest_size * smallest_size / 16) + margin - max_x); + max_x = max(factor + max_x, factor + margin - max_x); if (smallest_size < 8 && max_x > 5) max_x /= 1.5; + if (smallest_size < 6 && max_x > 4) max_x /= 4.0; for (x = 0; x < max_x; x++) { _height_map.height(x, y) = 0; } /* Bottom left */ max_x = abs((perlin_coast_noise_2D(_height_map.size_y - y, y, 0.85, 101) + 0.3) * 6 + (perlin_coast_noise_2D(y, y, 0.45, 67) + 0.75) * 8); - max_x = max((smallest_size * smallest_size / 16) + max_x, (smallest_size * smallest_size / 16) + margin - max_x); + max_x = max(factor + max_x, factor + margin - max_x); if (smallest_size < 8 && max_x > 5) max_x /= 1.5; - for (x = _height_map.size_x; x > (_height_map.size_x - 1 - max_x); x--) { + if (smallest_size < 6 && max_x > 4) max_x /= 4.0; + for (x = _height_map.size_x; x > (_height_map.size_x - 1 - max_x) && x > 0; x--) { _height_map.height(x, y) = 0; } } @@ -604,8 +609,9 @@ for (x = 0; x <= _height_map.size_x; x++) { /* Top left */ max_y = abs((perlin_coast_noise_2D(x, _height_map.size_y / 2, 0.9, 167) + 0.4) * 5 + (perlin_coast_noise_2D(x, _height_map.size_y / 3, 0.4, 211) + 0.7) * 9); - max_y = max((smallest_size * smallest_size / 16) + max_y, (smallest_size * smallest_size / 16) + margin - max_y); + max_y = max(factor + max_y, factor + margin - max_y); if (smallest_size < 8 && max_y > 5) max_y /= 1.5; + if (smallest_size < 6 && max_y > 4) max_y /= 4.0; for (y = 0; y < max_y; y++) { _height_map.height(x, y) = 0; } @@ -613,9 +619,10 @@ /* Bottom right */ max_y = abs((perlin_coast_noise_2D(x, _height_map.size_y / 3, 0.85, 71) + 0.25) * 6 + (perlin_coast_noise_2D(x, _height_map.size_y / 3, 0.35, 193) + 0.75) * 12); - max_y = max((smallest_size * smallest_size / 16) + max_y, (smallest_size * smallest_size / 16) + margin - max_y); + max_y = max(factor + max_y, factor + margin - max_y); if (smallest_size < 8 && max_y > 5) max_y /= 1.5; - for (y = _height_map.size_y; y > (_height_map.size_y - 1 - max_y); y--) { + if (smallest_size < 6 && max_y > 4) max_y /= 4.0; + for (y = _height_map.size_y; y > (_height_map.size_y - 1 - max_y) && y > 0; y--) { _height_map.height(x, y) = 0; } } @@ -711,10 +718,10 @@ HeightMapAdjustWaterLevel(water_percent, h_max_new); - //HeightMapCoastLines(); + HeightMapCoastLines(); HeightMapSmoothSlopes(roughness); - //HeightMapSmoothCoasts(); + HeightMapSmoothCoasts(); HeightMapSmoothSlopes(roughness); HeightMapSineTransform(12, h_max_new);