FS#6208 - Tile selection is being drawn outside the map.

Attached to Project: OpenTTD
Opened by Grzegorz DuczyƄski (adf88) - Friday, 16 January 2015, 11:37 GMT
Last edited by frosch (frosch) - Sunday, 22 February 2015, 15:06 GMT
Type Bug
Category Core
Status Closed
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


1. start scenario editor
2. select "lower/raise land" tool
3. increase tool size
4. move cursor toward SE or SW map border
5. notice that selection "dots" are being drawn outside the map leaving artifacts behind

Bug introduced by "(svn r26899) -Codechange: reduce the amount of tiles that needs to be drawn by taking the height of tiles into account instead of drawing way too many (ic111)"

There is also a small issue that doesn't cause problems currently, but is dangerous and may cause bugs. ViewportAddLandscape fills in a TileInfo struct with the information of the tile that is being drawn currently. Before r26899, the TileInfo::tile for MP_VOID tiles was being set correctly (index of the MP_VOID tile). After r26899 TileInfo::tile is set to INVALID_TILE for booth MP_VOID tiles and non-existent tiles. It may cause problems e.g. the DrawPointSelection procedure when drawing MP_VOID tiles at SE and SW edges gets INVALID_TILE in the given TileInfo::tile. Fortunately, it doesn't refer to the TileInfo::tile field...

For sanity, the TileInfo::tile should be set correctly for every existing tile.

I'm attaching a fix (-p0), it requires  FS#6206 .

The fix changes the code in a way that tile selection is not being drawn for non-existent tiles. Also TileInfo::tile is being set correctly for every existent tile.
This task depends upon

Closed by  frosch (frosch)
Sunday, 22 February 2015, 15:06 GMT
Reason for closing:  Fixed
Additional comments about closing:  in r27162. Thanks for the patch!