TBTR: Show empty and full train weights in GUI, and weight ratios if enabled
This commit is contained in:
26
src/train.h
26
src/train.h
@@ -221,6 +221,15 @@ struct Train FINAL : public GroundVehicle<Train, VEH_TRAIN> {
|
||||
return const_cast<Train *>(const_cast<const Train *>(this)->GetStationLoadingVehicle());
|
||||
}
|
||||
|
||||
inline uint16 GetCargoWeight(uint cargo_amount) const
|
||||
{
|
||||
if (cargo_amount > 0) {
|
||||
return (CargoSpec::Get(this->cargo_type)->weight * cargo_amount * FreightWagonMult(this->cargo_type)) / 16;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected: // These functions should not be called outside acceleration code.
|
||||
/**
|
||||
* Gets the speed a broken down train (low speed breakdown) is limited to.
|
||||
@@ -272,13 +281,9 @@ protected: // These functions should not be called outside acceleration code.
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to know the weight value that this vehicle will use.
|
||||
* @return Weight value from the engine in tonnes.
|
||||
*/
|
||||
inline uint16 GetWeight() const
|
||||
inline uint16 GetWeightWithoutCargo() const
|
||||
{
|
||||
uint16 weight = (CargoSpec::Get(this->cargo_type)->weight * this->cargo.StoredCount() * FreightWagonMult(this->cargo_type)) / 16;
|
||||
uint16 weight = 0;
|
||||
|
||||
/* Vehicle weight is not added for articulated parts. */
|
||||
if (!this->IsArticulatedPart()) {
|
||||
@@ -293,6 +298,15 @@ protected: // These functions should not be called outside acceleration code.
|
||||
return weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to know the weight value that this vehicle will use.
|
||||
* @return Weight value from the engine in tonnes.
|
||||
*/
|
||||
inline uint16 GetWeight() const
|
||||
{
|
||||
return this->GetWeightWithoutCargo() + this->GetCargoWeight(this->cargo.StoredCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to know the tractive effort value that this vehicle will use.
|
||||
* @return Tractive effort value from the engine.
|
||||
|
Reference in New Issue
Block a user