Fix weight calculation
This commit is contained in:
64
src/train.h
64
src/train.h
@@ -267,7 +267,7 @@ public:
|
||||
return const_cast<Train *>(const_cast<const Train *>(this)->GetStationLoadingVehicle());
|
||||
}
|
||||
|
||||
inline uint16 GetCargoWeight(uint cargo_amount) const
|
||||
uint16 GetCargoWeight(uint cargo_amount) const
|
||||
{
|
||||
if (cargo_amount > 0) {
|
||||
return (CargoSpec::Get(this->cargo_type)->weight * cargo_amount * FreightWagonMult(this->cargo_type)) / 16;
|
||||
@@ -277,10 +277,10 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the weight of this vehicle when empty.
|
||||
* @return Empty weight in tonnes.
|
||||
*/
|
||||
uint16 GetEmptyWeight() const
|
||||
* Allows to know the weight value that this vehicle will use (excluding cargo).
|
||||
* @return Weight value from the engine in tonnes.
|
||||
*/
|
||||
uint16 GetWeightWithoutCargo() const
|
||||
{
|
||||
uint16 weight = 0;
|
||||
|
||||
@@ -294,28 +294,16 @@ public:
|
||||
weight += RailVehInfo(this->gcache.first_engine)->pow_wag_weight;
|
||||
}
|
||||
|
||||
return weight * (this->IsWagon() ? FreightWagonMult(this->cargo_type) : 1);
|
||||
return weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the weight of this vehicle when fully loaded.
|
||||
* @return Loaded weight in tonnes.
|
||||
*/
|
||||
uint16 GetLoadedWeight() const
|
||||
* Allows to know the weight value that this vehicle will use (cargo only).
|
||||
* @return Weight value from the engine in tonnes.
|
||||
*/
|
||||
uint16 GetCargoWeight() const
|
||||
{
|
||||
uint16 weight = (CargoSpec::Get(this->cargo_type)->weight * this->cargo_cap) / 16;
|
||||
|
||||
/* Vehicle weight is not added for articulated parts. */
|
||||
if (!this->IsArticulatedPart()) {
|
||||
weight += GetVehicleProperty(this, PROP_TRAIN_WEIGHT, RailVehInfo(this->engine_type)->weight);
|
||||
}
|
||||
|
||||
/* Powered wagons have extra weight added. */
|
||||
if (HasBit(this->flags, VRF_POWEREDWAGON)) {
|
||||
weight += RailVehInfo(this->gcache.first_engine)->pow_wag_weight;
|
||||
}
|
||||
|
||||
return weight * (this->IsWagon() ? FreightWagonMult(this->cargo_type) : 1);
|
||||
return this->GetCargoWeight(this->cargo.StoredCount());
|
||||
}
|
||||
|
||||
protected: // These functions should not be called outside acceleration code.
|
||||
@@ -369,36 +357,6 @@ protected: // These functions should not be called outside acceleration code.
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to know the weight value that this vehicle will use (excluding cargo).
|
||||
* @return Weight value from the engine in tonnes.
|
||||
*/
|
||||
inline uint16 GetWeightWithoutCargo() const
|
||||
{
|
||||
uint16 weight = 0;
|
||||
|
||||
/* Vehicle weight is not added for articulated parts. */
|
||||
if (!this->IsArticulatedPart()) {
|
||||
weight += GetVehicleProperty(this, PROP_TRAIN_WEIGHT, RailVehInfo(this->engine_type)->weight);
|
||||
}
|
||||
|
||||
/* Powered wagons have extra weight added. */
|
||||
if (HasBit(this->flags, VRF_POWEREDWAGON)) {
|
||||
weight += RailVehInfo(this->gcache.first_engine)->pow_wag_weight;
|
||||
}
|
||||
|
||||
return weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to know the weight value that this vehicle will use (cargo only).
|
||||
* @return Weight value from the engine in tonnes.
|
||||
*/
|
||||
inline uint16 GetCargoWeight() const
|
||||
{
|
||||
return this->GetCargoWeight(this->cargo.StoredCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to know the weight value that this vehicle will use.
|
||||
* @return Weight value from the engine in tonnes.
|
||||
|
Reference in New Issue
Block a user