diff options
author | Erich Eckner <git@eckner.net> | 2018-11-05 11:12:09 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-11-16 19:11:46 +0100 |
commit | a4701d576e54a47745a19d89e691c791a4f181ed (patch) | |
tree | f5ca7a7f7479bf169b9ae92cd2367317edf76f74 /src | |
parent | 5430113f4a842e519d2661a490022dcdf86f5247 (diff) | |
download | openttd-a4701d576e54a47745a19d89e691c791a4f181ed.tar.xz |
src/landscape.cpp, src/tile_map.h: fix bug which makes assert fail
Diffstat (limited to 'src')
-rw-r--r-- | src/landscape.cpp | 30 | ||||
-rw-r--r-- | src/tile_map.h | 7 |
2 files changed, 21 insertions, 16 deletions
diff --git a/src/landscape.cpp b/src/landscape.cpp index 18f27807d..152aceda7 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -35,6 +35,7 @@ #include "framerate_type.h" #include <list> #include <set> +#include "layer_func.h" #include "table/strings.h" #include "table/sprites.h" @@ -760,22 +761,25 @@ void RunTileLoop() void InitializeLandscape() { - uint maxx = MapMaxX(); - uint maxy = MapMaxY(); + uint maxx = LayerMaxX(); + uint maxy = LayerMaxY(); uint sizex = MapSizeX(); - - uint y; - for (y = _settings_game.construction.freeform_edges ? 1 : 0; y < maxy; y++) { - uint x; - for (x = _settings_game.construction.freeform_edges ? 1 : 0; x < maxx; x++) { - MakeClear(sizex * y + x, CLEAR_GRASS, 3); - SetTileHeight(sizex * y + x, 0); - SetTropicZone(sizex * y + x, TROPICZONE_NORMAL); - ClearBridgeMiddle(sizex * y + x); + uint layersize = LayerSize(); + + FOR_ALL_LAYERS(layer) { + uint y; + for (y = _settings_game.construction.freeform_edges ? 1 : 0; y < maxy; y++) { + uint x; + for (x = _settings_game.construction.freeform_edges ? 1 : 0; x < maxx; x++) { + MakeClear(layer * layersize + sizex * y + x, CLEAR_GRASS, 3); + SetTileHeight(layer * layersize + sizex * y + x, 0); + SetTropicZone(layer * layersize + sizex * y + x, TROPICZONE_NORMAL); + ClearBridgeMiddle(layer * layersize + sizex * y + x); + } + MakeVoid(layer * layersize + sizex * y + x); } - MakeVoid(sizex * y + x); + for (uint x = 0; x < sizex; x++) MakeVoid(layer * layersize + sizex * y + x); } - for (uint x = 0; x < sizex; x++) MakeVoid(sizex * y + x); } static const byte _genterrain_tbl_1[5] = { 10, 22, 33, 37, 4 }; diff --git a/src/tile_map.h b/src/tile_map.h index 58dff2cb0..0e2cc8ec2 100644 --- a/src/tile_map.h +++ b/src/tile_map.h @@ -16,6 +16,7 @@ #include "map_func.h" #include "core/bitmath_func.hpp" #include "settings_type.h" +#include "layer_func.h" /** * Returns the height of a tile @@ -103,10 +104,10 @@ static inline bool IsInnerTile(TileIndex tile) { assert(tile < MapSize()); - uint x = TileX(tile); - uint y = TileY(tile); + uint x = LayerX(tile); + uint y = LayerY(tile); - return x < MapMaxX() && y < MapMaxY() && ((x > 0 && y > 0) || !_settings_game.construction.freeform_edges); + return x < LayerMaxX() && y < LayerMaxY() && ((x > 0 && y > 0) || !_settings_game.construction.freeform_edges); } /** |