MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / TrainCanLeaveTile

Function TrainCanLeaveTile

src/train_cmd.cpp:3839–3859  ·  view source on GitHub ↗

* Determines whether train would like to leave the tile * @param v train to test * @return true iff vehicle is NOT entering or inside a depot or tunnel/bridge */

Source from the content-addressed store, hash-verified

3837 * @return true iff vehicle is NOT entering or inside a depot or tunnel/bridge
3838 */
3839static bool TrainCanLeaveTile(const Train *v)
3840{
3841 /* Exit if inside a tunnel/bridge or a depot */
3842 if (v->track == TRACK_BIT_WORMHOLE || v->track == TRACK_BIT_DEPOT) return false;
3843
3844 TileIndex tile = v->tile;
3845
3846 /* entering a tunnel/bridge? */
3847 if (IsTileType(tile, MP_TUNNELBRIDGE)) {
3848 DiagDirection dir = GetTunnelBridgeDirection(tile);
3849 if (DiagDirToDir(dir) == v->direction) return false;
3850 }
3851
3852 /* entering a depot? */
3853 if (IsRailDepotTile(tile)) {
3854 DiagDirection dir = ReverseDiagDir(GetRailDepotDirection(tile));
3855 if (DiagDirToDir(dir) == v->direction) return false;
3856 }
3857
3858 return true;
3859}
3860
3861
3862/**

Callers 2

TrainCheckIfLineEndsFunction · 0.85

Calls 6

IsTileTypeFunction · 0.85
GetTunnelBridgeDirectionFunction · 0.85
DiagDirToDirFunction · 0.85
IsRailDepotTileFunction · 0.85
ReverseDiagDirFunction · 0.85
GetRailDepotDirectionFunction · 0.85

Tested by

no test coverage detected