Merge branch 'master' into jgrpp

# Conflicts:
#	.github/workflows/commit-checker.yml
#	src/industry_cmd.cpp
#	src/industry_gui.cpp
#	src/landscape.cpp
#	src/linkgraph/linkgraph_gui.cpp
#	src/order_base.h
#	src/order_cmd.cpp
#	src/order_gui.cpp
#	src/saveload/afterload.cpp
#	src/saveload/league_sl.cpp
#	src/saveload/saveload.h
#	src/script/api/script_object.hpp
#	src/script/squirrel_helper.hpp
#	src/settings_table.cpp
#	src/station_cmd.cpp
#	src/table/settings.h.preamble
#	src/tree_cmd.cpp
#	src/tree_map.h
#	src/vehicle.cpp
#	src/waypoint_cmd.cpp
This commit is contained in:
Jonathan G Rennison
2023-03-04 16:44:23 +00:00
94 changed files with 1075 additions and 1558 deletions

View File

@@ -930,12 +930,15 @@ static void GenerateTerrain(int type, uint flag)
{
uint32 r = Random();
const Sprite *templ = GetSprite((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + 4845, ST_MAPGEN);
/* Choose one of the templates from the graphics file. */
const Sprite *templ = GetSprite((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + SPR_MAPGEN_BEGIN, ST_MAPGEN);
if (templ == nullptr) usererror("Map generator sprites could not be loaded");
/* Chose a random location to apply the template to. */
uint x = r & MapMaxX();
uint y = (r >> MapLogX()) & MapMaxY();
/* Make sure the template is not too close to the upper edges; bottom edges are checked later. */
uint edge_distance = 1 + (_settings_game.construction.freeform_edges ? 1 : 0);
if (x <= edge_distance || y <= edge_distance) return;
@@ -948,6 +951,9 @@ static void GenerateTerrain(int type, uint flag)
const byte *p = templ->data;
if ((flag & 4) != 0) {
/* This is only executed in secondary/tertiary loops to generate the terrain for arctic and tropic.
* It prevents the templates to be applied to certain parts of the map based on the flags, thus
* creating regions with different elevations/topography. */
uint xw = x * MapSizeY();
uint yw = y * MapSizeX();
uint bias = (MapSizeX() + MapSizeY()) * 16;
@@ -972,11 +978,15 @@ static void GenerateTerrain(int type, uint flag)
}
}
/* Ensure the template does not overflow at the bottom edges of the map; upper edges were checked before. */
if (x + w >= MapMaxX()) return;
if (y + h >= MapMaxY()) return;
TileIndex tile = TileXY(x, y);
/* Get the template and overlay in a particular direction over the map's height from the given
* origin point (tile), and update the map's height everywhere where the height from the template
* is higher than the height of the map. In other words, this only raises the tile heights. */
switch (direction) {
default: NOT_REACHED();
case DIAGDIR_NE: