summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2008-02-14 15:59:16 +0000
committerfrosch <frosch@openttd.org>2008-02-14 15:59:16 +0000
commit514df81e27398309532f7523ee1c7df86fe3043d (patch)
treea43464406df621d20a7dd83755ef86ae3474e9ea /src
parent6c932166414ac0164fc53658b880d5b05a9d7a7e (diff)
downloadopenttd-514df81e27398309532f7523ee1c7df86fe3043d.tar.xz
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
Diffstat (limited to 'src')
-rw-r--r--src/ai/default/default.cpp9
-rw-r--r--src/ai/trolly/trolly.cpp5
-rw-r--r--src/depot.h4
-rw-r--r--src/elrail.cpp2
-rw-r--r--src/npf.cpp2
-rw-r--r--src/openttd.cpp2
-rw-r--r--src/order_gui.cpp2
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/road_cmd.cpp32
-rw-r--r--src/road_gui.cpp2
-rw-r--r--src/road_map.cpp4
-rw-r--r--src/road_map.h41
-rw-r--r--src/roadveh_cmd.cpp22
-rw-r--r--src/station_cmd.cpp7
-rw-r--r--src/tunnelbridge_cmd.cpp2
-rw-r--r--src/yapf/follow_track.hpp2
16 files changed, 79 insertions, 61 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp
index 95fab9619..077e2a849 100644
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -2639,8 +2639,7 @@ static CommandCost AiDoBuildDefaultRoadBlock(TileIndex tile, const AiDefaultBloc
_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 @@ clear_town_stuff:;
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 @@ static bool AiEnumFollowRoad(TileIndex tile, AiRoadEnum *a, int track, uint leng
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 @@ pos_3:
if (IsLevelCrossing(tile)) goto is_rail_crossing;
- if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) {
+ if (IsRoadDepot(tile)) {
DiagDirection dir;
TileIndex t;
diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp
index 8f62b7e95..1a5a0fce4 100644
--- a/src/ai/trolly/trolly.cpp
+++ b/src/ai/trolly/trolly.cpp
@@ -801,8 +801,7 @@ static void AiNew_State_FindDepot(Player *p)
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 @@ static void AiNew_State_BuildDepot(Player *p)
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;
diff --git a/src/depot.h b/src/depot.h
index 4aec85aa1..f551f943f 100644
--- a/src/depot.h
+++ b/src/depot.h
@@ -45,7 +45,7 @@ static inline bool IsTileDepotType(TileIndex tile, TransportType type)
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 IsTileDepotType(TileIndex tile, TransportType type)
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);
diff --git a/src/elrail.cpp b/src/elrail.cpp
index b93448020..7dd9eab0c 100644
--- a/src/elrail.cpp
+++ b/src/elrail.cpp
@@ -103,7 +103,7 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
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);
diff --git a/src/npf.cpp b/src/npf.cpp
index ea49c075f..3b6e71466 100644
--- a/src/npf.cpp
+++ b/src/npf.cpp
@@ -512,7 +512,7 @@ static DiagDirection GetDepotDirection(TileIndex tile, TransportType type)
/** 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;
diff --git a/src/openttd.cpp b/src/openttd.cpp
index f1f55e310..4ec3fc919 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -2388,7 +2388,7 @@ bool AfterLoadGame()
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) */
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index 6a05adf77..4f13423a5 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -281,7 +281,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
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;
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index b5f674df3..2830838f6 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -356,7 +356,7 @@ CommandCost CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p
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);
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 405261d86..e26318b56 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -225,7 +225,7 @@ static CommandCost RemoveRoad(TileIndex tile, uint32 flags, RoadBits pieces, Roa
/* 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 @@ CommandCost CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
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 @@ CommandCost CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
} 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 @@ CommandCost CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
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 @@ do_clear:;
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 @@ do_clear:;
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 @@ static void DrawTile_Road(TileInfo *ti)
}
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 @@ static void DrawTile_Road(TileInfo *ti)
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 @@ static uint GetSlopeZ_Road(TileIndex tile, uint x, uint y)
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 uint GetSlopeZ_Road(TileIndex tile, uint x, uint y)
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 @@ static void TileLoop_Road(TileIndex tile)
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 @@ static void TileLoop_Road(TileIndex tile)
/* 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 TileLoop_Road(TileIndex tile)
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 VehicleEnterTileStatus VehicleEnter_Road(Vehicle *v, TileIndex tile, int
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 @@ static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID n
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);
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 31231e37f..b7313b449 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -177,7 +177,7 @@ static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction)
{
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);
}
diff --git a/src/road_map.cpp b/src/road_map.cpp
index 51723fa14..c86c3d1b3 100644
--- 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 @@ TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt)
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;
}
diff --git a/src/road_map.h b/src/road_map.h
index 997040057..305c77375 100644
--- a/src/road_map.h
+++ b/src/road_map.h
@@ -24,6 +24,16 @@ static inline RoadTileType GetRoadTileType(TileIndex t)
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 @@ static inline bool IsLevelCrossingTile(TileIndex t)
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 RoadBits GetAllRoadBits(TileIndex tile)
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 void SetRoadTypes(TileIndex t, RoadTypes rt)
}
}
+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 @@ DECLARE_ENUM_AS_BIT_SET(DisallowedRoadDirections);
*/
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 DisallowedRoadDirections GetDisallowedRoadDirections(TileIndex t)
*/
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 TrackBits GetCrossingRailBits(TileIndex tile)
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 void TerminateRoadWorks(TileIndex t)
static inline DiagDirection GetRoadDepotDirection(TileIndex t)
{
- assert(GetRoadTileType(t) == ROAD_TILE_DEPOT);
+ assert(IsRoadDepot(t));
return (DiagDirection)GB(_m[t].m5, 0, 2);
}
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 85ddce643..57208e7e1 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -182,7 +182,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
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 @@ static bool EnumRoadSignalFindDepot(TileIndex tile, void* data, Trackdir trackdi
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 @@ CommandCost CmdTurnRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
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 @@ static Trackdir RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection ent
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 @@ static Trackdir RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection ent
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 @@ static Trackdir FollowPreviousRoadVehicle(const Vehicle *v, const Vehicle *prev,
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 @@ again:
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 @@ again:
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 @@ again:
/* 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);
}
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index bef1c1cf3..b2219c1cb 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1333,7 +1333,7 @@ CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
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 @@ CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* 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 @@ static CommandCost ClearTile_Station(TileIndex tile, byte flags)
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:
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 6dcce8162..d04c32ed6 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -387,7 +387,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p
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:
diff --git a/src/yapf/follow_track.hpp b/src/yapf/follow_track.hpp
index 09bc98b76..07a6b15b3 100644
--- a/src/yapf/follow_track.hpp
+++ b/src/yapf/follow_track.hpp
@@ -44,7 +44,7 @@ struct CFollowTrackT : public FollowTrack_t
/** 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;