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

Method GetVehicleTrackdir

src/roadveh_cmd.cpp:1753–1773  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1751}
1752
1753Trackdir RoadVehicle::GetVehicleTrackdir() const
1754{
1755 if (this->vehstatus.Test(VehState::Crashed)) return INVALID_TRACKDIR;
1756
1757 if (this->IsInDepot()) {
1758 /* We'll assume the road vehicle is facing outwards */
1759 return DiagDirToDiagTrackdir(GetRoadDepotDirection(this->tile));
1760 }
1761
1762 if (IsBayRoadStopTile(this->tile)) {
1763 /* We'll assume the road vehicle is facing outwards */
1764 return DiagDirToDiagTrackdir(GetBayRoadStopDir(this->tile)); // Road vehicle in a station
1765 }
1766
1767 /* Drive through road stops / wormholes (tunnels) */
1768 if (this->state > RVSB_TRACKDIR_MASK) return DiagDirToDiagTrackdir(DirToDiagDir(this->direction));
1769
1770 /* If vehicle's state is a valid track direction (vehicle is not turning around) return it,
1771 * otherwise transform it into a valid track direction */
1772 return (Trackdir)((IsReversingRoadTrackdir((Trackdir)this->state)) ? (this->state - 6) : this->state);
1773}
1774
1775uint16_t RoadVehicle::GetMaxWeight() const
1776{

Callers

nothing calls this directly

Calls 8

IsInDepotMethod · 0.95
DiagDirToDiagTrackdirFunction · 0.85
GetRoadDepotDirectionFunction · 0.85
IsBayRoadStopTileFunction · 0.85
GetBayRoadStopDirFunction · 0.85
DirToDiagDirFunction · 0.85
IsReversingRoadTrackdirFunction · 0.85
TestMethod · 0.80

Tested by

no test coverage detected