mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-22 11:44:17 +01:00
Codechange: use INVALID_TOWN instead of 0 to denote 'not applicable'
This commit is contained in:
@@ -604,7 +604,7 @@ static CommandCost CheckRoadSlope(Slope tileh, RoadBits *pieces, RoadBits existi
|
||||
* @param pieces road pieces to build (RoadBits)
|
||||
* @param rt road type
|
||||
* @param toggle_drd disallowed directions to toggle
|
||||
* @param town_id the town that is building the road (0 if not applicable)
|
||||
* @param town_id the town that is building the road (INVALID_TOWN if not applicable)
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdBuildRoad(DoCommandFlag flags, TileIndex tile, RoadBits pieces, RoadType rt, DisallowedRoadDirections toggle_drd, TownID town_id)
|
||||
@@ -617,7 +617,7 @@ CommandCost CmdBuildRoad(DoCommandFlag flags, TileIndex tile, RoadBits pieces, R
|
||||
|
||||
/* Road pieces are max 4 bitset values (NE, NW, SE, SW) and town can only be non-zero
|
||||
* if a non-company is building the road */
|
||||
if ((Company::IsValidID(company) && town_id != 0) || (company == OWNER_TOWN && !Town::IsValidID(town_id)) || (company == OWNER_DEITY && town_id != 0)) return CMD_ERROR;
|
||||
if ((Company::IsValidID(company) && town_id != INVALID_TOWN) || (company == OWNER_TOWN && !Town::IsValidID(town_id)) || (company == OWNER_DEITY && town_id != INVALID_TOWN)) return CMD_ERROR;
|
||||
if (company != OWNER_TOWN) {
|
||||
const Town *town = CalcClosestTownFromTile(tile);
|
||||
town_id = (town != nullptr) ? town->index : INVALID_TOWN;
|
||||
@@ -1026,7 +1026,7 @@ CommandCost CmdBuildLongRoad(DoCommandFlag flags, TileIndex end_tile, TileIndex
|
||||
if (tile == start_tile && start_half) bits &= DiagDirToRoadBits(dir);
|
||||
}
|
||||
|
||||
CommandCost ret = Command<CMD_BUILD_ROAD>::Do(flags, tile, bits, rt, drd, 0);
|
||||
CommandCost ret = Command<CMD_BUILD_ROAD>::Do(flags, tile, bits, rt, drd, INVALID_TOWN);
|
||||
if (ret.Failed()) {
|
||||
last_error = ret;
|
||||
if (last_error.GetErrorMessage() != STR_ERROR_ALREADY_BUILT) {
|
||||
|
||||
Reference in New Issue
Block a user