summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-11-05 11:12:09 +0100
committerErich Eckner <git@eckner.net>2022-01-16 21:58:15 +0100
commit9670d858c828102387be0d86a6890de50a8f0fca (patch)
tree21c241fe15a3e7109f96be7481758dac15e85b56
parent0c5ba5b7bf9a9dfa78c026f4da656940a460f47d (diff)
downloadopenttd-9670d858c828102387be0d86a6890de50a8f0fca.tar.xz
src/landscape.cpp, src/tile_map.h: fix bug which makes assert fail
-rw-r--r--src/landscape.cpp25
-rw-r--r--src/tile_map.h7
2 files changed, 20 insertions, 12 deletions
diff --git a/src/landscape.cpp b/src/landscape.cpp
index b921deef2..ac9040e16 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -35,6 +35,7 @@
#include <array>
#include <list>
#include <set>
+#include "layer_func.h"
#include "table/strings.h"
#include "table/sprites.h"
@@ -835,17 +836,23 @@ void RunTileLoop()
void InitializeLandscape()
{
- for (uint y = _settings_game.construction.freeform_edges ? 1 : 0; y < MapMaxY(); y++) {
- for (uint x = _settings_game.construction.freeform_edges ? 1 : 0; x < MapMaxX(); x++) {
- MakeClear(TileXY(x, y), CLEAR_GRASS, 3);
- SetTileHeight(TileXY(x, y), 0);
- SetTropicZone(TileXY(x, y), TROPICZONE_NORMAL);
- ClearBridgeMiddle(TileXY(x, y));
+ uint maxx = LayerMaxX();
+ uint maxy = LayerMaxY();
+ uint sizex = MapSizeX();
+ uint layersize = LayerSize();
+
+ FOR_ALL_LAYERS(layer) {
+ for (uint y = _settings_game.construction.freeform_edges ? 1 : 0; y < LayerMaxY(); y++) {
+ for (uint x = _settings_game.construction.freeform_edges ? 1 : 0; x < LayerMaxX(); x++) {
+ MakeClear(layer * layersize + TileXY(x, y), CLEAR_GRASS, 3);
+ SetTileHeight(layer * layersize + TileXY(x, y), 0);
+ SetTropicZone(layer * layersize + TileXY(x, y), TROPICZONE_NORMAL);
+ ClearBridgeMiddle(layer * layersize + TileXY(x, y));
+ }
+ MakeVoid(layer * layersize + TileXY(LayerMaxX(), y));
}
+ for (uint x = 0; x < LayerSizeX(); x++) MakeVoid(TileXY(x, LayerMaxY()));
}
-
- for (uint x = 0; x < MapSizeX(); x++) MakeVoid(TileXY(x, MapMaxY()));
- for (uint y = 0; y < MapSizeY(); y++) MakeVoid(TileXY(MapMaxX(), y));
}
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 4bd584539..c191ab904 100644
--- a/src/tile_map.h
+++ b/src/tile_map.h
@@ -14,6 +14,7 @@
#include "map_func.h"
#include "core/bitmath_func.hpp"
#include "settings_type.h"
+#include "layer_func.h"
/**
* Returns the height of a tile
@@ -110,10 +111,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);
}
/**