mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-21 01:59:44 +00:00
Codechange: use existing helpers to convert to/from Axis (#15629)
This commit is contained in:
+1
-1
@@ -406,7 +406,7 @@ static void DrawRailCatenaryRailway(const TileInfo *ti)
|
||||
if (ppp_allowed[i].Any(ppp_preferred[i])) ppp_allowed[i] &= ppp_preferred[i];
|
||||
|
||||
if (IsBridgeAbove(ti->tile)) {
|
||||
Track bridgetrack = GetBridgeAxis(ti->tile) == AXIS_X ? TRACK_X : TRACK_Y;
|
||||
Track bridgetrack = AxisToTrack(GetBridgeAxis(ti->tile));
|
||||
int height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
|
||||
|
||||
if ((height <= GetTileMaxZ(ti->tile) + 1) &&
|
||||
|
||||
+1
-1
@@ -2992,7 +2992,7 @@ static VehicleEnterTileStates VehicleEnterTile_Rail(Vehicle *v, TileIndex tile,
|
||||
/* Leave the depot. */
|
||||
if ((v = v->GetMovingNext()) != nullptr) {
|
||||
v->vehstatus.Reset(VehState::Hidden);
|
||||
Train::From(v)->track = (DiagDirToAxis(dir) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y);
|
||||
Train::From(v)->track = AxisToTrackBits(DiagDirToAxis(dir));
|
||||
}
|
||||
}
|
||||
} else if (_fractcoords_enter[dir] == fract_coord) {
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ static bool IsPossibleCrossing(const TileIndex tile, Axis ax)
|
||||
{
|
||||
return (IsTileType(tile, TileType::Railway) &&
|
||||
GetRailTileType(tile) == RailTileType::Normal &&
|
||||
GetTrackBits(tile) == (ax == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X) &&
|
||||
GetTrackBits(tile) == AxisToTrackBits(OtherAxis(ax)) &&
|
||||
std::get<Slope>(GetFoundationSlope(tile)) == SLOPE_FLAT);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1449,13 +1449,13 @@ void DrawRoadCatenary(const TileInfo *ti)
|
||||
road = GetRoadBits(ti->tile, RoadTramType::Road);
|
||||
tram = GetRoadBits(ti->tile, RoadTramType::Tram);
|
||||
} else if (IsLevelCrossing(ti->tile)) {
|
||||
tram = road = (GetCrossingRailAxis(ti->tile) == AXIS_Y ? ROAD_X : ROAD_Y);
|
||||
tram = road = GetCrossingRoadBits(ti->tile);
|
||||
}
|
||||
} else if (IsTileType(ti->tile, TileType::Station)) {
|
||||
if (IsAnyRoadStop(ti->tile)) {
|
||||
if (IsDriveThroughStopTile(ti->tile)) {
|
||||
Axis axis = GetDriveThroughStopAxis(ti->tile);
|
||||
tram = road = (axis == AXIS_X ? ROAD_X : ROAD_Y);
|
||||
tram = road = AxisToRoadBits(axis);
|
||||
} else {
|
||||
tram = road = DiagDirToRoadBits(GetBayRoadStopDir(ti->tile));
|
||||
}
|
||||
|
||||
+2
-2
@@ -347,7 +347,7 @@ inline Axis GetCrossingRoadAxis(Tile t)
|
||||
inline Axis GetCrossingRailAxis(Tile t)
|
||||
{
|
||||
assert(IsLevelCrossing(t));
|
||||
return OtherAxis((Axis)GetCrossingRoadAxis(t));
|
||||
return OtherAxis(GetCrossingRoadAxis(t));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -357,7 +357,7 @@ inline Axis GetCrossingRailAxis(Tile t)
|
||||
*/
|
||||
inline RoadBits GetCrossingRoadBits(Tile tile)
|
||||
{
|
||||
return GetCrossingRoadAxis(tile) == AXIS_X ? ROAD_X : ROAD_Y;
|
||||
return AxisToRoadBits(GetCrossingRoadAxis(tile));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1235,7 +1235,7 @@ bool AfterLoadGame()
|
||||
MakeRailNormal(
|
||||
t,
|
||||
GetTileOwner(t),
|
||||
axis == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X,
|
||||
AxisToTrackBits(OtherAxis(axis)),
|
||||
GetRailType(t)
|
||||
);
|
||||
} else {
|
||||
@@ -1245,7 +1245,7 @@ bool AfterLoadGame()
|
||||
SetTileType(t, TileType::Road);
|
||||
t.m2() = town.base();
|
||||
t.m3() = 0;
|
||||
t.m5() = (axis == AXIS_X ? ROAD_Y : ROAD_X).base() | to_underlying(RoadTileType::Normal) << 6;
|
||||
t.m5() = AxisToRoadBits(OtherAxis(axis)).base() | to_underlying(RoadTileType::Normal) << 6;
|
||||
SB(t.m6(), 2, 4, 0);
|
||||
t.m7() = 1 << 6;
|
||||
SetRoadOwner(t, RoadTramType::Tram, OWNER_NONE);
|
||||
|
||||
+1
-1
@@ -1128,7 +1128,7 @@ static CommandCost CheckFlatLandRoadStop(TileIndex cur_tile, int &allowed_z, con
|
||||
bool build_over_road = is_drive_through && IsNormalRoadTile(cur_tile);
|
||||
/* Road bits in the wrong direction. */
|
||||
RoadBits rb = IsNormalRoadTile(cur_tile) ? GetAllRoadBits(cur_tile) : RoadBits{};
|
||||
if (build_over_road && rb.Any(axis == AXIS_X ? ROAD_Y : ROAD_X)) {
|
||||
if (build_over_road && rb.Any(AxisToRoadBits(OtherAxis(axis)))) {
|
||||
/* Someone was pedantic and *NEEDED* three fracking different error messages. */
|
||||
switch (rb.Count()) {
|
||||
case 1:
|
||||
|
||||
Reference in New Issue
Block a user