mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-01 20:03:26 +00:00
(svn r16349) -Codechange: rename IsPlainRailTile() to IsPlainRail(), introduce shiny new IsPlainRailTile()
This commit is contained in:
parent
d1f9a90d32
commit
0af27062c4
@ -221,7 +221,7 @@
|
||||
/* static */ bool AIRail::RemoveRailTrack(TileIndex tile, RailTrack rail_track)
|
||||
{
|
||||
EnforcePrecondition(false, ::IsValidTile(tile));
|
||||
EnforcePrecondition(false, ::IsTileType(tile, MP_RAILWAY) && ::IsPlainRailTile(tile));
|
||||
EnforcePrecondition(false, ::IsPlainRailTile(tile));
|
||||
EnforcePrecondition(false, GetRailTracks(tile) & rail_track);
|
||||
EnforcePrecondition(false, KillFirstBit((uint)rail_track) == 0);
|
||||
|
||||
@ -404,7 +404,7 @@ static bool IsValidSignalType(int signal_type)
|
||||
/* static */ bool AIRail::BuildSignal(TileIndex tile, TileIndex front, SignalType signal)
|
||||
{
|
||||
EnforcePrecondition(false, AIMap::DistanceManhattan(tile, front) == 1)
|
||||
EnforcePrecondition(false, ::IsTileType(tile, MP_RAILWAY) && ::IsPlainRailTile(tile));
|
||||
EnforcePrecondition(false, ::IsPlainRailTile(tile));
|
||||
EnforcePrecondition(false, ::IsValidSignalType(signal));
|
||||
|
||||
Track track = INVALID_TRACK;
|
||||
|
@ -545,8 +545,7 @@ static void DisasterTick_Big_Ufo(Vehicle *v)
|
||||
TileIndex tile_org = RandomTile();
|
||||
TileIndex tile = tile_org;
|
||||
do {
|
||||
if (IsTileType(tile, MP_RAILWAY) &&
|
||||
IsPlainRailTile(tile) &&
|
||||
if (IsPlainRailTile(tile) &&
|
||||
IsHumanCompany(GetTileOwner(tile))) {
|
||||
break;
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
|
||||
*/
|
||||
static TrackBits MaskWireBits(TileIndex t, TrackBits tracks)
|
||||
{
|
||||
if (!IsTileType(t, MP_RAILWAY) || !IsPlainRailTile(t)) return tracks;
|
||||
if (!IsPlainRail(t)) return tracks;
|
||||
|
||||
TrackdirBits neighbour_tdb = TRACKDIR_BIT_NONE;
|
||||
for (DiagDirection d = DIAGDIR_BEGIN; d < DIAGDIR_END; d++) {
|
||||
|
@ -611,7 +611,7 @@ start_at:
|
||||
|
||||
/* Not a regular rail tile?
|
||||
* Then we can't use the code below, but revert to more general code. */
|
||||
if (!IsTileType(tile, MP_RAILWAY) || !IsPlainRailTile(tile)) {
|
||||
if (!IsPlainRailTile(tile)) {
|
||||
/* We found a tile which is not a normal railway tile.
|
||||
* Determine which tracks that exist on this tile. */
|
||||
bits = TrackdirBitsToTrackBits(TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0)) & DiagdirReachesTrackdirs(direction));
|
||||
|
@ -18,7 +18,7 @@ TrackBits GetReservedTrackbits(TileIndex t)
|
||||
switch (GetTileType(t)) {
|
||||
case MP_RAILWAY:
|
||||
if (IsRailWaypoint(t) || IsRailDepot(t)) return GetRailWaypointReservation(t);
|
||||
if (IsPlainRailTile(t)) return GetTrackReservation(t);
|
||||
if (IsPlainRail(t)) return GetTrackReservation(t);
|
||||
break;
|
||||
|
||||
case MP_ROAD:
|
||||
@ -79,7 +79,7 @@ bool TryReserveRailTrack(TileIndex tile, Track t)
|
||||
|
||||
switch (GetTileType(tile)) {
|
||||
case MP_RAILWAY:
|
||||
if (IsPlainRailTile(tile)) return TryReserveTrack(tile, t);
|
||||
if (IsPlainRail(tile)) return TryReserveTrack(tile, t);
|
||||
if (IsRailWaypoint(tile) || IsRailDepot(tile)) {
|
||||
if (!GetDepotWaypointReservation(tile)) {
|
||||
SetDepotWaypointReservation(tile, true);
|
||||
@ -139,7 +139,7 @@ bool TryReserveRailTrack(TileIndex tile, Track t)
|
||||
MarkTileDirtyByTile(tile);
|
||||
break;
|
||||
}
|
||||
if (IsPlainRailTile(tile)) UnreserveTrack(tile, t);
|
||||
if (IsPlainRail(tile)) UnreserveTrack(tile, t);
|
||||
break;
|
||||
|
||||
case MP_ROAD:
|
||||
|
@ -118,7 +118,7 @@ static bool CheckTrackCombination(TileIndex tile, TrackBits to_build, uint flags
|
||||
TrackBits future; // The track layout we want to build
|
||||
_error_message = STR_ERROR_IMPOSSIBLE_TRACK_COMBINATION;
|
||||
|
||||
if (!IsPlainRailTile(tile)) return false;
|
||||
if (!IsPlainRail(tile)) return false;
|
||||
|
||||
/* So, we have a tile with tracks on it (and possibly signals). Let's see
|
||||
* what tracks first */
|
||||
@ -321,7 +321,7 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
||||
case MP_RAILWAY:
|
||||
if (!CheckTileOwnership(tile)) return CMD_ERROR;
|
||||
|
||||
if (!IsPlainRailTile(tile)) return CMD_ERROR;
|
||||
if (!IsPlainRail(tile)) return CMD_ERROR;
|
||||
|
||||
if (!IsCompatibleRail(GetRailType(tile), railtype)) return_cmd_error(STR_ERROR_IMPOSSIBLE_TRACK_COMBINATION);
|
||||
|
||||
@ -481,7 +481,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||
case MP_RAILWAY: {
|
||||
TrackBits present;
|
||||
|
||||
if (!IsPlainRailTile(tile) ||
|
||||
if (!IsPlainRail(tile) ||
|
||||
(_current_company != OWNER_WATER && !CheckTileOwnership(tile)) ||
|
||||
!EnsureNoTrainOnTrack(tile, track)) {
|
||||
return CMD_ERROR;
|
||||
@ -825,15 +825,15 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||
|
||||
if (sigtype > SIGTYPE_LAST) return CMD_ERROR;
|
||||
|
||||
if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoTrainOnTrack(tile, track))
|
||||
/* You can only build signals on plain rail tiles, and the selected track must exist */
|
||||
if (!ValParamTrackOrientation(track) || !IsPlainRailTile(tile) ||
|
||||
!EnsureNoTrainOnTrack(tile, track) || !HasTrack(tile, track)) {
|
||||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
/* Protect against invalid signal copying */
|
||||
if (p2 != 0 && (p2 & SignalOnTrack(track)) == 0) return CMD_ERROR;
|
||||
|
||||
/* You can only build signals on plain rail tiles, and the selected track must exist */
|
||||
if (!IsPlainRailTile(tile) || !HasTrack(tile, track)) return CMD_ERROR;
|
||||
|
||||
if (!CheckTileOwnership(tile)) return CMD_ERROR;
|
||||
|
||||
{
|
||||
@ -1047,7 +1047,7 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uin
|
||||
end_tile = p1;
|
||||
if (signal_density == 0 || signal_density > 20) return CMD_ERROR;
|
||||
|
||||
if (!IsTileType(tile, MP_RAILWAY) || !IsPlainRailTile(tile)) return CMD_ERROR;
|
||||
if (!IsPlainRailTile(tile)) return CMD_ERROR;
|
||||
|
||||
/* for vertical/horizontal tracks, double the given signals density
|
||||
* since the original amount will be too dense (shorter tracks) */
|
||||
@ -1172,7 +1172,6 @@ CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1
|
||||
Track track = (Track)GB(p1, 0, 3);
|
||||
|
||||
if (!ValParamTrackOrientation(track) ||
|
||||
!IsTileType(tile, MP_RAILWAY) ||
|
||||
!IsPlainRailTile(tile) ||
|
||||
!HasTrack(tile, track) ||
|
||||
!EnsureNoTrainOnTrack(tile, track) ||
|
||||
@ -1456,10 +1455,11 @@ static CommandCost ClearTile_Track(TileIndex tile, DoCommandFlag flags)
|
||||
CommandCost ret;
|
||||
|
||||
if (flags & DC_AUTO) {
|
||||
if (!IsTileOwner(tile, _current_company))
|
||||
if (!IsTileOwner(tile, _current_company)) {
|
||||
return_cmd_error(STR_ERROR_AREA_IS_OWNED_BY_ANOTHER);
|
||||
}
|
||||
|
||||
if (IsPlainRailTile(tile)) {
|
||||
if (IsPlainRail(tile)) {
|
||||
return_cmd_error(STR_ERROR_MUST_REMOVE_RAILROAD_TRACK);
|
||||
} else {
|
||||
return_cmd_error(STR_ERROR_BUILDING_MUST_BE_DEMOLISHED);
|
||||
@ -1889,7 +1889,7 @@ static void DrawTile_Track(TileInfo *ti)
|
||||
|
||||
_drawtile_track_palette = COMPANY_SPRITE_COLOUR(GetTileOwner(ti->tile));
|
||||
|
||||
if (IsPlainRailTile(ti->tile)) {
|
||||
if (IsPlainRail(ti->tile)) {
|
||||
TrackBits rails = GetTrackBits(ti->tile);
|
||||
|
||||
DrawTrackBits(ti, rails);
|
||||
@ -2059,7 +2059,7 @@ static uint GetSlopeZ_Track(TileIndex tile, uint x, uint y)
|
||||
Slope tileh = GetTileSlope(tile, &z);
|
||||
|
||||
if (tileh == SLOPE_FLAT) return z;
|
||||
if (IsPlainRailTile(tile)) {
|
||||
if (IsPlainRail(tile)) {
|
||||
z += ApplyFoundationToSlope(GetRailFoundation(tileh, GetTrackBits(tile)), &tileh);
|
||||
return z + GetPartialZ(x & 0xF, y & 0xF, tileh);
|
||||
} else {
|
||||
@ -2069,7 +2069,7 @@ static uint GetSlopeZ_Track(TileIndex tile, uint x, uint y)
|
||||
|
||||
static Foundation GetFoundation_Track(TileIndex tile, Slope tileh)
|
||||
{
|
||||
return IsPlainRailTile(tile) ? GetRailFoundation(tileh, GetTrackBits(tile)) : FlatteningFoundation(tileh);
|
||||
return IsPlainRail(tile) ? GetRailFoundation(tileh, GetTrackBits(tile)) : FlatteningFoundation(tileh);
|
||||
}
|
||||
|
||||
static void GetAcceptedCargo_Track(TileIndex tile, AcceptedCargo ac)
|
||||
@ -2100,7 +2100,7 @@ static void TileLoop_Track(TileIndex tile)
|
||||
|
||||
/* for non-flat track, use lower part of track
|
||||
* in other cases, use the highest part with track */
|
||||
if (IsPlainRailTile(tile)) {
|
||||
if (IsPlainRail(tile)) {
|
||||
TrackBits track = GetTrackBits(tile);
|
||||
Foundation f = GetRailFoundation(slope, track);
|
||||
|
||||
@ -2158,7 +2158,7 @@ static void TileLoop_Track(TileIndex tile)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!IsPlainRailTile(tile)) return;
|
||||
if (!IsPlainRail(tile)) return;
|
||||
|
||||
new_ground = RAIL_GROUND_GRASS;
|
||||
|
||||
@ -2180,7 +2180,7 @@ static void TileLoop_Track(TileIndex tile)
|
||||
(rail & TRACK_BIT_X)
|
||||
)) {
|
||||
TileIndex n = tile + TileDiffXY(0, -1);
|
||||
TrackBits nrail = (IsTileType(n, MP_RAILWAY) && IsPlainRailTile(n) ? GetTrackBits(n) : TRACK_BIT_NONE);
|
||||
TrackBits nrail = (IsPlainRailTile(n) ? GetTrackBits(n) : TRACK_BIT_NONE);
|
||||
|
||||
if (!IsTileType(n, MP_RAILWAY) ||
|
||||
!IsTileOwner(n, owner) ||
|
||||
@ -2195,7 +2195,7 @@ static void TileLoop_Track(TileIndex tile)
|
||||
(rail & TRACK_BIT_X)
|
||||
)) {
|
||||
TileIndex n = tile + TileDiffXY(0, 1);
|
||||
TrackBits nrail = (IsTileType(n, MP_RAILWAY) && IsPlainRailTile(n) ? GetTrackBits(n) : TRACK_BIT_NONE);
|
||||
TrackBits nrail = (IsPlainRailTile(n) ? GetTrackBits(n) : TRACK_BIT_NONE);
|
||||
|
||||
if (!IsTileType(n, MP_RAILWAY) ||
|
||||
!IsTileOwner(n, owner) ||
|
||||
@ -2211,7 +2211,7 @@ static void TileLoop_Track(TileIndex tile)
|
||||
(rail & TRACK_BIT_Y)
|
||||
)) {
|
||||
TileIndex n = tile + TileDiffXY(-1, 0);
|
||||
TrackBits nrail = (IsTileType(n, MP_RAILWAY) && IsPlainRailTile(n) ? GetTrackBits(n) : TRACK_BIT_NONE);
|
||||
TrackBits nrail = (IsPlainRailTile(n) ? GetTrackBits(n) : TRACK_BIT_NONE);
|
||||
|
||||
if (!IsTileType(n, MP_RAILWAY) ||
|
||||
!IsTileOwner(n, owner) ||
|
||||
@ -2226,7 +2226,7 @@ static void TileLoop_Track(TileIndex tile)
|
||||
(rail & TRACK_BIT_Y)
|
||||
)) {
|
||||
TileIndex n = tile + TileDiffXY(1, 0);
|
||||
TrackBits nrail = (IsTileType(n, MP_RAILWAY) && IsPlainRailTile(n) ? GetTrackBits(n) : TRACK_BIT_NONE);
|
||||
TrackBits nrail = (IsPlainRailTile(n) ? GetTrackBits(n) : TRACK_BIT_NONE);
|
||||
|
||||
if (!IsTileType(n, MP_RAILWAY) ||
|
||||
!IsTileOwner(n, owner) ||
|
||||
@ -2252,7 +2252,7 @@ set_ground:
|
||||
static TrackStatus GetTileTrackStatus_Track(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
|
||||
{
|
||||
/* Case of half tile slope with water. */
|
||||
if (mode == TRANSPORT_WATER && IsPlainRailTile(tile) && GetRailGroundType(tile) == RAIL_GROUND_WATER) {
|
||||
if (mode == TRANSPORT_WATER && IsPlainRail(tile) && GetRailGroundType(tile) == RAIL_GROUND_WATER) {
|
||||
TrackBits tb = GetTrackBits(tile);
|
||||
switch (tb) {
|
||||
default: NOT_REACHED();
|
||||
@ -2555,7 +2555,7 @@ static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlag flags, uint
|
||||
{
|
||||
uint z_old;
|
||||
Slope tileh_old = GetTileSlope(tile, &z_old);
|
||||
if (IsPlainRailTile(tile)) {
|
||||
if (IsPlainRail(tile)) {
|
||||
TrackBits rail_bits = GetTrackBits(tile);
|
||||
/* Is there flat water on the lower halftile, that must be cleared expensively? */
|
||||
bool was_water = (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh_old));
|
||||
|
@ -42,12 +42,23 @@ static inline RailTileType GetRailTileType(TileIndex t)
|
||||
* @pre IsTileType(t, MP_RAILWAY)
|
||||
* @return true if and only if the tile is normal rail (with or without signals)
|
||||
*/
|
||||
static inline bool IsPlainRailTile(TileIndex t)
|
||||
static inline bool IsPlainRail(TileIndex t)
|
||||
{
|
||||
RailTileType rtt = GetRailTileType(t);
|
||||
return rtt == RAIL_TILE_NORMAL || rtt == RAIL_TILE_SIGNALS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the tile is a rail tile or rail tile with signals.
|
||||
* @param t the tile to get the information from
|
||||
* @return true if and only if the tile is normal rail (with or without signals)
|
||||
*/
|
||||
static inline bool IsPlainRailTile(TileIndex t)
|
||||
{
|
||||
return IsTileType(t, MP_RAILWAY) && IsPlainRail(t);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a rail tile has signals.
|
||||
* @param t the tile to get the information from
|
||||
|
@ -683,7 +683,7 @@ bool AfterLoadGame()
|
||||
for (TileIndex t = 0; t < map_size; t++) {
|
||||
switch (GetTileType(t)) {
|
||||
case MP_RAILWAY:
|
||||
if (IsPlainRailTile(t)) {
|
||||
if (IsPlainRail(t)) {
|
||||
/* Swap ground type and signal type for plain rail tiles, so the
|
||||
* ground type uses the same bits as for depots and waypoints. */
|
||||
uint tmp = GB(_m[t].m4, 0, 4);
|
||||
@ -1548,7 +1548,7 @@ bool AfterLoadGame()
|
||||
if (IsLevelCrossing(t)) {
|
||||
if (!Company::IsValidID(GetTileOwner(t))) FixOwnerOfRailTrack(t);
|
||||
}
|
||||
} else if (IsTileType(t, MP_RAILWAY) && IsPlainRailTile(t)) {
|
||||
} else if (IsPlainRailTile(t)) {
|
||||
if (!Company::IsValidID(GetTileOwner(t))) FixOwnerOfRailTrack(t);
|
||||
}
|
||||
}
|
||||
|
@ -2753,7 +2753,7 @@ static PBSTileInfo ExtendTrainReservation(const Vehicle *v, TrackBits *new_track
|
||||
}
|
||||
|
||||
/* Station, depot or waypoint are a possible target. */
|
||||
bool target_seen = ft.m_is_station || (IsTileType(ft.m_new_tile, MP_RAILWAY) && !IsPlainRailTile(ft.m_new_tile));
|
||||
bool target_seen = ft.m_is_station || (IsTileType(ft.m_new_tile, MP_RAILWAY) && !IsPlainRail(ft.m_new_tile));
|
||||
if (target_seen || KillFirstBit(ft.m_new_td_bits) != TRACKDIR_BIT_NONE) {
|
||||
/* Choice found or possible target encountered.
|
||||
* On finding a possible target, we need to stop and let the pathfinder handle the
|
||||
|
@ -394,7 +394,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
||||
break;
|
||||
|
||||
case MP_RAILWAY:
|
||||
if (!IsPlainRailTile(tile)) goto not_valid_below;
|
||||
if (!IsPlainRail(tile)) goto not_valid_below;
|
||||
break;
|
||||
|
||||
case MP_ROAD:
|
||||
|
@ -434,7 +434,7 @@ static bool IsWateredTile(TileIndex tile, Direction from)
|
||||
|
||||
case MP_RAILWAY:
|
||||
if (GetRailGroundType(tile) == RAIL_GROUND_WATER) {
|
||||
assert(IsPlainRailTile(tile));
|
||||
assert(IsPlainRail(tile));
|
||||
switch (GetTileSlope(tile, NULL)) {
|
||||
case SLOPE_W: return (from == DIR_SE) || (from == DIR_E) || (from == DIR_NE);
|
||||
case SLOPE_S: return (from == DIR_NE) || (from == DIR_N) || (from == DIR_NW);
|
||||
@ -910,7 +910,7 @@ void DoFloodTile(TileIndex target)
|
||||
/* make coast.. */
|
||||
switch (GetTileType(target)) {
|
||||
case MP_RAILWAY: {
|
||||
if (!IsPlainRailTile(target)) break;
|
||||
if (!IsPlainRail(target)) break;
|
||||
FloodVehicles(target);
|
||||
flooded = FloodHalftile(target);
|
||||
break;
|
||||
@ -967,7 +967,7 @@ static void DoDryUp(TileIndex tile)
|
||||
|
||||
switch (GetTileType(tile)) {
|
||||
case MP_RAILWAY:
|
||||
assert(IsPlainRailTile(tile));
|
||||
assert(IsPlainRail(tile));
|
||||
assert(GetRailGroundType(tile) == RAIL_GROUND_WATER);
|
||||
|
||||
RailGroundType new_ground;
|
||||
|
@ -202,7 +202,7 @@ protected:
|
||||
FORCEINLINE bool QueryNewTileTrackStatus()
|
||||
{
|
||||
CPerfStart perf(*m_pPerf);
|
||||
if (IsRailTT() && GetTileType(m_new_tile) == MP_RAILWAY && IsPlainRailTile(m_new_tile)) {
|
||||
if (IsRailTT() && IsPlainRailTile(m_new_tile)) {
|
||||
m_new_td_bits = (TrackdirBits)(GetTrackBits(m_new_tile) * 0x101);
|
||||
} else {
|
||||
m_new_td_bits = TrackStatusToTrackdirBits(GetTileTrackStatus(m_new_tile, TT(), m_veh != NULL ? m_veh->u.road.compatible_roadtypes : 0));
|
||||
|
@ -115,7 +115,7 @@ public:
|
||||
|
||||
FORCEINLINE int SwitchCost(TileIndex tile1, TileIndex tile2, DiagDirection exitdir)
|
||||
{
|
||||
if (IsTileType(tile1, MP_RAILWAY) && IsTileType(tile2, MP_RAILWAY) && IsPlainRailTile(tile1) && IsPlainRailTile(tile2)) {
|
||||
if (IsPlainRailTile(tile1) && IsPlainRailTile(tile2)) {
|
||||
bool t1 = KillFirstBit(GetTrackBits(tile1) & DiagdirReachesTracks(ReverseDiagDir(exitdir))) != TRACK_BIT_NONE;
|
||||
bool t2 = KillFirstBit(GetTrackBits(tile2) & DiagdirReachesTracks(exitdir)) != TRACK_BIT_NONE;
|
||||
if (t1 && t2) return Yapf().PfGetSettings().rail_doubleslip_penalty;
|
||||
|
Loading…
Reference in New Issue
Block a user