--- /tmp/viewport.cpp +++ /home/zigieteusz/Programowanie/OpenTTD/clean/trunk/src/viewport.cpp @@ -1504,27 +1504,21 @@ * for x and y. */ int x = (row - column) / 2; int y = (row + column) / 2; - tile_info.x = x; - tile_info.y = y; - - /* For some strange reason, those fields inside tile_info are uints. However, - * in the old code their copies in an int variable where compared against zero. */ - if (IsInsideMM(x, _settings_game.construction.freeform_edges ? 1 : 0, MapMaxX()) && - IsInsideMM(y, _settings_game.construction.freeform_edges ? 1 : 0, MapMaxY())) { - /* We are inside the map => paint landscape. */ - tile_info.tile = TileXY(tile_info.x, tile_info.y); - tile_info.tileh = GetTilePixelSlope(tile_info.tile, &tile_info.z); + + if (IsInsideMM(x, 0, MapSizeX()) && IsInsideMM(y, 0, MapSizeY())) { + tile_info.tile = TileXY(x, y); tile_type = GetTileType(tile_info.tile); } else { - /* We are outside the map => paint black. */ tile_info.tile = INVALID_TILE; - tile_info.tileh = GetTilePixelSlopeOutsideMap(tile_info.x, tile_info.y, &tile_info.z); tile_type = MP_VOID; } - /* Scale to 16x16 tiles, needed for the drawing procedures called below. */ - tile_info.x *= TILE_SIZE; - tile_info.y *= TILE_SIZE; + tile_info.tileh = (tile_type != MP_VOID) ? + GetTilePixelSlope(tile_info.tile, &tile_info.z) : + GetTilePixelSlopeOutsideMap(x, y, &tile_info.z); + + tile_info.x = x * TILE_SIZE; + tile_info.y = y * TILE_SIZE; _vd.foundation_part = FOUNDATION_PART_NONE; _vd.foundation[0] = -1; @@ -1533,7 +1527,7 @@ _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); } } }