Merge branch 'master' into jgrpp

# Conflicts:
#	cmake/CompileFlags.cmake
#	src/aircraft_cmd.cpp
#	src/blitter/32bpp_anim.cpp
#	src/cargopacket.cpp
#	src/cheat_gui.cpp
#	src/company_cmd.cpp
#	src/company_gui.cpp
#	src/core/pool_func.hpp
#	src/date.cpp
#	src/economy.cpp
#	src/error_gui.cpp
#	src/ground_vehicle.cpp
#	src/ground_vehicle.hpp
#	src/group_gui.cpp
#	src/industry_cmd.cpp
#	src/lang/dutch.txt
#	src/lang/french.txt
#	src/lang/german.txt
#	src/linkgraph/linkgraph_gui.cpp
#	src/linkgraph/mcf.cpp
#	src/network/network_content.cpp
#	src/network/network_server.cpp
#	src/network/network_udp.cpp
#	src/newgrf_engine.cpp
#	src/newgrf_station.cpp
#	src/order_cmd.cpp
#	src/order_gui.cpp
#	src/pathfinder/follow_track.hpp
#	src/pathfinder/yapf/yapf_common.hpp
#	src/saveload/saveload.cpp
#	src/settings_gui.cpp
#	src/station_cmd.cpp
#	src/station_kdtree.h
#	src/string_func.h
#	src/table/settings.ini
#	src/tgp.cpp
#	src/timetable_cmd.cpp
#	src/timetable_gui.cpp
#	src/toolbar_gui.cpp
#	src/town_cmd.cpp
#	src/train_cmd.cpp
#	src/train_gui.cpp
#	src/tree_gui.cpp
#	src/tunnelbridge_cmd.cpp
#	src/vehicle.cpp
#	src/vehicle_gui.cpp
#	src/video/sdl2_v.cpp
#	src/video/sdl_v.cpp
#	src/video/win32_v.cpp
#	src/viewport.cpp
#	src/viewport_sprite_sorter_sse4.cpp
#	src/window.cpp
This commit is contained in:
Jonathan G Rennison
2021-02-01 17:07:34 +00:00
290 changed files with 2135 additions and 1577 deletions

View File

