forked from mirror/OpenTTD
(svn r2473) - Add: VehicleMayEnterTile(), which checks if the tile owner of a tile is correct for a vehicle to enter it. Based upon glx's code.
- Fix: [ 1203769 ] [NPF] NPF tries to plan over bridges, through tunnels, over level crossings of other players. (glx) - Codechange: Renamed TRANSPORT_MAX to TRANSPORT_END and added INVALID_TRANSPORT. - Codechange: Moved IsLevelCrossing() from tile.h to rail.h - Add: GetCrossingTransportType(), which returns the transport type (road, rail) of both tracks on a level crossing. - Removed old TODO that was fulfilled already.
This commit is contained in:
29
rail.h
29
rail.h
@@ -443,4 +443,33 @@ static inline bool HasSemaphores(TileIndex tile, Track track)
|
||||
*/
|
||||
RailType GetTileRailType(TileIndex tile, byte trackdir);
|
||||
|
||||
/**
|
||||
* Returns whether the given tile is a level crossing.
|
||||
*/
|
||||
static inline bool IsLevelCrossing(TileIndex tile)
|
||||
{
|
||||
return (_map5[tile] & 0xF0) == 0x10;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the transport type of the given track on the given crossing tile.
|
||||
* @return The transport type of the given track, either TRANSPORT_ROAD,
|
||||
* TRANSPORT_RAIL.
|
||||
*/
|
||||
static inline TransportType GetCrossingTransportType(TileIndex tile, Track track)
|
||||
{
|
||||
/* XXX: Nicer way to write this? */
|
||||
switch(track)
|
||||
{
|
||||
/* When map5 bit 3 is set, the road runs in the y direction (DIAG2) */
|
||||
case TRACK_DIAG1:
|
||||
return (HASBIT(_map5[tile], 3) ? TRANSPORT_RAIL : TRANSPORT_ROAD);
|
||||
case TRACK_DIAG2:
|
||||
return (HASBIT(_map5[tile], 3) ? TRANSPORT_ROAD : TRANSPORT_RAIL);
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
return INVALID_TRANSPORT;
|
||||
}
|
||||
|
||||
#endif // RAIL_H
|
||||
|
Reference in New Issue
Block a user