Mercurial > hg > openttd
changeset 8563:992fa65afba1 draft
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
author | frosch <frosch@openttd.org> |
---|---|
date | Thu, 14 Feb 2008 15:59:16 +0000 |
parents | f539be5f3bd3 |
children | 2785566a8c4e |
files | src/ai/default/default.cpp src/ai/trolly/trolly.cpp src/depot.h src/elrail.cpp src/npf.cpp src/openttd.cpp src/order_gui.cpp src/rail_cmd.cpp src/road_cmd.cpp src/road_gui.cpp src/road_map.cpp src/road_map.h src/roadveh_cmd.cpp src/station_cmd.cpp src/tunnelbridge_cmd.cpp src/yapf/follow_track.hpp |
diffstat | 16 files changed, 79 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ai/default/default.cpp +++ b/src/ai/default/default.cpp @@ -2639,8 +2639,7 @@ _cleared_town = NULL; if (p->mode == 2) { - if (IsTileType(c, MP_ROAD) && - GetRoadTileType(c) == ROAD_TILE_NORMAL && + if (IsNormalRoadTile(c) && (GetRoadBits(c, ROADTYPE_ROAD) & p->attr) != 0) { roadflag |= 2; @@ -2682,7 +2681,7 @@ if (GetTileSlope(c, NULL) != SLOPE_FLAT) return CMD_ERROR; - if (!IsTileType(c, MP_ROAD) || GetRoadTileType(c) != ROAD_TILE_NORMAL) { + if (!IsNormalRoadTile(c)) { ret = DoCommand(c, 0, 0, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_LANDSCAPE_CLEAR); if (CmdFailed(ret)) return CMD_ERROR; } @@ -2857,7 +2856,7 @@ if (dist <= a->best_dist) { TileIndex tile2 = TILE_MASK(tile + TileOffsByDiagDir(_dir_by_track[track])); - if (IsTileType(tile2, MP_ROAD) && GetRoadTileType(tile2) == ROAD_TILE_NORMAL) { + if (IsNormalRoadTile(tile2)) { a->best_dist = dist; a->best_tile = tile; a->best_track = track; @@ -3740,7 +3739,7 @@ if (IsLevelCrossing(tile)) goto is_rail_crossing; - if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) { + if (IsRoadDepot(tile)) { DiagDirection dir; TileIndex t;
--- a/src/ai/trolly/trolly.cpp +++ b/src/ai/trolly/trolly.cpp @@ -801,8 +801,7 @@ for (j = DIAGDIR_BEGIN; j < DIAGDIR_END; j++) { TileIndex t = tile + TileOffsByDiagDir(j); - if (IsTileType(t, MP_ROAD) && - GetRoadTileType(t) == ROAD_TILE_DEPOT && + if (IsRoadDepotTile(t) && IsTileOwner(t, _current_player) && GetRoadDepotDirection(t) == ReverseDiagDir(j)) { _players_ainew[p->index].depot_tile = t; @@ -1102,7 +1101,7 @@ CommandCost res; assert(_players_ainew[p->index].state == AI_STATE_BUILD_DEPOT); - if (IsTileType(_players_ainew[p->index].depot_tile, MP_ROAD) && GetRoadTileType(_players_ainew[p->index].depot_tile) == ROAD_TILE_DEPOT) { + if (IsRoadDepotTile(_players_ainew[p->index].depot_tile)) { if (IsTileOwner(_players_ainew[p->index].depot_tile, _current_player)) { // The depot is already built _players_ainew[p->index].state = AI_STATE_BUILD_VEHICLE;
--- a/src/depot.h +++ b/src/depot.h @@ -45,7 +45,7 @@ return IsTileType(tile, MP_RAILWAY) && GetRailTileType(tile) == RAIL_TILE_DEPOT; case TRANSPORT_ROAD: - return IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_DEPOT; + return IsRoadDepotTile(tile); case TRANSPORT_WATER: return IsTileType(tile, MP_WATER) && GetWaterTileType(tile) == WATER_TILE_DEPOT; @@ -64,7 +64,7 @@ static inline bool IsDepotTile(TileIndex tile) { switch (GetTileType(tile)) { - case MP_ROAD: return GetRoadTileType(tile) == ROAD_TILE_DEPOT; + case MP_ROAD: return IsRoadDepot(tile); case MP_WATER: return GetWaterTileType(tile) == WATER_TILE_DEPOT; case MP_RAILWAY: return GetRailTileType(tile) == RAIL_TILE_DEPOT; case MP_STATION: return IsHangar(tile);
--- a/src/elrail.cpp +++ b/src/elrail.cpp @@ -103,7 +103,7 @@ return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(t))); case MP_ROAD: - if (GetRoadTileType(t) != ROAD_TILE_CROSSING) return TRACK_BIT_NONE; + if (!IsLevelCrossing(t)) return TRACK_BIT_NONE; if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE; return GetCrossingRailBits(t);
--- a/src/npf.cpp +++ b/src/npf.cpp @@ -512,7 +512,7 @@ /** Tests if a tile is a road tile with a single tramtrack (tram can reverse) */ static DiagDirection GetSingleTramBit(TileIndex tile) { - if (IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) { + if (IsNormalRoadTile(tile)) { RoadBits rb = GetRoadBits(tile, ROADTYPE_TRAM); switch (rb) { case ROAD_NW: return DIAGDIR_NW;
--- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -2388,7 +2388,7 @@ Owner o = GetRoadOwner(t, rt); if (IsValidPlayer(o) && !GetPlayer(o)->is_active) SetRoadOwner(t, rt, OWNER_NONE); } - if (GetRoadTileType(t) == ROAD_TILE_CROSSING) { + if (IsLevelCrossing(t)) { Owner o = GetTileOwner(t); if (!GetPlayer(o)->is_active) { /* remove leftover rail piece from crossing (from very old savegames) */
--- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -281,7 +281,7 @@ break; case MP_ROAD: - if (GetRoadTileType(tile) == ROAD_TILE_DEPOT && v->type == VEH_ROAD && IsTileOwner(tile, _local_player)) { + if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_player)) { order.type = OT_GOTO_DEPOT; order.flags = OFB_PART_OF_ORDERS; order.dest = GetDepotByTile(tile)->index;
--- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -356,7 +356,7 @@ if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; - if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) { + if (IsNormalRoad(tile)) { if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS); RoadTypes roadtypes = GetRoadTypes(tile);
--- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -225,7 +225,7 @@ /* Don't allow road to be removed from the crossing when there is tram; * we can't draw the crossing without trambits ;) */ - if (rt == ROADTYPE_ROAD && HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) && (flags & DC_EXEC || crossing_check)) return CMD_ERROR; + if (rt == ROADTYPE_ROAD && HasTileRoadType(tile, ROADTYPE_TRAM) && (flags & DC_EXEC || crossing_check)) return CMD_ERROR; if (rt == ROADTYPE_ROAD) { ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM); @@ -429,7 +429,7 @@ if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; all_bits = GetAllRoadBits(tile); - if (!HasBit(GetRoadTypes(tile), rt)) break; + if (!HasTileRoadType(tile, rt)) break; existing = GetRoadBits(tile, rt); RoadBits merged = existing | pieces; @@ -455,7 +455,7 @@ } break; case ROAD_TILE_CROSSING: - if (HasBit(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT); + if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT); all_bits = GetCrossingRoadBits(tile); if (pieces & ComplementRoadBits(all_bits)) goto do_clear; if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; @@ -508,14 +508,14 @@ case MP_STATION: if (!IsDriveThroughStopTile(tile)) return CMD_ERROR; - if (HasBit(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT); + if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT); /* Don't allow adding roadtype to the roadstop when vehicles are already driving on it */ if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; break; case MP_TUNNELBRIDGE: if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR; - if (HasBit(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT); + if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT); /* Don't allow adding roadtype to the bridge/tunnel when vehicles are already driving on it */ if (GetVehicleTunnelBridge(tile, GetOtherTunnelBridgeEnd(tile)) != NULL) return CMD_ERROR; break; @@ -543,7 +543,7 @@ pieces &= ComplementRoadBits(existing); /* Check if new road bits will have the same foundation as other existing road types */ - if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) { + if (IsNormalRoad(tile)) { Slope slope = GetTileSlope(tile, NULL); Foundation found_new = GetRoadFoundation(slope, pieces | existing); @@ -603,7 +603,7 @@ break; } - if (rt != ROADTYPE_TRAM && IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) { + if (rt != ROADTYPE_TRAM && IsNormalRoadTile(tile)) { existing |= pieces; SetDisallowedRoadDirections(tile, (existing == ROAD_X || existing == ROAD_Y) ? GetDisallowedRoadDirections(tile) ^ toggle_drd : DRD_NONE); @@ -1090,7 +1090,7 @@ } DrawGroundSprite(image, pal); - if (HasBit(GetRoadTypes(ti->tile), ROADTYPE_TRAM)) { + if (HasTileRoadType(ti->tile, ROADTYPE_TRAM)) { DrawGroundSprite(SPR_TRAMWAY_OVERLAY + (GetCrossingRoadAxis(ti->tile) ^ 1), pal); DrawTramCatenary(ti, GetCrossingRoadBits(ti->tile)); } @@ -1108,7 +1108,7 @@ palette = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)); - if (HasBit(GetRoadTypes(ti->tile), ROADTYPE_TRAM)) { + if (HasTileRoadType(ti->tile, ROADTYPE_TRAM)) { dts = &_tram_depot[GetRoadDepotDirection(ti->tile)]; } else { dts = &_road_depot[GetRoadDepotDirection(ti->tile)]; @@ -1165,7 +1165,7 @@ Slope tileh = GetTileSlope(tile, &z); if (tileh == SLOPE_FLAT) return z; - if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) { + if (IsNormalRoad(tile)) { Foundation f = GetRoadFoundation(tileh, GetAllRoadBits(tile)); z += ApplyFoundationToSlope(f, &tileh); return z + GetPartialZ(x & 0xF, y & 0xF, tileh); @@ -1176,7 +1176,7 @@ static Foundation GetFoundation_Road(TileIndex tile, Slope tileh) { - if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) { + if (IsNormalRoad(tile)) { return GetRoadFoundation(tileh, GetAllRoadBits(tile)); } else { return FlatteningFoundation(tileh); @@ -1229,7 +1229,7 @@ break; } - if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) return; + if (IsRoadDepot(tile)) return; const Town* t = ClosestTownFromTile(tile, (uint)-1); if (!HasRoadWorks(tile)) { @@ -1241,7 +1241,7 @@ /* Show an animation to indicate road work */ if (t->road_build_months != 0 && (DistanceManhattan(t->xy, tile) < 8 || grp != HZB_TOWN_EDGE) && - GetRoadTileType(tile) == ROAD_TILE_NORMAL && CountBits(GetAllRoadBits(tile)) > 1 ) { + IsNormalRoad(tile) && CountBits(GetAllRoadBits(tile)) > 1 ) { if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicleOnGround(tile) && Chance16(1, 40)) { StartRoadWorks(tile); @@ -1297,7 +1297,7 @@ static void ClickTile_Road(TileIndex tile) { - if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) ShowDepotWindow(tile, VEH_ROAD); + if (IsRoadDepot(tile)) ShowDepotWindow(tile, VEH_ROAD); } static const byte _road_trackbits[16] = { @@ -1402,7 +1402,7 @@ static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player) { - if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) { + if (IsRoadDepot(tile)) { if (GetTileOwner(tile) == old_player) { if (new_player == PLAYER_SPECTATOR) { DoCommand(tile, 0, 0, DC_EXEC | DC_BANKRUPT, CMD_LANDSCAPE_CLEAR); @@ -1415,7 +1415,7 @@ for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) { /* ROADTYPE_ROAD denotes the tile owner, so update it too */ - if (rt != ROADTYPE_ROAD && !HasBit(GetRoadTypes(tile), rt)) continue; + if (rt != ROADTYPE_ROAD && !HasTileRoadType(tile, rt)) continue; if (GetRoadOwner(tile, rt) == old_player) { SetRoadOwner(tile, rt, new_player == PLAYER_SPECTATOR ? OWNER_NONE : new_player);
--- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -177,7 +177,7 @@ { tile += TileOffsByDiagDir(direction); // if there is a roadpiece just outside of the station entrance, build a connecting route - if (IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) { + if (IsNormalRoadTile(tile)) { if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) { DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, NULL, CMD_BUILD_ROAD); }
--- a/src/road_map.cpp +++ b/src/road_map.cpp @@ -16,7 +16,7 @@ RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt) { - if (!HasBit(GetRoadTypes(tile), rt)) return ROAD_NONE; + if (!HasTileRoadType(tile, rt)) return ROAD_NONE; switch (GetTileType(tile)) { case MP_ROAD: @@ -46,7 +46,7 @@ uint32 r; /* Don't allow local authorities to build roads through road depots or road stops. */ - if ((IsTileType(tile, MP_ROAD) && IsTileDepotType(tile, TRANSPORT_ROAD)) || (IsTileType(tile, MP_STATION) && !IsDriveThroughStopTile(tile)) || !HasBit(GetRoadTypes(tile), rt)) { + if (IsRoadDepotTile(tile) || (IsTileType(tile, MP_STATION) && !IsDriveThroughStopTile(tile)) || !HasTileRoadType(tile, rt)) { return TRACK_BIT_NONE; }
--- a/src/road_map.h +++ b/src/road_map.h @@ -24,6 +24,16 @@ return (RoadTileType)GB(_m[t].m5, 6, 2); } +static inline bool IsNormalRoad(TileIndex t) +{ + return GetRoadTileType(t) == ROAD_TILE_NORMAL; +} + +static inline bool IsNormalRoadTile(TileIndex t) +{ + return IsTileType(t, MP_ROAD) && IsNormalRoad(t); +} + static inline bool IsLevelCrossing(TileIndex t) { return GetRoadTileType(t) == ROAD_TILE_CROSSING; @@ -34,9 +44,19 @@ return IsTileType(t, MP_ROAD) && IsLevelCrossing(t); } +static inline bool IsRoadDepot(TileIndex t) +{ + return GetRoadTileType(t) == ROAD_TILE_DEPOT; +} + +static inline bool IsRoadDepotTile(TileIndex t) +{ + return IsTileType(t, MP_ROAD) && IsRoadDepot(t); +} + static inline RoadBits GetRoadBits(TileIndex t, RoadType rt) { - assert(GetRoadTileType(t) == ROAD_TILE_NORMAL); + assert(IsNormalRoad(t)); switch (rt) { default: NOT_REACHED(); case ROADTYPE_ROAD: return (RoadBits)GB(_m[t].m4, 0, 4); @@ -52,7 +72,7 @@ static inline void SetRoadBits(TileIndex t, RoadBits r, RoadType rt) { - assert(GetRoadTileType(t) == ROAD_TILE_NORMAL); // XXX incomplete + assert(IsNormalRoad(t)); // XXX incomplete switch (rt) { default: NOT_REACHED(); case ROADTYPE_ROAD: SB(_m[t].m4, 0, 4, r); break; @@ -80,6 +100,11 @@ } } +static inline bool HasTileRoadType(TileIndex t, RoadType rt) +{ + return HasBit(GetRoadTypes(t), rt); +} + static inline Owner GetRoadOwner(TileIndex t, RoadType rt) { if (!IsTileType(t, MP_ROAD)) return GetTileOwner(t); @@ -159,7 +184,7 @@ */ static inline DisallowedRoadDirections GetDisallowedRoadDirections(TileIndex t) { - assert(GetRoadTileType(t) == ROAD_TILE_NORMAL); + assert(IsNormalRoad(t)); return (DisallowedRoadDirections)GB(_m[t].m5, 4, 2); } @@ -170,14 +195,14 @@ */ static inline void SetDisallowedRoadDirections(TileIndex t, DisallowedRoadDirections drd) { - assert(GetRoadTileType(t) == ROAD_TILE_NORMAL); + assert(IsNormalRoad(t)); assert(drd < DRD_END); SB(_m[t].m5, 4, 2, drd); } static inline Axis GetCrossingRoadAxis(TileIndex t) { - assert(GetRoadTileType(t) == ROAD_TILE_CROSSING); + assert(IsLevelCrossing(t)); return (Axis)GB(_m[t].m4, 6, 1); } @@ -193,13 +218,13 @@ static inline bool IsCrossingBarred(TileIndex t) { - assert(GetRoadTileType(t) == ROAD_TILE_CROSSING); + assert(IsLevelCrossing(t)); return HasBit(_m[t].m4, 5); } static inline void SetCrossingBarred(TileIndex t, bool barred) { - assert(GetRoadTileType(t) == ROAD_TILE_CROSSING); + assert(IsLevelCrossing(t)); SB(_m[t].m4, 5, 1, barred); } @@ -280,7 +305,7 @@ static inline DiagDirection GetRoadDepotDirection(TileIndex t) { - assert(GetRoadTileType(t) == ROAD_TILE_DEPOT); + assert(IsRoadDepot(t)); return (DiagDirection)GB(_m[t].m5, 0, 2); }
--- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -182,7 +182,7 @@ if (!IsTileDepotType(tile, TRANSPORT_ROAD)) return CMD_ERROR; if (!IsTileOwner(tile, _current_player)) return CMD_ERROR; - if (HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) != HasBit(EngInfo(p1)->misc_flags, EF_ROAD_TRAM)) return_cmd_error(STR_DEPOT_WRONG_DEPOT_TYPE); + if (HasTileRoadType(tile, ROADTYPE_TRAM) != HasBit(EngInfo(p1)->misc_flags, EF_ROAD_TRAM)) return_cmd_error(STR_DEPOT_WRONG_DEPOT_TYPE); uint num_vehicles = 1 + CountArticulatedParts(p1, false); @@ -404,8 +404,7 @@ tile += TileOffsByDiagDir(_road_pf_directions[trackdir]); - if (IsTileType(tile, MP_ROAD) && - GetRoadTileType(tile) == ROAD_TILE_DEPOT && + if (IsRoadDepotTile(tile) && IsTileOwner(tile, rfdd->owner) && length < rfdd->best_length) { rfdd->best_length = length; @@ -550,7 +549,7 @@ return CMD_ERROR; } - if (IsTileType(v->tile, MP_ROAD) && GetRoadTileType(v->tile) == ROAD_TILE_NORMAL && GetDisallowedRoadDirections(v->tile) != DRD_NONE) return CMD_ERROR; + if (IsNormalRoadTile(v->tile) && GetDisallowedRoadDirections(v->tile) != DRD_NONE) return CMD_ERROR; if (IsTileType(v->tile, MP_TUNNELBRIDGE) && DirToDiagDir(v->direction) == GetTunnelBridgeDirection(v->tile)) return CMD_ERROR; @@ -1159,7 +1158,7 @@ TrackdirBits trackdirs = (TrackdirBits)GB(r, 0, 16); if (IsTileType(tile, MP_ROAD)) { - if (GetRoadTileType(tile) == ROAD_TILE_DEPOT && (!IsTileOwner(tile, v->owner) || GetRoadDepotDirection(tile) == enterdir || (GetRoadTypes(tile) & v->u.road.compatible_roadtypes) == 0)) { + if (IsRoadDepot(tile) && (!IsTileOwner(tile, v->owner) || GetRoadDepotDirection(tile) == enterdir || (GetRoadTypes(tile) & v->u.road.compatible_roadtypes) == 0)) { /* Road depot owned by another player or with the wrong orientation */ trackdirs = TRACKDIR_BIT_NONE; } @@ -1251,7 +1250,7 @@ DiagDirection dir; if (IsTileType(desttile, MP_ROAD)) { - if (GetRoadTileType(desttile) == ROAD_TILE_DEPOT) { + if (IsRoadDepot(desttile)) { dir = GetRoadDepotDirection(desttile); goto do_it; } @@ -1413,7 +1412,7 @@ if (IsTileType(tile, MP_TUNNELBRIDGE)) { diag_dir = GetTunnelBridgeDirection(tile); - } else if (IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_DEPOT) { + } else if (IsRoadDepotTile(tile)) { diag_dir = ReverseDiagDir(GetRoadDepotDirection(tile)); } @@ -1582,8 +1581,7 @@ case TRACKDIR_RVREV_NW: needed = ROAD_SE; break; } if ((v->Previous() != NULL && v->Previous()->tile == tile) || - (IsRoadVehFront(v) && IsTileType(tile, MP_ROAD) && - GetRoadTileType(tile) == ROAD_TILE_NORMAL && !HasRoadWorks(tile) && + (IsRoadVehFront(v) && IsNormalRoadTile(tile) && !HasRoadWorks(tile) && (needed & GetRoadBits(tile, ROADTYPE_TRAM)) != ROAD_NONE)) { /* * Taking the 'big' corner for trams only happens when: @@ -1614,7 +1612,7 @@ v->cur_speed = 0; return false; } - } else if (IsTileType(v->tile, MP_ROAD) && GetRoadTileType(v->tile) == ROAD_TILE_NORMAL && GetDisallowedRoadDirections(v->tile) != DRD_NONE) { + } else if (IsNormalRoadTile(v->tile) && GetDisallowedRoadDirections(v->tile) != DRD_NONE) { v->cur_speed = 0; return false; } else { @@ -1757,9 +1755,7 @@ /* This vehicle is not in a wormhole and it hasn't entered a new tile. If * it's on a depot tile, check if it's time to activate the next vehicle in * the chain yet. */ - if (v->Next() != NULL && - IsTileType(v->tile, MP_ROAD) && GetRoadTileType(v->tile) == ROAD_TILE_DEPOT) { - + if (v->Next() != NULL && IsRoadDepotTile(v->tile)) { if (v->u.road.frame == v->u.road.cached_veh_length + RVC_DEPOT_START_FRAME) { RoadVehLeaveDepot(v->Next(), false); }
--- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -1333,7 +1333,7 @@ { bool type = HasBit(p2, 0); bool is_drive_through = HasBit(p2, 1); - bool build_over_road = is_drive_through && IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_NORMAL; + bool build_over_road = is_drive_through && IsNormalRoadTile(tile); bool town_owned_road = build_over_road && IsTileOwner(tile, OWNER_TOWN); RoadTypes rts = (RoadTypes)GB(p2, 2, 3); @@ -1356,7 +1356,6 @@ /* Not allowed to build over this road */ if (build_over_road) { if (IsTileOwner(tile, OWNER_TOWN) && !_patches.road_stop_on_town_road) return_cmd_error(STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD); - if (GetRoadTileType(tile) != ROAD_TILE_NORMAL) return CMD_ERROR; RoadTypes cur_rts = GetRoadTypes(tile); @@ -2946,8 +2945,8 @@ switch (GetStationType(tile)) { case STATION_RAIL: return_cmd_error(STR_300B_MUST_DEMOLISH_RAILROAD); case STATION_AIRPORT: return_cmd_error(STR_300E_MUST_DEMOLISH_AIRPORT_FIRST); - case STATION_TRUCK: return_cmd_error(HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) ? STR_MUST_DEMOLISH_CARGO_TRAM_STATION : STR_3047_MUST_DEMOLISH_TRUCK_STATION); - case STATION_BUS: return_cmd_error(HasBit(GetRoadTypes(tile), ROADTYPE_TRAM) ? STR_MUST_DEMOLISH_PASSENGER_TRAM_STATION : STR_3046_MUST_DEMOLISH_BUS_STATION); + case STATION_TRUCK: return_cmd_error(HasTileRoadType(tile, ROADTYPE_TRAM) ? STR_MUST_DEMOLISH_CARGO_TRAM_STATION : STR_3047_MUST_DEMOLISH_TRUCK_STATION); + case STATION_BUS: return_cmd_error(HasTileRoadType(tile, ROADTYPE_TRAM) ? STR_MUST_DEMOLISH_PASSENGER_TRAM_STATION : STR_3046_MUST_DEMOLISH_BUS_STATION); case STATION_BUOY: return_cmd_error(STR_306A_BUOY_IN_THE_WAY); case STATION_DOCK: return_cmd_error(STR_304D_MUST_DEMOLISH_DOCK_FIRST); case STATION_OILRIG:
--- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -387,7 +387,7 @@ break; case MP_ROAD: - if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) goto not_valid_below; + if (IsRoadDepot(tile)) goto not_valid_below; break; case MP_TUNNELBRIDGE:
--- a/src/yapf/follow_track.hpp +++ b/src/yapf/follow_track.hpp @@ -44,7 +44,7 @@ /** Tests if a tile is a road tile with a single tramtrack (tram can reverse) */ FORCEINLINE DiagDirection GetSingleTramBit(TileIndex tile) { - if (IsTram() && IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) { + if (IsTram() && IsNormalRoadTile(tile)) { RoadBits rb = GetRoadBits(tile, ROADTYPE_TRAM); switch (rb) { case ROAD_NW: return DIAGDIR_NW;