@@ -235,8 +235,28 @@ static height_t TGPGetMaxHeight()
{ 12, 19, 25, 31, 67, 75, 87 }, ///< Alpinist
};
int max_height_from_table = max_height[_settings_game.difficulty.terrain_type][min<unsigned int>(max_height_array_size - 1, min(MapLogX(), MapLogY()) - MIN_MAP_SIZE_BITS)];
return I2H(min(max_height_from_table, _settings_game.construction.max_heightlevel));
int map_size_bucket = std::min(MapLogX(), MapLogY()) - MIN_MAP_SIZE_BITS;
int max_height_from_table = max_height[_settings_game.difficulty.terrain_type][map_size_bucket];
/* Arctic needs snow to have all industries, so make sure we allow TGP to generate this high. */
if (_settings_game.game_creation.landscape == LT_ARCTIC) {
max_height_from_table += _settings_newgame.game_creation.snow_line_height;
/* Make flat a bit more flat by removing "very flat" from it, to somewhat compensate for the increase we just did. */
if (_settings_game.difficulty.terrain_type > 0) {
max_height_from_table -= max_height[_settings_game.difficulty.terrain_type - 1][map_size_bucket];
}
}
/* Tropic needs tropical forest to have all industries, so make sure we allow TGP to generate this high.
* Tropic forest always starts at 1/4th of the max height. */
if (_settings_game.game_creation.landscape == LT_TROPIC) {
max_height_from_table += CeilDiv(_settings_game.construction.max_heightlevel, 4);
/* Make flat a bit more flat by removing "very flat" from it, to somewhat compensate for the increase we just did. */
if (_settings_game.difficulty.terrain_type > 0) {
max_height_from_table -= max_height[_settings_game.difficulty.terrain_type - 1][map_size_bucket];
}
}
return I2H(std::min<uint>(max_height_from_table, _settings_game.construction.max_heightlevel));
}
/**
@@ -271,7 +291,7 @@ static amplitude_t GetAmplitude(int frequency)
/* 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)];
amplitude_t amplitude = amplitudes[smoothness][std::max(0, index)];
if (index >= 0) return amplitude;
/* We need to extrapolate the amplitude. */
@@ -350,7 +370,7 @@ static void HeightMapGenerate()
/* Trying to apply noise to uninitialized height map */
assert(_height_map.h != nullptr);
int start = max(MAX_TGP_FREQUENCIES - (int)min(MapLogX(), MapLogY()), 0);
int start = std::max(MAX_TGP_FREQUENCIES - (int)std::min(MapLogX(), MapLogY()), 0);
bool first = true;
for (int frequency = start; frequency < MAX_TGP_FREQUENCIES; frequency++) {
@@ -726,7 +746,7 @@ static double perlin_coast_noise_2D(const double x, const double y, const double
*/
static void HeightMapCoastLines(uint8 water_borders)
{
int smallest_size = min(_settings_game.game_creation.map_x, _settings_game.game_creation.map_y);
int smallest_size = std::min(_settings_game.game_creation.map_x, _settings_game.game_creation.map_y);
const int margin = 4;
int y, x;
double max_x;
@@ -737,7 +757,7 @@ static void HeightMapCoastLines(uint8 water_borders)
if (HasBit(water_borders, BORDER_NE)) {
/* 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 / 64) + max_x, (smallest_size * smallest_size / 64) + margin - max_x);
max_x = std::max((smallest_size * smallest_size / 64) + max_x, (smallest_size * smallest_size / 64) + margin - max_x);
if (smallest_size < 8 && max_x > 5) max_x /= 1.5;
for (x = 0; x < max_x; x++) {
_height_map.height(x, y) = 0;
@@ -747,7 +767,7 @@ static void HeightMapCoastLines(uint8 water_borders)
if (HasBit(water_borders, BORDER_SW)) {
/* 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 / 64) + max_x, (smallest_size * smallest_size / 64) + margin - max_x);
max_x = std::max((smallest_size * smallest_size / 64) + max_x, (smallest_size * smallest_size / 64) + 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--) {
_height_map.height(x, y) = 0;
@@ -760,7 +780,7 @@ static void HeightMapCoastLines(uint8 water_borders)
if (HasBit(water_borders, BORDER_NW)) {
/* 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 / 64) + max_y, (smallest_size * smallest_size / 64) + margin - max_y);
max_y = std::max((smallest_size * smallest_size / 64) + max_y, (smallest_size * smallest_size / 64) + margin - max_y);
if (smallest_size < 8 && max_y > 5) max_y /= 1.5;
for (y = 0; y < max_y; y++) {
_height_map.height(x, y) = 0;
@@ -770,7 +790,7 @@ static void HeightMapCoastLines(uint8 water_borders)
if (HasBit(water_borders, BORDER_SE)) {
/* 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 / 64) + max_y, (smallest_size * smallest_size / 64) + margin - max_y);
max_y = std::max((smallest_size * smallest_size / 64) + max_y, (smallest_size * smallest_size / 64) + 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--) {
_height_map.height(x, y) = 0;
@@ -810,7 +830,7 @@ static void HeightMapSmoothCoastInDirection(int org_x, int org_y, int dir_x, int
* Soften the coast slope */
for (depth = 0; IsValidXY(x, y) && depth <= max_coast_Smooth_depth; depth++, x += dir_x, y += dir_y) {
h = _height_map.height(x, y);
h = min(h, h_prev + (4 + depth)); // coast softening formula
h = std::min<uint>(h, h_prev + (4 + depth)); // coast softening formula
_height_map.height(x, y) = h;
h_prev = h;
}
@@ -843,13 +863,13 @@ static void HeightMapSmoothSlopes(height_t dh_max)
{
for (int y = 0; y <= (int)_height_map.size_y; y++) {
for (int x = 0; x <= (int)_height_map.size_x; x++) {
height_t h_max = min(_height_map.height(x > 0 ? x - 1 : x, y), _height_map.height(x, y > 0 ? y - 1 : y)) + dh_max;
height_t h_max = std::min(_height_map.height(x > 0 ? x - 1 : x, y), _height_map.height(x, y > 0 ? y - 1 : y)) + dh_max;
if (_height_map.height(x, y) > h_max) _height_map.height(x, y) = h_max;
}
}
for (int y = _height_map.size_y; y >= 0; y--) {
for (int x = _height_map.size_x; x >= 0; x--) {
height_t h_max = min(_height_map.height(x < _height_map.size_x ? x + 1 : x, y), _height_map.height(x, y < _height_map.size_y ? y + 1 : y)) + dh_max;
height_t h_max = std::min(_height_map.height(x < _height_map.size_x ? x + 1 : x, y), _height_map.height(x, y < _height_map.size_y ? y + 1 : y)) + dh_max;
if (_height_map.height(x, y) > h_max) _height_map.height(x, y) = h_max;
}
}