1
0
Fork 0

(svn r22706) -Cleanup: A loop is no loop, if it never iterates.

release/1.2
frosch 2011-07-31 09:42:05 +00:00
parent 7b418502ab
commit ae8f53a403
1 changed files with 31 additions and 34 deletions

View File

@ -776,26 +776,24 @@ static bool IsRoadAllowedHere(Town *t, TileIndex tile, DiagDirection dir)
{ {
if (DistanceFromEdge(tile) == 0) return false; if (DistanceFromEdge(tile) == 0) return false;
Slope cur_slope, desired_slope;
for (;;) {
/* Check if there already is a road at this point? */ /* Check if there already is a road at this point? */
if (GetTownRoadBits(tile) == ROAD_NONE) { if (GetTownRoadBits(tile) == ROAD_NONE) {
/* No, try if we are able to build a road piece there. /* No, try if we are able to build a road piece there.
* If that fails clear the land, and if that fails exit. * If that fails clear the land, and if that fails exit.
* This is to make sure that we can build a road here later. */ * This is to make sure that we can build a road here later. */
if (DoCommand(tile, ((dir == DIAGDIR_NW || dir == DIAGDIR_SE) ? ROAD_Y : ROAD_X), 0, DC_AUTO, CMD_BUILD_ROAD).Failed() && if (DoCommand(tile, ((dir == DIAGDIR_NW || dir == DIAGDIR_SE) ? ROAD_Y : ROAD_X), 0, DC_AUTO, CMD_BUILD_ROAD).Failed() &&
DoCommand(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR).Failed()) DoCommand(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR).Failed()) {
return false; return false;
} }
}
cur_slope = _settings_game.construction.build_on_slopes ? GetFoundationSlope(tile, NULL) : GetTileSlope(tile, NULL); Slope cur_slope = _settings_game.construction.build_on_slopes ? GetFoundationSlope(tile, NULL) : GetTileSlope(tile, NULL);
bool ret = !IsNeighborRoadTile(tile, dir, t->layout == TL_ORIGINAL ? 1 : 2); bool ret = !IsNeighborRoadTile(tile, dir, t->layout == TL_ORIGINAL ? 1 : 2);
if (cur_slope == SLOPE_FLAT) return ret; if (cur_slope == SLOPE_FLAT) return ret;
/* If the tile is not a slope in the right direction, then /* If the tile is not a slope in the right direction, then
* maybe terraform some. */ * maybe terraform some. */
desired_slope = (dir == DIAGDIR_NW || dir == DIAGDIR_SE) ? SLOPE_NW : SLOPE_NE; Slope desired_slope = (dir == DIAGDIR_NW || dir == DIAGDIR_SE) ? SLOPE_NW : SLOPE_NE;
if (desired_slope != cur_slope && ComplementSlope(desired_slope) != cur_slope) { if (desired_slope != cur_slope && ComplementSlope(desired_slope) != cur_slope) {
if (Chance16(1, 8)) { if (Chance16(1, 8)) {
CommandCost res = CMD_ERROR; CommandCost res = CMD_ERROR;
@ -812,7 +810,6 @@ static bool IsRoadAllowedHere(Town *t, TileIndex tile, DiagDirection dir)
return false; return false;
} }
return ret; return ret;
}
} }
static bool TerraformTownTile(TileIndex tile, int edges, int dir) static bool TerraformTownTile(TileIndex tile, int edges, int dir)