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

@@ -4119,3 +4119,20 @@ Trackdir Train::GetVehicleTrackdir() const
return TrackDirectionToTrackdir(FindFirstTrack(this->track), this->direction);
}
uint16 Train::GetMaxWeight() const
{
uint16 weight = CargoSpec::Get(this->cargo_type)->WeightOfNUnitsInTrain(this->GetEngine()->DetermineCapacity(this));
/* 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;
}