mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 14:27:16 +00:00
(svn r4758) - Newstations: add support for 'blocked' station tiles, which no train can pass.
This commit is contained in:
parent
10992deeb3
commit
6e2b98b060
@ -640,3 +640,22 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Check if a rail station tile is traversable.
|
||||
* XXX This could be cached (during build) in the map array to save on all the dereferencing */
|
||||
bool IsStationTileBlocked(TileIndex tile)
|
||||
{
|
||||
const Station *st;
|
||||
const StationSpec *statspec;
|
||||
uint specindex;
|
||||
|
||||
if (!IsCustomStationSpecIndex(tile)) return false;
|
||||
|
||||
st = GetStationByTile(tile);
|
||||
specindex = GetCustomStationSpecIndex(tile);
|
||||
if (specindex >= st->num_specs) return false;
|
||||
|
||||
statspec = st->speclist[specindex].spec;
|
||||
if (statspec == NULL) return false;
|
||||
|
||||
return HASBIT(statspec->blocked, GetStationGfx(tile));
|
||||
}
|
||||
|
@ -102,6 +102,9 @@ const StationSpec *GetCustomStationSpecByGrf(uint32 grfid, byte localidx);
|
||||
SpriteID GetCustomStationRelocation(const StationSpec *statspec, const Station *st, TileIndex tile);
|
||||
uint16 GetStationCallback(uint16 callback, uint32 param1, uint32 param2, const StationSpec *statspec, const Station *st, TileIndex tile);
|
||||
|
||||
/* Check if a rail station tile is traversable. */
|
||||
bool IsStationTileBlocked(TileIndex tile);
|
||||
|
||||
/* Allocate a StationSpec to a Station. This is called once per build operation. */
|
||||
int AllocateSpecToStation(const StationSpec *statspec, Station *st, bool exec);
|
||||
|
||||
|
@ -2124,6 +2124,8 @@ static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode)
|
||||
switch (mode) {
|
||||
case TRANSPORT_RAIL:
|
||||
if (IsRailwayStation(tile)) {
|
||||
if (IsStationTileBlocked(tile)) return 0;
|
||||
|
||||
return TrackToTrackBits(GetRailStationTrack(tile)) * 0x101;
|
||||
}
|
||||
break;
|
||||
|
@ -187,7 +187,8 @@ static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
|
||||
return
|
||||
IsRailwayStationTile(t1) &&
|
||||
IsCompatibleRail(GetRailType(t1), GetRailType(t2)) &&
|
||||
GetRailStationAxis(t1) == GetRailStationAxis(t2);
|
||||
GetRailStationAxis(t1) == GetRailStationAxis(t2) &&
|
||||
!IsStationTileBlocked(t1);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user