Feature: Display power-to-weight ratio in ground vehicle details GUI

This commit is contained in:
Henry Wilson
2022-10-31 19:47:25 +00:00
committed by Michael Lutz
parent b304c06a4a
commit 59dbcdb5ba
11 changed files with 126 additions and 2 deletions

View File

@@ -1753,3 +1753,16 @@ Trackdir RoadVehicle::GetVehicleTrackdir() const
* otherwise transform it into a valid track direction */
return (Trackdir)((IsReversingRoadTrackdir((Trackdir)this->state)) ? (this->state - 6) : this->state);
}
uint16 RoadVehicle::GetMaxWeight() const
{
uint16 weight = CargoSpec::Get(this->cargo_type)->WeightOfNUnits(this->GetEngine()->DetermineCapacity(this));
/* 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;
}