1
0
Fork 0

Add: Add IsStandard and IsExtendedRailDepotTile map functions.

pull/8480/head
Juanjo 2014-09-23 18:22:18 +02:00 committed by J0anJosep
parent 2654cfeae7
commit 8488abaf2f
6 changed files with 63 additions and 13 deletions

View File

@ -311,7 +311,7 @@ protected:
return false;
}
}
if (IsRailTT() && IsDepotTypeTile(m_new_tile, TT())) {
if (IsRailTT() && IsStandardRailDepotTile(m_new_tile)) {
DiagDirection exitdir = GetRailDepotDirection(m_new_tile);
if (ReverseDiagDir(exitdir) != m_exitdir) {
m_err = EC_NO_WAY;

View File

@ -389,13 +389,12 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
/* Tests for 'potential target' reasons to close the segment. */
if (cur.tile == prev.tile) {
/* Penalty for reversing in a depot. */
assert(IsRailDepot(cur.tile));
assert(IsStandardRailDepot(cur.tile));
segment_cost += Yapf().PfGetSettings().rail_depot_reverse_penalty;
} else if (IsRailDepotTile(cur.tile)) {
} else if (IsStandardRailDepotTile(cur.tile)) {
/* We will end in this pass (depot is possible target) */
end_segment_reason |= ESRB_DEPOT;
} else if (cur.tile_type == MP_STATION && IsRailWaypoint(cur.tile)) {
if (v->current_order.IsType(OT_GOTO_WAYPOINT) &&
GetStationIndex(cur.tile) == v->current_order.GetDestination() &&

View File

@ -240,7 +240,7 @@ static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Tra
if (tile == start_tile && trackdir == start_trackdir) break;
}
/* Depot tile? Can't continue. */
if (IsRailDepotTile(tile)) break;
if (IsStandardRailDepotTile(tile)) break;
/* Non-pbs signal? Reservation can't continue. */
if (IsTileType(tile, MP_RAILWAY) && HasSignalOnTrackdir(tile, trackdir) && !IsPbsSignal(GetSignalType(tile, TrackdirToTrack(trackdir)))) break;
}
@ -292,7 +292,7 @@ PBSTileInfo FollowTrainReservation(const Train *v, Vehicle **train_on_res)
TileIndex tile = v->tile;
Trackdir trackdir = v->GetVehicleTrackdir();
if (IsRailDepotTile(tile) && !GetDepotReservationTrackBits(tile)) return PBSTileInfo(tile, trackdir, false);
if (IsStandardRailDepotTile(tile) && !GetDepotReservationTrackBits(tile)) return PBSTileInfo(tile, trackdir, false);
FindTrainOnTrackInfo ftoti;
ftoti.res = FollowReservation(v->owner, GetRailTypeInfo(v->railtype)->compatible_railtypes, tile, trackdir);
@ -379,7 +379,7 @@ Train *GetTrainForReservation(TileIndex tile, Track track)
*/
bool IsSafeWaitingPosition(const Train *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg)
{
if (IsRailDepotTile(tile)) return true;
if (IsStandardRailDepotTile(tile)) return true;
if (IsTileType(tile, MP_RAILWAY)) {
/* For non-pbs signals, stop on the signal tile. */
@ -432,7 +432,7 @@ bool IsWaitingPositionFree(const Train *v, TileIndex tile, Trackdir trackdir, bo
if (TrackOverlapsTracks(reserved, track)) return false;
/* Not reserved and depot or not a pbs signal -> free. */
if (IsRailDepotTile(tile)) return true;
if (IsStandardRailDepotTile(tile)) return true;
if (IsTileType(tile, MP_RAILWAY) && HasSignalOnTrackdir(tile, trackdir) && !IsPbsSignal(GetSignalType(tile, track))) return true;
/* Check the next tile, if it's a PBS signal, it has to be free as well. */

View File

@ -2960,6 +2960,7 @@ static const int8_t _deltacoord_leaveoffset[8] = {
*/
int TicksToLeaveDepot(const Train *v)
{
assert(IsStandardRailDepotTile(v->tile));
DiagDirection dir = GetRailDepotDirection(v->tile);
int length = v->CalcNextVehicleOffset();

View File

@ -107,6 +107,50 @@ debug_inline static bool IsRailDepotTile(Tile t)
return IsTileType(t, MP_RAILWAY) && IsRailDepot(t);
}
/**
* Is this rail depot tile an extended depot?
* @param t the tile to get the information from
* @pre IsRailDepotTile(t)
* @return true if and only if the tile is an extended rail depot
*/
static inline bool IsExtendedRailDepot(Tile t)
{
assert(IsRailDepotTile(t));
return HasBit(t.m5(), 5);
}
/**
* Is this rail tile a standard rail depot?
* @param t the tile to get the information from
* @pre IsTileType(t, MP_RAILWAY)
* @return true if and only if the tile is a standard rail depot
*/
static inline bool IsStandardRailDepot(Tile t)
{
assert(IsTileType(t, MP_RAILWAY));
return IsRailDepot(t) && !IsExtendedRailDepot(t);
}
/**
* Is this tile a standard rail depot?
* @param t the tile to get the information from
* @return true if and only if the tile is a standard rail depot
*/
static inline bool IsStandardRailDepotTile(TileIndex t)
{
return IsTileType(t, MP_RAILWAY) && IsStandardRailDepot(t);
}
/**
* Is this tile rail tile and an extended rail depot?
* @param t the tile to get the information from
* @return true if and only if the tile is an extended rail depot
*/
static inline bool IsExtendedRailDepotTile(TileIndex t)
{
return IsTileType(t, MP_RAILWAY) && IsRailDepotTile(t) && IsExtendedRailDepot(t);
}
/**
* Gets the rail type of the given tile
* @param t the tile to get the rail type from

View File

@ -2181,7 +2181,7 @@ void ReverseTrainDirection(Train *v)
!IsPbsSignal(GetSignalType(v->tile, FindFirstTrack(v->track))));
/* If we are on a depot tile facing outwards, do not treat the current tile as safe. */
if (IsRailDepotTile(v->tile) && TrackdirToExitdir(v->GetVehicleTrackdir()) == GetRailDepotDirection(v->tile)) first_tile_okay = false;
if (IsStandardRailDepotTile(v->tile) && TrackdirToExitdir(v->GetVehicleTrackdir()) == GetRailDepotDirection(v->tile)) first_tile_okay = false;
if (IsRailStationTile(v->tile)) SetRailStationPlatformReservation(v->tile, TrackdirToExitdir(v->GetVehicleTrackdir()), true);
if (TryPathReserve(v, false, first_tile_okay)) {
@ -2549,7 +2549,7 @@ void FreeTrainTrackReservation(const Train *v)
StationID station_id = IsRailStationTile(v->tile) ? GetStationIndex(v->tile) : INVALID_STATION;
/* Can't be holding a reservation if we enter a depot. */
if (IsRailDepotTile(tile) && TrackdirToExitdir(td) != GetRailDepotDirection(tile)) return;
if (IsStandardRailDepotTile(tile) && TrackdirToExitdir(td) != GetRailDepotDirection(tile)) return;
if (v->track == TRACK_BIT_DEPOT) {
/* Front engine is in a depot. We enter if some part is not in the depot. */
for (const Train *u = v; u != nullptr; u = u->Next()) {
@ -3005,6 +3005,7 @@ bool TryPathReserve(Train *v, bool mark_as_stuck, bool first_tile_okay)
if (mark_as_stuck) MarkTrainAsStuck(v);
return false;
} else {
assert(IsStandardRailDepotTile(v->tile));
/* Depot not reserved, but the next tile might be. */
TileIndex next_tile = TileAddByDiagDir(v->tile, GetRailDepotDirection(v->tile));
if (HasReservedTracks(next_tile, DiagdirReachesTracks(GetRailDepotDirection(v->tile)))) return false;
@ -3823,7 +3824,7 @@ static void DeleteLastWagon(Train *v)
}
/* Update signals */
if (IsTileType(tile, MP_TUNNELBRIDGE) || IsRailDepotTile(tile)) {
if (IsTileType(tile, MP_TUNNELBRIDGE) || IsStandardRailDepotTile(tile)) {
UpdateSignalsOnSegment(tile, INVALID_DIAGDIR, owner);
} else {
SetSignalsOnBothDir(tile, track, owner);
@ -3974,8 +3975,13 @@ static bool TrainCanLeaveTile(const Train *v)
/* entering a depot? */
if (IsRailDepotTile(tile)) {
DiagDirection dir = ReverseDiagDir(GetRailDepotDirection(tile));
if (DiagDirToDir(dir) == v->direction) return false;
if (IsExtendedRailDepot(tile)) {
Direction dir = DiagDirToDir(GetRailDepotDirection(tile));
if (dir == v->direction || ReverseDir(dir) == v->direction) return false;
} else {
DiagDirection dir = ReverseDiagDir(GetRailDepotDirection(tile));
if (DiagDirToDir(dir) == v->direction) return false;
}
}
return true;