summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2015-04-25 11:46:10 +0000
committerfrosch <frosch@openttd.org>2015-04-25 11:46:10 +0000
commit93d7db0b3608c7c081f8d291db6b8e93c942eb6e (patch)
treec341b478f9712b7bc2f502866c25eca860f95434
parent6bdae2f64aaa981894336b4b962204516b3f584c (diff)
downloadopenttd-93d7db0b3608c7c081f8d291db6b8e93c942eb6e.tar.xz
(svn r27247) -Cleanup: Make GrowTownAtRoad return a bool.
-rw-r--r--src/town_cmd.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 810499d04..2d03f4f87 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -1338,9 +1338,9 @@ static bool CanFollowRoad(TileIndex tile, DiagDirection dir)
* Returns "growth" if a house was built, or no if the build failed.
* @param t town 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.
* @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 */
if (IsValidDiagDirection(target_dir)) cur_rb &= ~DiagDirToRoadBits(ReverseDiagDir(target_dir));
if (cur_rb == ROAD_NONE) {
- return _grow_town_result;
+ return _grow_town_result != GROWTH_SEARCH_STOPPED;
}
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
* and continue the search from there. */
do {
- if (cur_rb == ROAD_NONE) return GROWTH_SEARCH_STOPPED;
+ if (cur_rb == ROAD_NONE) return false;
RoadBits target_bits;
do {
target_dir = RandomDiagDir();
@@ -1413,7 +1413,7 @@ static int GrowTownAtRoad(Town *t, TileIndex tile)
/* Max number of times is checked. */
} 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;
for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) {
if (GetTownRoadBits(tile) != ROAD_NONE) {
- int r = GrowTownAtRoad(t, tile);
+ bool success = GrowTownAtRoad(t, tile);
cur_company.Restore();
- return r != 0;
+ return success;
}
tile = TILE_ADD(tile, ToTileIndexDiff(*ptr));
}