Mercurial > hg > openttd
changeset 7766:f0585ed32dd3 draft
(svn r11315) -Fix [FS#1353]: towns are not growing beyond height differences. Patch by skidd13.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sat, 20 Oct 2007 17:38:23 +0000 |
parents | aa5048ea50a0 |
children | 33f9ed104293 |
files | src/town_cmd.cpp |
diffstat | 1 files changed, 31 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -732,16 +732,14 @@ if (desired_slope != cur_slope && ComplementSlope(desired_slope) != cur_slope) { uint32 r = Random(); - if (CHANCE16I(1, 8, r) && !_generating_world) { - CommandCost res; - - if (CHANCE16I(1, 16, r)) { - res = DoCommand(tile, cur_slope, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_TERRAFORM_LAND); - } else { + if (CHANCE16I(1, 8, r)) { + CommandCost res = CMD_ERROR; + if (!_generating_world && CHANCE16I(1, 10, r >> 4)) { /* Note: Do not replace " ^ 0xF" with ComplementSlope(). The slope might be steep. */ - res = DoCommand(tile, cur_slope ^ 0xF, 1, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_TERRAFORM_LAND); + res = DoCommand(tile, CHANCE16I(1, 16, r >> 8) ? cur_slope : cur_slope ^ 0xF, 0, + DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_TERRAFORM_LAND); } - if (CmdFailed(res) && CHANCE16I(1, 3, r)) { + if (CmdFailed(res) && CHANCE16I(1, 3, r >> 16)) { /* We can consider building on the slope, though. */ goto no_slope; } @@ -810,38 +808,33 @@ break; } - /* Stop if the tile is not a part of the grid lines */ - if (rcmd == ROAD_NONE) return rcmd; - /* Optimise only X-junctions */ - if (COUNTBITS(rcmd) != 2) { - RoadBits rb_template; - - switch (GetTileSlope(tile, NULL)) { - default: rb_template = ROAD_ALL; break; - case SLOPE_W: rb_template = ROAD_NW | ROAD_SW; break; - case SLOPE_SW: rb_template = ROAD_Y | ROAD_SW; break; - case SLOPE_S: rb_template = ROAD_SW | ROAD_SE; break; - case SLOPE_SE: rb_template = ROAD_X | ROAD_SE; break; - case SLOPE_E: rb_template = ROAD_SE | ROAD_NE; break; - case SLOPE_NE: rb_template = ROAD_Y | ROAD_NE; break; - case SLOPE_N: rb_template = ROAD_NE | ROAD_NW; break; - case SLOPE_NW: rb_template = ROAD_X | ROAD_NW; break; - case SLOPE_STEEP_W: - case SLOPE_STEEP_S: - case SLOPE_STEEP_E: - case SLOPE_STEEP_N: - rb_template = ROAD_NONE; - break; - } - - /* Stop if the template is compatible to the growth dir */ - if (DiagDirToRoadBits(ReverseDiagDir(dir)) & rb_template) return rb_template; - /* If not generate a straight road in the direction of the growth */ - return DiagDirToRoadBits(dir) | DiagDirToRoadBits(ReverseDiagDir(dir)); + if (rcmd != ROAD_ALL) return rcmd; + + RoadBits rb_template; + + switch (GetTileSlope(tile, NULL)) { + default: rb_template = ROAD_ALL; break; + case SLOPE_W: rb_template = ROAD_NW | ROAD_SW; break; + case SLOPE_SW: rb_template = ROAD_Y | ROAD_SW; break; + case SLOPE_S: rb_template = ROAD_SW | ROAD_SE; break; + case SLOPE_SE: rb_template = ROAD_X | ROAD_SE; break; + case SLOPE_E: rb_template = ROAD_SE | ROAD_NE; break; + case SLOPE_NE: rb_template = ROAD_Y | ROAD_NE; break; + case SLOPE_N: rb_template = ROAD_NE | ROAD_NW; break; + case SLOPE_NW: rb_template = ROAD_X | ROAD_NW; break; + case SLOPE_STEEP_W: + case SLOPE_STEEP_S: + case SLOPE_STEEP_E: + case SLOPE_STEEP_N: + rb_template = ROAD_NONE; + break; } - return rcmd; + /* Stop if the template is compatible to the growth dir */ + if (DiagDirToRoadBits(ReverseDiagDir(dir)) & rb_template) return rb_template; + /* If not generate a straight road in the direction of the growth */ + return DiagDirToRoadBits(dir) | DiagDirToRoadBits(ReverseDiagDir(dir)); } /** @@ -1106,7 +1099,7 @@ /* Build a house, but not if there already is a house there. */ if (!IsTileType(house_tile, MP_HOUSE)) { /* Level the land if possible */ - LevelTownLand(house_tile); + if (CHANCE16(1, 6)) LevelTownLand(house_tile); /* And build a house. * Set result to -1 if we managed to build it. */