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

Method GetVehicleTrackdir

src/train_cmd.cpp:4226–4241  ·  view source on GitHub ↗

* Get the tracks of the train vehicle. * @return Current tracks of the vehicle. */

Source from the content-addressed store, hash-verified

4224 * @return Current tracks of the vehicle.
4225 */
4226Trackdir Train::GetVehicleTrackdir() const
4227{
4228 if (this->vehstatus.Test(VehState::Crashed)) return INVALID_TRACKDIR;
4229
4230 if (this->track == TRACK_BIT_DEPOT) {
4231 /* We'll assume the train is facing outwards */
4232 return DiagDirToDiagTrackdir(GetRailDepotDirection(this->tile)); // Train in depot
4233 }
4234
4235 if (this->track == TRACK_BIT_WORMHOLE) {
4236 /* train in tunnel or on bridge, so just use its direction and assume a diagonal track */
4237 return DiagDirToDiagTrackdir(DirToDiagDir(this->direction));
4238 }
4239
4240 return TrackDirectionToTrackdir(FindFirstTrack(this->track), this->direction);
4241}
4242
4243uint16_t Train::GetMaxWeight() const
4244{

Callers 7

ReverseTrainDirectionFunction · 0.45
CheckNextTrainTileFunction · 0.45
ChooseTrainTrackFunction · 0.45
CrashMethod · 0.45
TrainControllerFunction · 0.45

Calls 6

DiagDirToDiagTrackdirFunction · 0.85
GetRailDepotDirectionFunction · 0.85
DirToDiagDirFunction · 0.85
TrackDirectionToTrackdirFunction · 0.85
FindFirstTrackFunction · 0.85
TestMethod · 0.80

Tested by

no test coverage detected