Mercurial > hg > openttd
changeset 16098:69fa0c82f849 draft
(svn r20791) -Fix (r12161): Building 2x2 houses did not work for 2x2 road layouts on all map sizes.
author | frosch <frosch@openttd.org> |
---|---|
date | Sun, 12 Sep 2010 19:40:47 +0000 |
parents | 53de12768241 |
children | 084184db4653 |
files | src/town_cmd.cpp |
diffstat | 1 files changed, 7 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -1984,18 +1984,19 @@ /* Allow towns everywhere when we don't build roads */ if (!_settings_game.economy.allow_town_roads && !_generating_world) return true; - /* MapSize() is sure dividable by both MapSizeX() and MapSizeY(), - * so to do only one memory access, use MapSize() */ - uint dx = MapSize() + TileX(t->xy) - TileX(tile); - uint dy = MapSize() + TileY(t->xy) - TileY(tile); + /* Compute relative position of tile. (Positive offsets are towards north) */ + TileIndexDiffC grid_pos = TileIndexToTileIndexDiffC(t->xy, tile); switch (t->layout) { case TL_2X2_GRID: - if ((dx % 3) != 0 || (dy % 3) != 0) return false; + grid_pos.x %= 3; + grid_pos.y %= 3; + if ((grid_pos.x != 2 && grid_pos.x != -1) || + (grid_pos.y != 2 && grid_pos.y != -1)) return false; break; case TL_3X3_GRID: - if ((dx % 4) < 2 || (dy % 4) < 2) return false; + if ((grid_pos.x & 3) < 2 || (grid_pos.y & 3) < 2) return false; break; default: