(svn r21519) -Codechange: Allow direct access to the GroundVehicleCache from a Vehicle.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user