Changeset - r16088:945d6e309a50
[Not reviewed]
master
0 1 0
frosch - 14 years ago 2010-09-12 19:40:47
frosch@openttd.org
(svn r20791) -Fix (r12161): Building 2x2 houses did not work for 2x2 road layouts on all map sizes.
1 file changed with 7 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/town_cmd.cpp
Show inline comments
 
@@ -1984,18 +1984,19 @@ static inline bool TownLayoutAllows2x2Ho
 
	/* 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:
0 comments (0 inline, 0 general)