summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2015-02-22 15:05:48 +0000
committerfrosch <frosch@openttd.org>2015-02-22 15:05:48 +0000
commitf26e9bf59dd953ab76bf816ba7aad87638c22c21 (patch)
tree6a549a5da8e624a83d4144dfad901e11265fbcbc /src
parent3adf082db258d04728cf573c0d79ee708c502b7d (diff)
downloadopenttd-f26e9bf59dd953ab76bf816ba7aad87638c22c21.tar.xz
(svn r27162) -Fix [FS#6208]: Tile selection was drawn outside of map in some cases. (adf88)
Diffstat (limited to 'src')
-rw-r--r--src/viewport.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 01787f07a..ef23f1812 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -1142,18 +1142,23 @@ static void ViewportAddLandscape()
tile_info.x = tilecoord.x * TILE_SIZE; // FIXME tile_info should use signed integers
tile_info.y = tilecoord.y * TILE_SIZE;
- if (IsInsideBS(tilecoord.x, 0, MapMaxX()) && IsInsideBS(tilecoord.y, 0, MapMaxY())) {
- /* We are inside the map => paint landscape. */
+ if (IsInsideBS(tilecoord.x, 0, MapSizeX()) && IsInsideBS(tilecoord.y, 0, MapSizeY())) {
+ /* This includes the south border at MapMaxX / MapMaxY. When terraforming we still draw tile selections there. */
tile_info.tile = TileXY(tilecoord.x, tilecoord.y);
- tile_info.tileh = GetTilePixelSlope(tile_info.tile, &tile_info.z);
tile_type = GetTileType(tile_info.tile);
} else {
- /* We are outside the map => paint black. */
tile_info.tile = INVALID_TILE;
- tile_info.tileh = GetTilePixelSlopeOutsideMap(tilecoord.x, tilecoord.y, &tile_info.z);
tile_type = MP_VOID;
}
+ if (tile_type != MP_VOID) {
+ /* We are inside the map => paint landscape. */
+ tile_info.tileh = GetTilePixelSlope(tile_info.tile, &tile_info.z);
+ } else {
+ /* We are outside the map => paint black. */
+ tile_info.tileh = GetTilePixelSlopeOutsideMap(tilecoord.x, tilecoord.y, &tile_info.z);
+ }
+
int viewport_y = GetViewportY(tilecoord);
if (viewport_y + MAX_TILE_EXTENT_BOTTOM < _vd.dpi.top) {
@@ -1195,7 +1200,7 @@ static void ViewportAddLandscape()
_vd.last_foundation_child[1] = NULL;
_tile_type_procs[tile_type]->draw_tile_proc(&tile_info);
- DrawTileSelection(&tile_info);
+ if (tile_info.tile != INVALID_TILE) DrawTileSelection(&tile_info);
}
}
}