|
@@ -123,167 +123,167 @@ struct RoadVehicle FINAL : public Ground
|
|
|
|
|
|
bool IsBus() const;
|
|
|
|
|
|
int GetCurrentMaxSpeed() const;
|
|
|
int UpdateSpeed();
|
|
|
|
|
|
protected: // These functions should not be called outside acceleration code.
|
|
|
|
|
|
/**
|
|
|
* Allows to know the power value that this vehicle will use.
|
|
|
* @return Power value from the engine in HP, or zero if the vehicle is not powered.
|
|
|
*/
|
|
|
FORCEINLINE uint16 GetPower() const
|
|
|
inline uint16 GetPower() const
|
|
|
{
|
|
|
/* Power is not added for articulated parts */
|
|
|
if (!this->IsArticulatedPart()) {
|
|
|
/* Road vehicle power is in units of 10 HP. */
|
|
|
return 10 * GetVehicleProperty(this, PROP_ROADVEH_POWER, RoadVehInfo(this->engine_type)->power);
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Returns a value if this articulated part is powered.
|
|
|
* @return Zero, because road vehicles don't have powered parts.
|
|
|
*/
|
|
|
FORCEINLINE uint16 GetPoweredPartPower(const RoadVehicle *head) const
|
|
|
inline uint16 GetPoweredPartPower(const RoadVehicle *head) const
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Allows to know the weight value that this vehicle will use.
|
|
|
* @return Weight value from the engine in tonnes.
|
|
|
*/
|
|
|
FORCEINLINE uint16 GetWeight() const
|
|
|
inline uint16 GetWeight() const
|
|
|
{
|
|
|
uint16 weight = (CargoSpec::Get(this->cargo_type)->weight * this->cargo.Count()) / 16;
|
|
|
|
|
|
/* Vehicle weight is not added for articulated parts. */
|
|
|
if (!this->IsArticulatedPart()) {
|
|
|
/* Road vehicle weight is in units of 1/4 t. */
|
|
|
weight += GetVehicleProperty(this, PROP_ROADVEH_WEIGHT, RoadVehInfo(this->engine_type)->weight) / 4;
|
|
|
}
|
|
|
|
|
|
return weight;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Allows to know the tractive effort value that this vehicle will use.
|
|
|
* @return Tractive effort value from the engine.
|
|
|
*/
|
|
|
FORCEINLINE byte GetTractiveEffort() const
|
|
|
inline byte GetTractiveEffort() const
|
|
|
{
|
|
|
/* The tractive effort coefficient is in units of 1/256. */
|
|
|
return GetVehicleProperty(this, PROP_ROADVEH_TRACTIVE_EFFORT, RoadVehInfo(this->engine_type)->tractive_effort);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Gets the area used for calculating air drag.
|
|
|
* @return Area of the engine in m^2.
|
|
|
*/
|
|
|
FORCEINLINE byte GetAirDragArea() const
|
|
|
inline byte GetAirDragArea() const
|
|
|
{
|
|
|
return 6;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Gets the air drag coefficient of this vehicle.
|
|
|
* @return Air drag value from the engine.
|
|
|
*/
|
|
|
FORCEINLINE byte GetAirDrag() const
|
|
|
inline byte GetAirDrag() const
|
|
|
{
|
|
|
return RoadVehInfo(this->engine_type)->air_drag;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Checks the current acceleration status of this vehicle.
|
|
|
* @return Acceleration status.
|
|
|
*/
|
|
|
FORCEINLINE AccelStatus GetAccelerationStatus() const
|
|
|
inline AccelStatus GetAccelerationStatus() const
|
|
|
{
|
|
|
return (this->vehstatus & VS_STOPPED) ? AS_BRAKE : AS_ACCEL;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Calculates the current speed of this vehicle.
|
|
|
* @return Current speed in km/h-ish.
|
|
|
*/
|
|
|
FORCEINLINE uint16 GetCurrentSpeed() const
|
|
|
inline uint16 GetCurrentSpeed() const
|
|
|
{
|
|
|
return this->cur_speed / 2;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Returns the rolling friction coefficient of this vehicle.
|
|
|
* @return Rolling friction coefficient in [1e-4].
|
|
|
*/
|
|
|
FORCEINLINE uint32 GetRollingFriction() const
|
|
|
inline uint32 GetRollingFriction() const
|
|
|
{
|
|
|
/* Trams have a slightly greater friction coefficient than trains.
|
|
|
* The rest of road vehicles have bigger values. */
|
|
|
uint32 coeff = (this->roadtype == ROADTYPE_TRAM) ? 40 : 75;
|
|
|
/* The friction coefficient increases with speed in a way that
|
|
|
* it doubles at 128 km/h, triples at 256 km/h and so on. */
|
|
|
return coeff * (128 + this->GetCurrentSpeed()) / 128;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Allows to know the acceleration type of a vehicle.
|
|
|
* @return Zero, road vehicles always use a normal acceleration method.
|
|
|
*/
|
|
|
FORCEINLINE int GetAccelerationType() const
|
|
|
inline int GetAccelerationType() const
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Returns the slope steepness used by this vehicle.
|
|
|
* @return Slope steepness used by the vehicle.
|
|
|
*/
|
|
|
FORCEINLINE uint32 GetSlopeSteepness() const
|
|
|
inline uint32 GetSlopeSteepness() const
|
|
|
{
|
|
|
return _settings_game.vehicle.roadveh_slope_steepness;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Gets the maximum speed allowed by the track for this vehicle.
|
|
|
* @return Since roads don't limit road vehicle speed, it returns always zero.
|
|
|
*/
|
|
|
FORCEINLINE uint16 GetMaxTrackSpeed() const
|
|
|
inline uint16 GetMaxTrackSpeed() const
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Checks if the vehicle is at a tile that can be sloped.
|
|
|
* @return True if the tile can be sloped.
|
|
|
*/
|
|
|
FORCEINLINE bool TileMayHaveSlopedTrack() const
|
|
|
inline bool TileMayHaveSlopedTrack() const
|
|
|
{
|
|
|
TrackStatus ts = GetTileTrackStatus(this->tile, TRANSPORT_ROAD, this->compatible_roadtypes);
|
|
|
TrackBits trackbits = TrackStatusToTrackBits(ts);
|
|
|
|
|
|
return trackbits == TRACK_BIT_X || trackbits == TRACK_BIT_Y;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Road vehicles have to use GetSlopePixelZ() to compute their height
|
|
|
* if they are reversing because in that case, their direction
|
|
|
* is not parallel with the road. It is safe to return \c true
|
|
|
* even if it is not reversing.
|
|
|
* @return are we (possibly) reversing?
|
|
|
*/
|
|
|
FORCEINLINE bool HasToUseGetSlopePixelZ()
|
|
|
inline bool HasToUseGetSlopePixelZ()
|
|
|
{
|
|
|
const RoadVehicle *rv = this->First();
|
|
|
|
|
|
/* Check if this vehicle is in the same direction as the road under.
|
|
|
* We already know it has either GVF_GOINGUP_BIT or GVF_GOINGDOWN_BIT set. */
|
|
|
|
|
|
if (rv->state <= RVSB_TRACKDIR_MASK && IsReversingRoadTrackdir((Trackdir)rv->state)) {
|
|
|
/* If the first vehicle is reversing, this vehicle may be reversing too
|
|
|
* (especially if this is the first, and maybe the only, vehicle).*/
|
|
|
return true;
|
|
|
}
|
|
|
|