equal
deleted
inserted
replaced
340 log_frequency_min = log_size_min - 6; |
340 log_frequency_min = log_size_min - 6; |
341 |
341 |
342 do { |
342 do { |
343 log_frequency = iteration_round - log_frequency_min; |
343 log_frequency = iteration_round - log_frequency_min; |
344 if (log_frequency >= 0) { |
344 if (log_frequency >= 0) { |
345 amplitude = _amplitudes_by_smoothness_and_frequency[_patches.tgen_smoothness][log_frequency]; |
345 amplitude = _amplitudes_by_smoothness_and_frequency[_settings.game_creation.tgen_smoothness][log_frequency]; |
346 } else { |
346 } else { |
347 amplitude = 0; |
347 amplitude = 0; |
348 } |
348 } |
349 continue_iteration = ApplyNoise(iteration_round, amplitude); |
349 continue_iteration = ApplyNoise(iteration_round, amplitude); |
350 iteration_round++; |
350 iteration_round++; |
529 * Please note that all the small numbers; 53, 101, 167, etc. are small primes |
529 * Please note that all the small numbers; 53, 101, 167, etc. are small primes |
530 * to help give the perlin noise a bit more of a random feel. |
530 * to help give the perlin noise a bit more of a random feel. |
531 */ |
531 */ |
532 static void HeightMapCoastLines() |
532 static void HeightMapCoastLines() |
533 { |
533 { |
534 int smallest_size = min(_patches.map_x, _patches.map_y); |
534 int smallest_size = min(_settings.game_creation.map_x, _settings.game_creation.map_y); |
535 const int margin = 4; |
535 const int margin = 4; |
536 uint y, x; |
536 uint y, x; |
537 double max_x; |
537 double max_x; |
538 double max_y; |
538 double max_y; |
539 |
539 |
661 * - height histogram redistribution by sine wave transform */ |
661 * - height histogram redistribution by sine wave transform */ |
662 static void HeightMapNormalize() |
662 static void HeightMapNormalize() |
663 { |
663 { |
664 const amplitude_t water_percent = _water_percent[_opt.diff.quantity_sea_lakes]; |
664 const amplitude_t water_percent = _water_percent[_opt.diff.quantity_sea_lakes]; |
665 const height_t h_max_new = I2H(_max_height[_opt.diff.terrain_type]); |
665 const height_t h_max_new = I2H(_max_height[_opt.diff.terrain_type]); |
666 const height_t roughness = 7 + 3 * _patches.tgen_smoothness; |
666 const height_t roughness = 7 + 3 * _settings.game_creation.tgen_smoothness; |
667 |
667 |
668 HeightMapAdjustWaterLevel(water_percent, h_max_new); |
668 HeightMapAdjustWaterLevel(water_percent, h_max_new); |
669 |
669 |
670 HeightMapCoastLines(); |
670 HeightMapCoastLines(); |
671 HeightMapSmoothSlopes(roughness); |
671 HeightMapSmoothSlopes(roughness); |
690 * prime is used to allow the perlin noise generator to create useful random |
690 * prime is used to allow the perlin noise generator to create useful random |
691 * numbers from slightly different series. |
691 * numbers from slightly different series. |
692 */ |
692 */ |
693 static double int_noise(const long x, const long y, const int prime) |
693 static double int_noise(const long x, const long y, const int prime) |
694 { |
694 { |
695 long n = x + y * prime + _patches.generation_seed; |
695 long n = x + y * prime + _settings.game_creation.generation_seed; |
696 |
696 |
697 n = (n << 13) ^ n; |
697 n = (n << 13) ^ n; |
698 |
698 |
699 /* Pseudo-random number generator, using several large primes */ |
699 /* Pseudo-random number generator, using several large primes */ |
700 return 1.0 - (double)((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0; |
700 return 1.0 - (double)((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0; |