mirror of https://github.com/OpenTTD/OpenTTD
(svn r27247) -Cleanup: Make GrowTownAtRoad return a bool.
parent
6bdae2f64a
commit
93d7db0b36
|
@ -1338,9 +1338,9 @@ static bool CanFollowRoad(TileIndex tile, DiagDirection dir)
|
||||||
* Returns "growth" if a house was built, or no if the build failed.
|
* Returns "growth" if a house was built, or no if the build failed.
|
||||||
* @param t town to inquiry
|
* @param t town to inquiry
|
||||||
* @param tile to inquiry
|
* @param tile to inquiry
|
||||||
* @return something other than zero(0)if town expansion was possible
|
* @return true if town expansion was possible
|
||||||
*/
|
*/
|
||||||
static int GrowTownAtRoad(Town *t, TileIndex tile)
|
static bool GrowTownAtRoad(Town *t, TileIndex tile)
|
||||||
{
|
{
|
||||||
/* Special case.
|
/* Special case.
|
||||||
* @see GrowTownInTile Check the else if
|
* @see GrowTownInTile Check the else if
|
||||||
|
@ -1377,7 +1377,7 @@ static int GrowTownAtRoad(Town *t, TileIndex tile)
|
||||||
* and return if no more road blocks available */
|
* and return if no more road blocks available */
|
||||||
if (IsValidDiagDirection(target_dir)) cur_rb &= ~DiagDirToRoadBits(ReverseDiagDir(target_dir));
|
if (IsValidDiagDirection(target_dir)) cur_rb &= ~DiagDirToRoadBits(ReverseDiagDir(target_dir));
|
||||||
if (cur_rb == ROAD_NONE) {
|
if (cur_rb == ROAD_NONE) {
|
||||||
return _grow_town_result;
|
return _grow_town_result != GROWTH_SEARCH_STOPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
||||||
|
@ -1387,7 +1387,7 @@ static int GrowTownAtRoad(Town *t, TileIndex tile)
|
||||||
/* Select a random bit from the blockmask, walk a step
|
/* Select a random bit from the blockmask, walk a step
|
||||||
* and continue the search from there. */
|
* and continue the search from there. */
|
||||||
do {
|
do {
|
||||||
if (cur_rb == ROAD_NONE) return GROWTH_SEARCH_STOPPED;
|
if (cur_rb == ROAD_NONE) return false;
|
||||||
RoadBits target_bits;
|
RoadBits target_bits;
|
||||||
do {
|
do {
|
||||||
target_dir = RandomDiagDir();
|
target_dir = RandomDiagDir();
|
||||||
|
@ -1413,7 +1413,7 @@ static int GrowTownAtRoad(Town *t, TileIndex tile)
|
||||||
/* Max number of times is checked. */
|
/* Max number of times is checked. */
|
||||||
} while (--_grow_town_result >= 0);
|
} while (--_grow_town_result >= 0);
|
||||||
|
|
||||||
return (_grow_town_result == -2);
|
return _grow_town_result == GROWTH_SUCCEED - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1464,9 +1464,9 @@ static bool GrowTown(Town *t)
|
||||||
const TileIndexDiffC *ptr;
|
const TileIndexDiffC *ptr;
|
||||||
for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) {
|
for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) {
|
||||||
if (GetTownRoadBits(tile) != ROAD_NONE) {
|
if (GetTownRoadBits(tile) != ROAD_NONE) {
|
||||||
int r = GrowTownAtRoad(t, tile);
|
bool success = GrowTownAtRoad(t, tile);
|
||||||
cur_company.Restore();
|
cur_company.Restore();
|
||||||
return r != 0;
|
return success;
|
||||||
}
|
}
|
||||||
tile = TILE_ADD(tile, ToTileIndexDiff(*ptr));
|
tile = TILE_ADD(tile, ToTileIndexDiff(*ptr));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue