From 9aecbac2b4a4137abc44ff12a672916ec7482047 Mon Sep 17 00:00:00 2001 From: Joan Josep Date: Sun, 13 Jan 2019 00:20:10 +0100 Subject: Codechange: Define INVALID_TOWN as a TownID (#7044) --- src/road_cmd.cpp | 6 +++--- src/town.h | 2 +- src/town_cmd.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index bdc8ce7f3..175e776e5 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -333,7 +333,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec if (rt == ROADTYPE_ROAD && IsRoadOwner(tile, ROADTYPE_ROAD, OWNER_TOWN)) { /* Update nearest-town index */ const Town *town = CalcClosestTownFromTile(tile); - SetTownIndex(tile, town == NULL ? (TownID)INVALID_TOWN : town->index); + SetTownIndex(tile, town == NULL ? INVALID_TOWN : town->index); } SetRoadBits(tile, ROAD_NONE, rt); SetRoadTypes(tile, rts); @@ -494,7 +494,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 if ((Company::IsValidID(company) && p2 != 0) || (company == OWNER_TOWN && !Town::IsValidID(p2)) || (company == OWNER_DEITY && p2 != 0)) return CMD_ERROR; if (company != OWNER_TOWN) { const Town *town = CalcClosestTownFromTile(tile); - p2 = (town != NULL) ? town->index : (TownID)INVALID_TOWN; + p2 = (town != NULL) ? town->index : INVALID_TOWN; if (company == OWNER_DEITY) { company = OWNER_TOWN; @@ -1444,7 +1444,7 @@ void UpdateNearestTownForRoadTiles(bool invalidate) for (TileIndex t = 0; t < MapSize(); t++) { if (IsTileType(t, MP_ROAD) && !IsRoadDepot(t) && !HasTownOwnedRoad(t)) { - TownID tid = (TownID)INVALID_TOWN; + TownID tid = INVALID_TOWN; if (!invalidate) { const Town *town = CalcClosestTownFromTile(t); if (town != NULL) tid = town->index; diff --git a/src/town.h b/src/town.h index 19a4118ba..a905ea837 100644 --- a/src/town.h +++ b/src/town.h @@ -31,7 +31,7 @@ typedef TileMatrix AcceptanceMatrix; static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY = 4; ///< value for custom town number in difficulty settings static const uint CUSTOM_TOWN_MAX_NUMBER = 5000; ///< this is the maximum number of towns a user can specify in customisation -static const uint INVALID_TOWN = 0xFFFF; +static const TownID INVALID_TOWN = 0xFFFF; static const uint TOWN_GROWTH_WINTER = 0xFFFFFFFE; ///< The town only needs this cargo in the winter (any amount) static const uint TOWN_GROWTH_DESERT = 0xFFFFFFFF; ///< The town needs the cargo for growth when on desert (any amount) diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 927651864..4289d901a 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -3335,7 +3335,7 @@ Town *ClosestTownFromTile(TileIndex tile, uint threshold) if (!HasTownOwnedRoad(tile)) { TownID tid = GetTownIndex(tile); - if (tid == (TownID)INVALID_TOWN) { + if (tid == INVALID_TOWN) { /* in the case we are generating "many random towns", this value may be INVALID_TOWN */ if (_generating_world) return CalcClosestTownFromTile(tile, threshold); assert(Town::GetNumItems() == 0); -- cgit v1.2.3-70-g09d2