summaryrefslogtreecommitdiff
path: root/src/vehicle.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-05-22 18:17:20 +0000
committerrubidium <rubidium@openttd.org>2009-05-22 18:17:20 +0000
commit441011b782294e93b47876f24de96a63da7dd678 (patch)
tree7592579bbde1a91f353a6d685a8a64128f6a6955 /src/vehicle.cpp
parentcf0cfb908f02ca54efd5956f11909514de062015 (diff)
downloadopenttd-441011b782294e93b47876f24de96a63da7dd678.tar.xz
(svn r16382) -Codechange: make GetVehicleTrackdir a member function of Vehicle.
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r--src/vehicle.cpp47
1 files changed, 2 insertions, 45 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 961e9ee4b..90a9406d5 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -992,7 +992,7 @@ void VehicleEnterDepot(Vehicle *v)
case VEH_SHIP:
InvalidateWindowClasses(WC_SHIPS_LIST);
- v->u.ship.state = TRACK_BIT_DEPOT;
+ static_cast<Ship*>(v)->state = TRACK_BIT_DEPOT;
RecalcShipStuff(v);
break;
@@ -1173,49 +1173,6 @@ Direction GetDirectionTowards(const Vehicle *v, int x, int y)
return ChangeDir(dir, dirdiff > DIRDIFF_REVERSE ? DIRDIFF_45LEFT : DIRDIFF_45RIGHT);
}
-Trackdir GetVehicleTrackdir(const Vehicle *v)
-{
- if (v->vehstatus & VS_CRASHED) return INVALID_TRACKDIR;
-
- switch (v->type) {
- case VEH_TRAIN:
- if (v->u.rail.track == TRACK_BIT_DEPOT) // We'll assume the train is facing outwards
- return DiagDirToDiagTrackdir(GetRailDepotDirection(v->tile)); // Train in depot
-
- if (v->u.rail.track == TRACK_BIT_WORMHOLE) // train in tunnel or on bridge, so just use his direction and assume a diagonal track
- return DiagDirToDiagTrackdir(DirToDiagDir(v->direction));
-
- return TrackDirectionToTrackdir(FindFirstTrack(v->u.rail.track), v->direction);
-
- case VEH_SHIP:
- if (v->IsInDepot())
- /* We'll assume the ship is facing outwards */
- return DiagDirToDiagTrackdir(GetShipDepotDirection(v->tile));
-
- if (v->u.ship.state == TRACK_BIT_WORMHOLE) // ship on aqueduct, so just use his direction and assume a diagonal track
- return DiagDirToDiagTrackdir(DirToDiagDir(v->direction));
-
- return TrackDirectionToTrackdir(FindFirstTrack(v->u.ship.state), v->direction);
-
- case VEH_ROAD:
- if (v->IsInDepot()) // We'll assume the road vehicle is facing outwards
- return DiagDirToDiagTrackdir(GetRoadDepotDirection(v->tile));
-
- if (IsStandardRoadStopTile(v->tile)) // We'll assume the road vehicle is facing outwards
- return DiagDirToDiagTrackdir(GetRoadStopDir(v->tile)); // Road vehicle in a station
-
- /* Drive through road stops / wormholes (tunnels) */
- if (v->u.road.state > RVSB_TRACKDIR_MASK) return DiagDirToDiagTrackdir(DirToDiagDir(v->direction));
-
- /* If vehicle's state is a valid track direction (vehicle is not turning around) return it,
- * otherwise transform it into a valid track direction */
- return (Trackdir)((IsReversingRoadTrackdir((Trackdir)v->u.road.state)) ? (v->u.road.state - 6) : v->u.road.state);
-
- /* case VEH_AIRCRAFT: case VEH_EFFECT: case VEH_DISASTER: */
- default: return INVALID_TRACKDIR;
- }
-}
-
/**
* Call the tile callback function for a vehicle entering a tile
* @param v Vehicle entering the tile
@@ -1529,7 +1486,7 @@ void Vehicle::LeaveStation()
/* Try to reserve a path when leaving the station as we
* might not be marked as wanting a reservation, e.g.
* when an overlength train gets turned around in a station. */
- if (UpdateSignalsOnSegment(this->tile, TrackdirToExitdir(GetVehicleTrackdir(this)), this->owner) == SIGSEG_PBS || _settings_game.pf.reserve_paths) {
+ if (UpdateSignalsOnSegment(this->tile, TrackdirToExitdir(this->GetVehicleTrackdir()), this->owner) == SIGSEG_PBS || _settings_game.pf.reserve_paths) {
TryPathReserve(this, true, true);
}
}