diff options
author | smatz <smatz@openttd.org> | 2009-03-08 01:20:11 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2009-03-08 01:20:11 +0000 |
commit | f5b24edc1e33a43c6bd725482b9150f22414f2f2 (patch) | |
tree | b5902de710ecffe04af17e8f76703457edc2aeba /src | |
parent | c71898461845992cf05f3e17e8ab871b2cc7f463 (diff) | |
download | openttd-f5b24edc1e33a43c6bd725482b9150f22414f2f2.tar.xz |
(svn r15642) -Codechange: use a default parameter value in CalcClosestTownFromTile
Diffstat (limited to 'src')
-rw-r--r-- | src/road_cmd.cpp | 6 | ||||
-rw-r--r-- | src/saveload/afterload.cpp | 8 | ||||
-rw-r--r-- | src/town.h | 2 | ||||
-rw-r--r-- | src/town_cmd.cpp | 2 |
4 files changed, 9 insertions, 9 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 511ca8169..d80e2d9d1 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -290,7 +290,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec } else { if (rt == ROADTYPE_ROAD && IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN)) { /* Update nearest-town index */ - const Town *town = CalcClosestTownFromTile(tile, UINT_MAX); + const Town *town = CalcClosestTownFromTile(tile); SetTownIndex(tile, town == NULL ? (TownID)INVALID_TOWN : town->index); } SetRoadBits(tile, ROAD_NONE, rt); @@ -457,7 +457,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 * if a non-company is building the road */ if ((IsValidCompanyID(_current_company) && p2 != 0) || (_current_company == OWNER_TOWN && !IsValidTownID(p2))) return CMD_ERROR; if (_current_company != OWNER_TOWN) { - const Town *town = CalcClosestTownFromTile(tile, UINT_MAX); + const Town *town = CalcClosestTownFromTile(tile); p2 = (town != NULL) ? town->index : (TownID)INVALID_TOWN; } @@ -1254,7 +1254,7 @@ void UpdateNearestTownForRoadTiles(bool invalidate) if (IsTileType(t, MP_ROAD) && !HasTownOwnedRoad(t)) { TownID tid = (TownID)INVALID_TOWN; if (!invalidate) { - const Town *town = CalcClosestTownFromTile(t, UINT_MAX); + const Town *town = CalcClosestTownFromTile(t); if (town != NULL) tid = town->index; } SetTownIndex(t, tid); diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index de48d461a..eca68c5fd 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -624,13 +624,13 @@ bool AfterLoadGame() switch (GetTileType(t)) { case MP_HOUSE: _m[t].m4 = _m[t].m2; - SetTownIndex(t, CalcClosestTownFromTile(t, UINT_MAX)->index); + SetTownIndex(t, CalcClosestTownFromTile(t)->index); break; case MP_ROAD: _m[t].m4 |= (_m[t].m2 << 4); if ((GB(_m[t].m5, 4, 2) == ROAD_TILE_CROSSING ? (Owner)_m[t].m3 : GetTileOwner(t)) == OWNER_TOWN) { - SetTownIndex(t, CalcClosestTownFromTile(t, UINT_MAX)->index); + SetTownIndex(t, CalcClosestTownFromTile(t)->index); } else { SetTownIndex(t, 0); } @@ -775,7 +775,7 @@ bool AfterLoadGame() break; } if (!HasTownOwnedRoad(t)) { - const Town *town = CalcClosestTownFromTile(t, (uint)-1); + const Town *town = CalcClosestTownFromTile(t); if (town != NULL) SetTownIndex(t, town->index); } _m[t].m4 = 0; @@ -1273,7 +1273,7 @@ bool AfterLoadGame() if (CheckSavegameVersion(52)) { for (TileIndex t = 0; t < map_size; t++) { if (IsStatueTile(t)) { - _m[t].m2 = CalcClosestTownFromTile(t, UINT_MAX)->index; + _m[t].m2 = CalcClosestTownFromTile(t)->index; } } } diff --git a/src/town.h b/src/town.h index 169161505..3588de76a 100644 --- a/src/town.h +++ b/src/town.h @@ -340,7 +340,7 @@ static inline Town *GetRandomTown() return GetTown(index); } -Town *CalcClosestTownFromTile(TileIndex tile, uint threshold); +Town *CalcClosestTownFromTile(TileIndex tile, uint threshold = UINT_MAX); #define FOR_ALL_TOWNS_FROM(t, start) for (t = GetTown(start); t != NULL; t = (t->index + 1U < GetTownPoolSize()) ? GetTown(t->index + 1U) : NULL) if (t->IsValid()) #define FOR_ALL_TOWNS(t) FOR_ALL_TOWNS_FROM(t, 0) diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 4432f17a3..a73af923c 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2590,7 +2590,7 @@ Town *ClosestTownFromTile(TileIndex tile, uint threshold) Town *town = GetTown(tid); assert(town->IsValid()); - assert(town == CalcClosestTownFromTile(tile, UINT_MAX)); + assert(town == CalcClosestTownFromTile(tile)); if (DistanceManhattan(tile, town->xy) >= threshold) town = NULL; |