diff options
author | rubidium <rubidium@openttd.org> | 2007-01-12 08:37:14 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-01-12 08:37:14 +0000 |
commit | 5afd50017de25527e0d3334e9515e82a0299fe31 (patch) | |
tree | 2664aaead53681226541ca43d6c4c17d32e4c34c /src | |
parent | c3b56e0b3a684dfc8c28e0ab1612cda73847dd08 (diff) | |
download | openttd-5afd50017de25527e0d3334e9515e82a0299fe31.tar.xz |
(svn r8074) -Fix (FS#537, r7555, r5749): revert r7555 because it was really wrong and fix the off-by-one error due to truncation that was supposedly fixed by r7555.
Diffstat (limited to 'src')
-rw-r--r-- | src/heightmap.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/heightmap.cpp b/src/heightmap.cpp index 7d1809410..dc486fb07 100644 --- a/src/heightmap.cpp +++ b/src/heightmap.cpp @@ -304,11 +304,11 @@ static void GrayscaleToMapHeights(uint img_width, uint img_height, byte *map) if ((img_width * num_div) / img_height > ((width * num_div) / height)) { /* Image is wider than map - center vertically */ img_scale = (width * num_div) / img_width; - row_pad = (height - ((img_height * img_scale) / num_div)) / 2; + row_pad = (1 + height - ((img_height * img_scale) / num_div)) / 2; } else { /* Image is taller than map - center horizontally */ img_scale = (height * num_div) / img_height; - col_pad = (width - ((img_width * img_scale) / num_div)) / 2; + col_pad = (1 + width - ((img_width * img_scale) / num_div)) / 2; } /* Form the landscape */ @@ -322,8 +322,8 @@ static void GrayscaleToMapHeights(uint img_width, uint img_height, byte *map) /* Check if current tile is within the 1-pixel map edge or padding regions */ if ((DistanceFromEdge(tile) <= 1) || - (row < row_pad) || (row >= (img_height + row_pad)) || - (col < col_pad) || (col >= (img_width + col_pad))) { + (row < row_pad) || (row >= (height - row_pad - 1)) || + (col < col_pad) || (col >= (width - col_pad - 1))) { SetTileHeight(tile, 0); } else { /* Use nearest neighbor resizing to scale map data. |