diff options
author | terkhen <terkhen@openttd.org> | 2010-12-14 21:31:00 +0000 |
---|---|---|
committer | terkhen <terkhen@openttd.org> | 2010-12-14 21:31:00 +0000 |
commit | a4a92741778047893eb05dd9e98d0f153d41e2eb (patch) | |
tree | 6ce748e8d315f39770cceb6200ea13f2d9463005 /src/vehicle.cpp | |
parent | 12c86a139193ab88edb998844c2685b569430a57 (diff) | |
download | openttd-a4a92741778047893eb05dd9e98d0f153d41e2eb.tar.xz |
(svn r21519) -Codechange: Allow direct access to the GroundVehicleCache from a Vehicle.
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r-- | src/vehicle.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index e9630566e..d3b47c7e3 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -52,6 +52,7 @@ #include "vehiclelist.h" #include "tunnel_map.h" #include "depot_map.h" +#include "ground_vehicle.hpp" #include "table/strings.h" @@ -2228,3 +2229,33 @@ bool CanVehicleUseStation(const Vehicle *v, const Station *st) return CanVehicleUseStation(v->engine_type, st); } + +/** + * Access the ground vehicle cache of the vehicle. + * @pre The vehicle is a #GroundVehicle. + * @return #GroundVehicleCache of the vehicle. + */ +GroundVehicleCache *Vehicle::GetGroundVehicleCache() +{ + assert(this->IsGroundVehicle()); + if (this->type == VEH_TRAIN) { + return &Train::From(this)->gcache; + } else { + return &RoadVehicle::From(this)->gcache; + } +} + +/** + * Access the ground vehicle cache of the vehicle. + * @pre The vehicle is a #GroundVehicle. + * @return #GroundVehicleCache of the vehicle. + */ +const GroundVehicleCache *Vehicle::GetGroundVehicleCache() const +{ + assert(this->IsGroundVehicle()); + if (this->type == VEH_TRAIN) { + return &Train::From(this)->gcache; + } else { + return &RoadVehicle::From(this)->gcache; + } +} |