diff options
-rw-r--r-- | src/openttd.cpp | 2 | ||||
-rw-r--r-- | src/rail_cmd.cpp | 2 | ||||
-rw-r--r-- | src/road_cmd.cpp | 2 | ||||
-rw-r--r-- | src/road_map.h | 13 | ||||
-rw-r--r-- | src/train_cmd.cpp | 2 |
5 files changed, 16 insertions, 5 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp index 4ec3fc919..28da4c2dd 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -2393,7 +2393,7 @@ bool AfterLoadGame() if (!GetPlayer(o)->is_active) { /* remove leftover rail piece from crossing (from very old savegames) */ _current_player = o; - DoCommand(t, 0, AxisToTrack(OtherAxis(GetCrossingRoadAxis(t))), DC_EXEC | DC_BANKRUPT, CMD_REMOVE_SINGLE_RAIL); + DoCommand(t, 0, GetCrossingRailTrack(t), DC_EXEC | DC_BANKRUPT, CMD_REMOVE_SINGLE_RAIL); } } } diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index f2ffaff89..a67f74b4a 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1313,7 +1313,7 @@ CommandCost CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) default: // MP_STATION, MP_ROAD if (flags & DC_EXEC) { - Track track = (tt == MP_STATION) ? GetRailStationTrack(tile) : AxisToTrack(OtherAxis(GetCrossingRoadAxis(tile))); + Track track = ((tt == MP_STATION) ? GetRailStationTrack(tile) : GetCrossingRailTrack(tile)); YapfNotifyTrackLayoutChange(tile, track); } diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 97bb769d8..40d520288 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -1448,7 +1448,7 @@ static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID n if (IsLevelCrossing(tile)) { if (GetTileOwner(tile) == old_player) { if (new_player == PLAYER_SPECTATOR) { - DoCommand(tile, 0, AxisToTrack(OtherAxis(GetCrossingRoadAxis(tile))), DC_EXEC | DC_BANKRUPT, CMD_REMOVE_SINGLE_RAIL); + DoCommand(tile, 0, GetCrossingRailTrack(tile), DC_EXEC | DC_BANKRUPT, CMD_REMOVE_SINGLE_RAIL); } else { SetTileOwner(tile, new_player); } diff --git a/src/road_map.h b/src/road_map.h index 305c77375..35a3f9cf2 100644 --- a/src/road_map.h +++ b/src/road_map.h @@ -206,14 +206,25 @@ static inline Axis GetCrossingRoadAxis(TileIndex t) return (Axis)GB(_m[t].m4, 6, 1); } +static inline Axis GetCrossingRailAxis(TileIndex t) +{ + assert(IsLevelCrossing(t)); + return OtherAxis((Axis)GetCrossingRoadAxis(t)); +} + static inline RoadBits GetCrossingRoadBits(TileIndex tile) { return GetCrossingRoadAxis(tile) == AXIS_X ? ROAD_X : ROAD_Y; } +static inline Track GetCrossingRailTrack(TileIndex tile) +{ + return AxisToTrack(GetCrossingRailAxis(tile)); +} + static inline TrackBits GetCrossingRailBits(TileIndex tile) { - return AxisToTrackBits(OtherAxis(GetCrossingRoadAxis(tile))); + return AxisToTrackBits(GetCrossingRailAxis(tile)); } static inline bool IsCrossingBarred(TileIndex t) diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index d305391a9..e4f0a6bf5 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -1667,7 +1667,7 @@ static Vehicle *TrainApproachingCrossing(TileIndex tile) { assert(IsLevelCrossingTile(tile)); - DiagDirection dir = AxisToDiagDir(OtherAxis(GetCrossingRoadAxis(tile))); + DiagDirection dir = AxisToDiagDir(GetCrossingRailAxis(tile)); TileIndex tile_from = tile + TileOffsByDiagDir(dir); Vehicle *v = (Vehicle *)VehicleFromPos(tile_from, &tile, &TrainApproachingCrossingEnum); |