diff options
author | smatz <smatz@openttd.org> | 2009-05-18 01:26:23 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2009-05-18 01:26:23 +0000 |
commit | 0af27062c4d17148f357c0da1f8b9ce996601463 (patch) | |
tree | 1d4e22ed82a0995464f2789b1fd4c47ea8609e21 /src | |
parent | d1f9a90d3217709903530e58a641c18d61c96918 (diff) | |
download | openttd-0af27062c4d17148f357c0da1f8b9ce996601463.tar.xz |
(svn r16349) -Codechange: rename IsPlainRailTile() to IsPlainRail(), introduce shiny new IsPlainRailTile()
Diffstat (limited to 'src')
-rw-r--r-- | src/ai/api/ai_rail.cpp | 4 | ||||
-rw-r--r-- | src/disaster_cmd.cpp | 3 | ||||
-rw-r--r-- | src/elrail.cpp | 2 | ||||
-rw-r--r-- | src/pathfind.cpp | 2 | ||||
-rw-r--r-- | src/pbs.cpp | 6 | ||||
-rw-r--r-- | src/rail_cmd.cpp | 44 | ||||
-rw-r--r-- | src/rail_map.h | 13 | ||||
-rw-r--r-- | src/saveload/afterload.cpp | 4 | ||||
-rw-r--r-- | src/train_cmd.cpp | 2 | ||||
-rw-r--r-- | src/tunnelbridge_cmd.cpp | 2 | ||||
-rw-r--r-- | src/water_cmd.cpp | 6 | ||||
-rw-r--r-- | src/yapf/follow_track.hpp | 2 | ||||
-rw-r--r-- | src/yapf/yapf_costrail.hpp | 2 |
13 files changed, 51 insertions, 41 deletions
diff --git a/src/ai/api/ai_rail.cpp b/src/ai/api/ai_rail.cpp index b067b0904..6914f99c1 100644 --- a/src/ai/api/ai_rail.cpp +++ b/src/ai/api/ai_rail.cpp @@ -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; diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp index bf3ad6b3b..d83f55fe3 100644 --- a/src/disaster_cmd.cpp +++ b/src/disaster_cmd.cpp @@ -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; } diff --git a/src/elrail.cpp b/src/elrail.cpp index 69c9dc6e3..432ae60ba 100644 --- a/src/elrail.cpp +++ b/src/elrail.cpp @@ -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++) { diff --git a/src/pathfind.cpp b/src/pathfind.cpp index d5f48cde7..921c9c684 100644 --- a/src/pathfind.cpp +++ b/src/pathfind.cpp @@ -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)); diff --git a/src/pbs.cpp b/src/pbs.cpp index 5adccaea6..a738da913 100644 --- a/src/pbs.cpp +++ b/src/pbs.cpp @@ -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: diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 5c3345b49..428779a32 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -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)); diff --git a/src/rail_map.h b/src/rail_map.h index 195aef9f5..bfdc19f6d 100644 --- a/src/rail_map.h +++ b/src/rail_map.h @@ -42,13 +42,24 @@ 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 * @pre IsTileType(t, MP_RAILWAY) diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index b1829d5f6..fbb1bdef4 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -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); } } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 061f78d34..8c83c1bb8 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -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 diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 7f2c7bd5e..ac3ff0005 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -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: diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 4bc5a26de..b4a67024a 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -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; diff --git a/src/yapf/follow_track.hpp b/src/yapf/follow_track.hpp index 8953cddfc..531e548a6 100644 --- a/src/yapf/follow_track.hpp +++ b/src/yapf/follow_track.hpp @@ -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)); diff --git a/src/yapf/yapf_costrail.hpp b/src/yapf/yapf_costrail.hpp index b4792db87..6eefc08c0 100644 --- a/src/yapf/yapf_costrail.hpp +++ b/src/yapf/yapf_costrail.hpp @@ -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; |