mirror of https://github.com/OpenTTD/OpenTTD
(svn r5582) Add and use AxisToTrack{Bits,}()
parent
475f276769
commit
7ec704564a
|
@ -115,10 +115,15 @@ static inline RoadBits GetRoadBitsUnderBridge(TileIndex t)
|
||||||
return GetBridgeAxis(t) == AXIS_X ? ROAD_Y : ROAD_X;
|
return GetBridgeAxis(t) == AXIS_X ? ROAD_Y : ROAD_X;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TrackBits GetRailBitsUnderBridge(TileIndex t)
|
static inline Track GetRailUnderBridge(TileIndex t)
|
||||||
{
|
{
|
||||||
assert(GetTransportTypeUnderBridge(t) == TRANSPORT_RAIL);
|
assert(GetTransportTypeUnderBridge(t) == TRANSPORT_RAIL);
|
||||||
return GetBridgeAxis(t) == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X;
|
return AxisToTrack(OtherAxis(GetBridgeAxis(t)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline TrackBits GetRailBitsUnderBridge(TileIndex t)
|
||||||
|
{
|
||||||
|
return TrackToTrackBits(GetRailUnderBridge(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,12 @@ typedef enum Axis {
|
||||||
} Axis;
|
} Axis;
|
||||||
|
|
||||||
|
|
||||||
|
static inline Axis OtherAxis(Axis a)
|
||||||
|
{
|
||||||
|
return (Axis)(a ^ 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline Axis DiagDirToAxis(DiagDirection d)
|
static inline Axis DiagDirToAxis(DiagDirection d)
|
||||||
{
|
{
|
||||||
return (Axis)(d & 1);
|
return (Axis)(d & 1);
|
||||||
|
|
4
elrail.c
4
elrail.c
|
@ -89,7 +89,7 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
|
||||||
if (IsTunnel(t)) {
|
if (IsTunnel(t)) {
|
||||||
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
|
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
|
||||||
if (override != NULL) *override = 1 << GetTunnelDirection(t);
|
if (override != NULL) *override = 1 << GetTunnelDirection(t);
|
||||||
return DiagDirToAxis(GetTunnelDirection(t)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y;
|
return AxisToTrackBits(DiagDirToAxis(GetTunnelDirection(t)));
|
||||||
} else {
|
} else {
|
||||||
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
|
if (GetRailType(t) != RAILTYPE_ELECTRIC) return 0;
|
||||||
if (IsBridgeMiddle(t)) {
|
if (IsBridgeMiddle(t)) {
|
||||||
|
@ -102,7 +102,7 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
|
||||||
} else {
|
} else {
|
||||||
if (override != NULL && DistanceMax(t, GetOtherBridgeEnd(t)) > 1) *override = 1 << GetBridgeRampDirection(t);
|
if (override != NULL && DistanceMax(t, GetOtherBridgeEnd(t)) > 1) *override = 1 << GetBridgeRampDirection(t);
|
||||||
|
|
||||||
return DiagDirToAxis(GetBridgeRampDirection(t)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y;
|
return AxisToTrackBits(DiagDirToAxis(GetBridgeRampDirection(t)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
31
rail.h
31
rail.h
|
@ -34,6 +34,17 @@ typedef enum Track {
|
||||||
} Track;
|
} Track;
|
||||||
|
|
||||||
|
|
||||||
|
/** Convert an Axis to the corresponding Track
|
||||||
|
* AXIS_X -> TRACK_X
|
||||||
|
* AXIS_Y -> TRACK_Y
|
||||||
|
* Uses the fact that they share the same internal encoding
|
||||||
|
*/
|
||||||
|
static inline Track AxisToTrack(Axis a)
|
||||||
|
{
|
||||||
|
return (Track)a;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Bitfield corresponding to Track */
|
/** Bitfield corresponding to Track */
|
||||||
typedef enum TrackBits {
|
typedef enum TrackBits {
|
||||||
TRACK_BIT_NONE = 0U,
|
TRACK_BIT_NONE = 0U,
|
||||||
|
@ -55,6 +66,21 @@ typedef enum TrackBits {
|
||||||
} TrackBits;
|
} TrackBits;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps a Track to the corresponding TrackBits value
|
||||||
|
*/
|
||||||
|
static inline TrackBits TrackToTrackBits(Track track)
|
||||||
|
{
|
||||||
|
return (TrackBits)(1 << track);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline TrackBits AxisToTrackBits(Axis a)
|
||||||
|
{
|
||||||
|
return TrackToTrackBits(AxisToTrack(a));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** These are a combination of tracks and directions. Values are 0-5 in one
|
/** These are a combination of tracks and directions. Values are 0-5 in one
|
||||||
direction (corresponding to the Track enum) and 8-13 in the other direction. */
|
direction (corresponding to the Track enum) and 8-13 in the other direction. */
|
||||||
typedef enum Trackdirs {
|
typedef enum Trackdirs {
|
||||||
|
@ -241,11 +267,6 @@ static inline Trackdir ReverseTrackdir(Trackdir trackdir) {
|
||||||
return (Trackdir)(trackdir ^ 8);
|
return (Trackdir)(trackdir ^ 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Maps a Track to the corresponding TrackBits value
|
|
||||||
*/
|
|
||||||
static inline TrackBits TrackToTrackBits(Track track) { return (TrackBits)(1 << track); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Track that a given Trackdir represents
|
* Returns the Track that a given Trackdir represents
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -234,7 +234,7 @@ int32 CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
case MP_TUNNELBRIDGE:
|
case MP_TUNNELBRIDGE:
|
||||||
if (!IsBridge(tile) ||
|
if (!IsBridge(tile) ||
|
||||||
!IsBridgeMiddle(tile) ||
|
!IsBridgeMiddle(tile) ||
|
||||||
(GetBridgeAxis(tile) == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X) != trackbit) {
|
AxisToTrackBits(OtherAxis(GetBridgeAxis(tile))) != trackbit) {
|
||||||
// Get detailed error message
|
// Get detailed error message
|
||||||
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
|
||||||
}
|
}
|
||||||
|
@ -1918,7 +1918,7 @@ static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode)
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
if (GetRailTileSubtype(tile) == RAIL_SUBTYPE_DEPOT) {
|
if (GetRailTileSubtype(tile) == RAIL_SUBTYPE_DEPOT) {
|
||||||
return (DiagDirToAxis(GetRailDepotDirection(tile)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
return AxisToTrackBits(DiagDirToAxis(GetRailDepotDirection(tile))) * 0x101;
|
||||||
} else {
|
} else {
|
||||||
return GetRailWaypointBits(tile) * 0x101;
|
return GetRailWaypointBits(tile) * 0x101;
|
||||||
}
|
}
|
||||||
|
|
20
rail_map.h
20
rail_map.h
|
@ -126,22 +126,22 @@ static inline DiagDirection GetRailDepotDirection(TileIndex t)
|
||||||
return (DiagDirection)GB(_m[t].m5, 0, 2);
|
return (DiagDirection)GB(_m[t].m5, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Track GetRailWaypointTrack(TileIndex t)
|
|
||||||
{
|
|
||||||
return HASBIT(_m[t].m5, 0) ? TRACK_Y : TRACK_X;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline TrackBits GetRailWaypointBits(TileIndex t)
|
|
||||||
{
|
|
||||||
return _m[t].m5 & 1 ? TRACK_BIT_Y : TRACK_BIT_X;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline Axis GetWaypointAxis(TileIndex t)
|
static inline Axis GetWaypointAxis(TileIndex t)
|
||||||
{
|
{
|
||||||
return HASBIT(_m[t].m5, 0) ? AXIS_Y : AXIS_X;
|
return HASBIT(_m[t].m5, 0) ? AXIS_Y : AXIS_X;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline Track GetRailWaypointTrack(TileIndex t)
|
||||||
|
{
|
||||||
|
return AxisToTrack(GetWaypointAxis(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline TrackBits GetRailWaypointBits(TileIndex t)
|
||||||
|
{
|
||||||
|
return TrackToTrackBits(GetRailWaypointTrack(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef enum SignalType {
|
typedef enum SignalType {
|
||||||
SIGTYPE_NORMAL = 0, // normal signal
|
SIGTYPE_NORMAL = 0, // normal signal
|
||||||
|
|
|
@ -991,7 +991,7 @@ static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode)
|
||||||
return HasRoadWorks(tile) ? 0 : _road_trackbits[GetRoadBits(tile)] * 0x101;
|
return HasRoadWorks(tile) ? 0 : _road_trackbits[GetRoadBits(tile)] * 0x101;
|
||||||
|
|
||||||
case ROAD_TILE_CROSSING: {
|
case ROAD_TILE_CROSSING: {
|
||||||
uint32 r = (GetCrossingRoadAxis(tile) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
uint32 r = AxisToTrackBits(GetCrossingRoadAxis(tile)) * 0x101;
|
||||||
|
|
||||||
if (IsCrossingBarred(tile)) r *= 0x10001;
|
if (IsCrossingBarred(tile)) r *= 0x10001;
|
||||||
return r;
|
return r;
|
||||||
|
@ -999,7 +999,7 @@ static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
case ROAD_TILE_DEPOT:
|
case ROAD_TILE_DEPOT:
|
||||||
return (DiagDirToAxis(GetRoadDepotDirection(tile)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
return AxisToTrackBits(DiagDirToAxis(GetRoadDepotDirection(tile))) * 0x101;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ static inline RoadBits GetCrossingRoadBits(TileIndex tile)
|
||||||
|
|
||||||
static inline TrackBits GetCrossingRailBits(TileIndex tile)
|
static inline TrackBits GetCrossingRailBits(TileIndex tile)
|
||||||
{
|
{
|
||||||
return GetCrossingRoadAxis(tile) == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X;
|
return AxisToTrackBits(OtherAxis(GetCrossingRoadAxis(tile)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1087,7 +1087,7 @@ int32 CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint3
|
||||||
st->build_date = _date;
|
st->build_date = _date;
|
||||||
|
|
||||||
tile_delta = (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
tile_delta = (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
|
||||||
track = (axis == AXIS_X ? TRACK_X : TRACK_Y);
|
track = AxisToTrack(axis);
|
||||||
|
|
||||||
layout_ptr = alloca(numtracks * plat_len);
|
layout_ptr = alloca(numtracks * plat_len);
|
||||||
GetStationLayout(layout_ptr, numtracks, plat_len, statspec);
|
GetStationLayout(layout_ptr, numtracks, plat_len, statspec);
|
||||||
|
@ -2216,7 +2216,7 @@ static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode)
|
||||||
|
|
||||||
case TRANSPORT_ROAD:
|
case TRANSPORT_ROAD:
|
||||||
if (IsRoadStopTile(tile)) {
|
if (IsRoadStopTile(tile)) {
|
||||||
return (DiagDirToAxis(GetRoadStopDir(tile)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
return AxisToTrackBits(DiagDirToAxis(GetRoadStopDir(tile))) * 0x101;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,7 @@ static inline Axis GetRailStationAxis(TileIndex t)
|
||||||
|
|
||||||
static inline Track GetRailStationTrack(TileIndex t)
|
static inline Track GetRailStationTrack(TileIndex t)
|
||||||
{
|
{
|
||||||
return GetRailStationAxis(t) == AXIS_X ? TRACK_X : TRACK_Y;
|
return AxisToTrack(GetRailStationAxis(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
|
static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
|
||||||
|
|
|
@ -335,7 +335,7 @@ int32 CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
case MP_RAILWAY:
|
case MP_RAILWAY:
|
||||||
if (GetRailTileType(tile) != RAIL_TILE_NORMAL ||
|
if (GetRailTileType(tile) != RAIL_TILE_NORMAL ||
|
||||||
GetTrackBits(tile) != (direction == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X)) {
|
GetTrackBits(tile) != AxisToTrackBits(OtherAxis(direction))) {
|
||||||
goto not_valid_below;
|
goto not_valid_below;
|
||||||
}
|
}
|
||||||
transport_under = TRANSPORT_RAIL;
|
transport_under = TRANSPORT_RAIL;
|
||||||
|
@ -415,8 +415,8 @@ not_valid_below:;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSignalsOnBothDir(tile_start, direction == AXIS_X ? TRACK_X : TRACK_Y);
|
SetSignalsOnBothDir(tile_start, AxisToTrack(direction));
|
||||||
YapfNotifyTrackLayoutChange(tile_start, direction == AXIS_X ? TRACK_X : TRACK_Y);
|
YapfNotifyTrackLayoutChange(tile_start, AxisToTrack(direction));
|
||||||
|
|
||||||
/* for human player that builds the bridge he gets a selection to choose from bridges (DC_QUERY_COST)
|
/* for human player that builds the bridge he gets a selection to choose from bridges (DC_QUERY_COST)
|
||||||
It's unnecessary to execute this command every time for every bridge. So it is done only
|
It's unnecessary to execute this command every time for every bridge. So it is done only
|
||||||
|
@ -507,7 +507,7 @@ int32 CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
MakeRailTunnel(start_tile, _current_player, direction, GB(p1, 0, 4));
|
MakeRailTunnel(start_tile, _current_player, direction, GB(p1, 0, 4));
|
||||||
MakeRailTunnel(end_tile, _current_player, ReverseDiagDir(direction), GB(p1, 0, 4));
|
MakeRailTunnel(end_tile, _current_player, ReverseDiagDir(direction), GB(p1, 0, 4));
|
||||||
UpdateSignalsOnSegment(start_tile, direction);
|
UpdateSignalsOnSegment(start_tile, direction);
|
||||||
YapfNotifyTrackLayoutChange(start_tile, DiagDirToAxis(direction) == AXIS_X ? TRACK_X : TRACK_Y);
|
YapfNotifyTrackLayoutChange(start_tile, AxisToTrack(DiagDirToAxis(direction)));
|
||||||
} else {
|
} else {
|
||||||
MakeRoadTunnel(start_tile, _current_player, direction);
|
MakeRoadTunnel(start_tile, _current_player, direction);
|
||||||
MakeRoadTunnel(end_tile, _current_player, ReverseDiagDir(direction));
|
MakeRoadTunnel(end_tile, _current_player, ReverseDiagDir(direction));
|
||||||
|
@ -579,6 +579,7 @@ static int32 DoClearTunnel(TileIndex tile, uint32 flags)
|
||||||
// We first need to request the direction before calling DoClearSquare
|
// We first need to request the direction before calling DoClearSquare
|
||||||
// else the direction is always 0.. dah!! ;)
|
// else the direction is always 0.. dah!! ;)
|
||||||
DiagDirection dir = GetTunnelDirection(tile);
|
DiagDirection dir = GetTunnelDirection(tile);
|
||||||
|
Track track;
|
||||||
|
|
||||||
// Adjust the town's player rating. Do this before removing the tile owner info.
|
// Adjust the town's player rating. Do this before removing the tile owner info.
|
||||||
if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR)
|
if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR)
|
||||||
|
@ -588,8 +589,9 @@ static int32 DoClearTunnel(TileIndex tile, uint32 flags)
|
||||||
DoClearSquare(endtile);
|
DoClearSquare(endtile);
|
||||||
UpdateSignalsOnSegment(tile, ReverseDiagDir(dir));
|
UpdateSignalsOnSegment(tile, ReverseDiagDir(dir));
|
||||||
UpdateSignalsOnSegment(endtile, dir);
|
UpdateSignalsOnSegment(endtile, dir);
|
||||||
YapfNotifyTrackLayoutChange(tile, DiagDirToAxis(dir) == AXIS_X ? TRACK_X : TRACK_Y);
|
track = AxisToTrack(DiagDirToAxis(dir));
|
||||||
YapfNotifyTrackLayoutChange(endtile, DiagDirToAxis(dir) == AXIS_X ? TRACK_X : TRACK_Y);
|
YapfNotifyTrackLayoutChange(tile, track);
|
||||||
|
YapfNotifyTrackLayoutChange(endtile, track);
|
||||||
}
|
}
|
||||||
return _price.clear_tunnel * (length + 1);
|
return _price.clear_tunnel * (length + 1);
|
||||||
}
|
}
|
||||||
|
@ -687,6 +689,7 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
TileIndex c;
|
TileIndex c;
|
||||||
|
Track track;
|
||||||
|
|
||||||
//checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until
|
//checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until
|
||||||
// you have a "Poor" (0) town rating
|
// you have a "Poor" (0) town rating
|
||||||
|
@ -724,8 +727,9 @@ static int32 DoClearBridge(TileIndex tile, uint32 flags)
|
||||||
|
|
||||||
UpdateSignalsOnSegment(tile, ReverseDiagDir(direction));
|
UpdateSignalsOnSegment(tile, ReverseDiagDir(direction));
|
||||||
UpdateSignalsOnSegment(endtile, direction);
|
UpdateSignalsOnSegment(endtile, direction);
|
||||||
YapfNotifyTrackLayoutChange(tile, DiagDirToAxis(direction) == AXIS_X ? TRACK_X : TRACK_Y);
|
track = AxisToTrack(DiagDirToAxis(direction));
|
||||||
YapfNotifyTrackLayoutChange(endtile, DiagDirToAxis(direction) == AXIS_X ? TRACK_X : TRACK_Y);
|
YapfNotifyTrackLayoutChange(tile, track);
|
||||||
|
YapfNotifyTrackLayoutChange(endtile, track);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (DistanceManhattan(tile, endtile) + 1) * _price.clear_bridge;
|
return (DistanceManhattan(tile, endtile) + 1) * _price.clear_bridge;
|
||||||
|
@ -759,17 +763,15 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
|
||||||
if (endtile == INVALID_TILE) return CMD_ERROR;
|
if (endtile == INVALID_TILE) return CMD_ERROR;
|
||||||
|
|
||||||
if (exec) {
|
if (exec) {
|
||||||
Track track, endtrack;
|
Track track;
|
||||||
SetRailType(tile, totype);
|
SetRailType(tile, totype);
|
||||||
SetRailType(endtile, totype);
|
SetRailType(endtile, totype);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
MarkTileDirtyByTile(endtile);
|
MarkTileDirtyByTile(endtile);
|
||||||
|
|
||||||
// notify YAPF about the track layout change
|
track = AxisToTrack(DiagDirToAxis(GetTunnelDirection(tile)));
|
||||||
track = TrackdirToTrack(DiagdirToDiagTrackdir(GetTunnelDirection(tile)));
|
|
||||||
endtrack = TrackdirToTrack(DiagdirToDiagTrackdir(GetTunnelDirection(endtile)));
|
|
||||||
YapfNotifyTrackLayoutChange(tile, track);
|
YapfNotifyTrackLayoutChange(tile, track);
|
||||||
YapfNotifyTrackLayoutChange(endtile, endtrack);
|
YapfNotifyTrackLayoutChange(endtile, track);
|
||||||
}
|
}
|
||||||
return (length + 1) * (_price.build_rail >> 1);
|
return (length + 1) * (_price.build_rail >> 1);
|
||||||
} else if (IsBridge(tile) &&
|
} else if (IsBridge(tile) &&
|
||||||
|
@ -783,13 +785,10 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
|
||||||
if (GetRailType(tile) == totype) return CMD_ERROR;
|
if (GetRailType(tile) == totype) return CMD_ERROR;
|
||||||
|
|
||||||
if (exec) {
|
if (exec) {
|
||||||
TrackBits tracks;
|
|
||||||
SetRailType(tile, totype);
|
SetRailType(tile, totype);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
|
|
||||||
// notify YAPF about the track layout change
|
YapfNotifyTrackLayoutChange(tile, GetRailUnderBridge(tile));
|
||||||
for (tracks = GetRailBitsUnderBridge(tile); tracks != TRACK_BIT_NONE; tracks = KILL_FIRST_BIT(tracks))
|
|
||||||
YapfNotifyTrackLayoutChange(tile, FIND_FIRST_BIT(tracks));
|
|
||||||
}
|
}
|
||||||
return _price.build_rail >> 1;
|
return _price.build_rail >> 1;
|
||||||
} else if (IsBridge(tile) && IsBridgeRamp(tile) && GetBridgeTransportType(tile) == TRANSPORT_RAIL) {
|
} else if (IsBridge(tile) && IsBridgeRamp(tile) && GetBridgeTransportType(tile) == TRANSPORT_RAIL) {
|
||||||
|
@ -813,17 +812,15 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
|
||||||
if (GetRailType(tile) == totype) return CMD_ERROR;
|
if (GetRailType(tile) == totype) return CMD_ERROR;
|
||||||
|
|
||||||
if (exec) {
|
if (exec) {
|
||||||
Track track, endtrack;
|
Track track;
|
||||||
SetRailType(tile, totype);
|
SetRailType(tile, totype);
|
||||||
SetRailType(endtile, totype);
|
SetRailType(endtile, totype);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
MarkTileDirtyByTile(endtile);
|
MarkTileDirtyByTile(endtile);
|
||||||
|
|
||||||
// notify YAPF about the track layout change
|
track = AxisToTrack(DiagDirToAxis(GetBridgeRampDirection(tile)));
|
||||||
track = TrackdirToTrack(DiagdirToDiagTrackdir(GetBridgeRampDirection(tile)));
|
|
||||||
endtrack = TrackdirToTrack(DiagdirToDiagTrackdir(GetBridgeRampDirection(endtile)));
|
|
||||||
YapfNotifyTrackLayoutChange(tile, track);
|
YapfNotifyTrackLayoutChange(tile, track);
|
||||||
YapfNotifyTrackLayoutChange(endtile, endtrack);
|
YapfNotifyTrackLayoutChange(endtile, track);
|
||||||
}
|
}
|
||||||
cost = 2 * (_price.build_rail >> 1);
|
cost = 2 * (_price.build_rail >> 1);
|
||||||
delta = TileOffsByDir(GetBridgeRampDirection(tile));
|
delta = TileOffsByDir(GetBridgeRampDirection(tile));
|
||||||
|
@ -1273,20 +1270,20 @@ static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode
|
||||||
{
|
{
|
||||||
if (IsTunnel(tile)) {
|
if (IsTunnel(tile)) {
|
||||||
if (GetTunnelTransportType(tile) != mode) return 0;
|
if (GetTunnelTransportType(tile) != mode) return 0;
|
||||||
return (DiagDirToAxis(GetTunnelDirection(tile)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
return AxisToTrackBits(DiagDirToAxis(GetTunnelDirection(tile))) * 0x101;
|
||||||
} else {
|
} else {
|
||||||
if (IsBridgeRamp(tile)) {
|
if (IsBridgeRamp(tile)) {
|
||||||
if (GetBridgeTransportType(tile) != mode) return 0;
|
if (GetBridgeTransportType(tile) != mode) return 0;
|
||||||
return (DiagDirToAxis(GetBridgeRampDirection(tile)) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
return AxisToTrackBits(DiagDirToAxis(GetBridgeRampDirection(tile))) * 0x101;
|
||||||
} else {
|
} else {
|
||||||
uint32 result = 0;
|
uint32 result = 0;
|
||||||
|
|
||||||
if (GetBridgeTransportType(tile) == mode) {
|
if (GetBridgeTransportType(tile) == mode) {
|
||||||
result = (GetBridgeAxis(tile) == AXIS_X ? TRACK_BIT_X : TRACK_BIT_Y) * 0x101;
|
result = AxisToTrackBits(GetBridgeAxis(tile)) * 0x101;
|
||||||
}
|
}
|
||||||
if ((IsTransportUnderBridge(tile) && mode == GetTransportTypeUnderBridge(tile)) ||
|
if ((IsTransportUnderBridge(tile) && mode == GetTransportTypeUnderBridge(tile)) ||
|
||||||
(IsWaterUnderBridge(tile) && mode == TRANSPORT_WATER)) {
|
(IsWaterUnderBridge(tile) && mode == TRANSPORT_WATER)) {
|
||||||
result |= (GetBridgeAxis(tile) == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X) * 0x101;
|
result |= AxisToTrackBits(OtherAxis(GetBridgeAxis(tile))) * 0x101;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue