Base class for all vehicles that move through ground. More...
#include <ground_vehicle.hpp>
Public Member Functions | |
GroundVehicle () | |
The constructor at SpecializedVehicle must be called. | |
void | PowerChanged () |
Recalculates the cached total power of a vehicle. | |
void | CargoChanged () |
Recalculates the cached weight of a vehicle and its parts. | |
int | GetAcceleration () const |
Calculates the acceleration of the vehicle under its current conditions. | |
FORCEINLINE int32 | GetSlopeResistance () const |
Calculates the total slope resistance for this vehicle. | |
FORCEINLINE byte | UpdateInclination (bool new_tile, bool turned) |
Checks if the vehicle is in a slope and sets the required flags in that case. | |
Data Fields | |
GroundVehicleCache | gcache |
Cache of often calculated values. | |
uint16 | gv_flags |
Base class for all vehicles that move through ground.
Child classes must define all of the following functions. These functions are not defined as pure virtual functions at this class to improve performance.
virtual uint16 GetPower() const = 0; virtual uint16 GetPoweredPartPower(const T *head) const = 0; virtual uint16 GetWeight() const = 0; virtual byte GetTractiveEffort() const = 0; virtual byte GetAirDrag() const = 0; virtual byte GetAirDragArea() const = 0; virtual AccelStatus GetAccelerationStatus() const = 0; virtual uint16 GetCurrentSpeed() const = 0; virtual uint32 GetRollingFriction() const = 0; virtual int GetAccelerationType() const = 0; virtual int32 GetSlopeSteepness() const = 0; virtual int GetDisplayMaxSpeed() const = 0; virtual uint16 GetMaxTrackSpeed() const = 0; virtual bool TileMayHaveSlopedTrack() const = 0;
Definition at line 74 of file ground_vehicle.hpp.
void GroundVehicle< T, Type >::CargoChanged | ( | ) | [inline] |
Recalculates the cached weight of a vehicle and its parts.
Should be called each time the cargo on the consist changes.
Definition at line 80 of file ground_vehicle.cpp.
References GroundVehicleCache::cached_axle_resistance, GroundVehicleCache::cached_weight, SpecializedVehicle< T, Type >::First(), GroundVehicle< T, Type >::gcache, and GroundVehicle< T, Type >::PowerChanged().
Referenced by AfterLoadVehicles(), CmdBuildRoadVehicle(), CmdRefitVehicle(), RoadVehAccelerationModelChanged(), RoadVehSlopeSteepnessChanged(), and TrainSlopeSteepnessChanged().
int GroundVehicle< T, Type >::GetAcceleration | ( | ) | const [inline] |
Calculates the acceleration of the vehicle under its current conditions.
Definition at line 106 of file ground_vehicle.cpp.
References AS_ACCEL, GroundVehicleCache::cached_air_drag, GroundVehicleCache::cached_axle_resistance, GroundVehicleCache::cached_max_te, GroundVehicleCache::cached_power, GroundVehicleCache::cached_weight, SpecializedVehicle< T, Type >::From(), GroundVehicle< T, Type >::gcache, GroundVehicle< T, Type >::GetSlopeResistance(), max(), and min().
Referenced by RoadVehAccelerate().
FORCEINLINE int32 GroundVehicle< T, Type >::GetSlopeResistance | ( | ) | const [inline] |
Calculates the total slope resistance for this vehicle.
Definition at line 91 of file ground_vehicle.hpp.
Referenced by GroundVehicle< T, Type >::GetAcceleration().
void GroundVehicle< T, Type >::PowerChanged | ( | ) | [inline] |
Recalculates the cached total power of a vehicle.
Should be called when the consist is changed.
Definition at line 22 of file ground_vehicle.cpp.
References GroundVehicleCache::cached_air_drag, GroundVehicleCache::cached_max_te, GroundVehicleCache::cached_max_track_speed, GroundVehicleCache::cached_power, SpecializedVehicle< T, Type >::First(), SpecializedVehicle< T, Type >::From(), GroundVehicle< T, Type >::gcache, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >::index, max(), min(), SetWindowDirty(), SetWindowWidgetDirty(), Vehicle::vehstatus, and VS_STOPPED.
Referenced by GroundVehicle< T, Type >::CargoChanged().
FORCEINLINE byte GroundVehicle< T, Type >::UpdateInclination | ( | bool | new_tile, | |
bool | turned | |||
) | [inline] |
Checks if the vehicle is in a slope and sets the required flags in that case.
new_tile | True if the vehicle reached a new tile. | |
turned | Indicates if the vehicle has turned. |
Definition at line 112 of file ground_vehicle.hpp.
uint16 GroundVehicle< T, Type >::gv_flags |
Definition at line 76 of file ground_vehicle.hpp.
Referenced by GroundVehicle< RoadVehicle, VEH_ROAD >::UpdateInclination().