MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetMaxWeight

Method GetMaxWeight

src/train_cmd.cpp:4243–4258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4241}
4242
4243uint16_t Train::GetMaxWeight() const
4244{
4245 uint16_t weight = CargoSpec::Get(this->cargo_type)->WeightOfNUnitsInTrain(this->GetEngine()->DetermineCapacity(this));
4246
4247 /* Vehicle weight is not added for articulated parts. */
4248 if (!this->IsArticulatedPart()) {
4249 weight += GetVehicleProperty(this, PROP_TRAIN_WEIGHT, RailVehInfo(this->engine_type)->weight);
4250 }
4251
4252 /* Powered wagons have extra weight added. */
4253 if (this->flags.Test(VehicleRailFlag::PoweredWagon)) {
4254 weight += RailVehInfo(this->gcache.first_engine)->pow_wag_weight;
4255 }
4256
4257 return weight;
4258}

Callers 1

GetDisplayMaxWeightMethod · 0.45

Calls 7

GetVehiclePropertyFunction · 0.85
RailVehInfoFunction · 0.85
WeightOfNUnitsInTrainMethod · 0.80
DetermineCapacityMethod · 0.80
IsArticulatedPartMethod · 0.80
TestMethod · 0.80
GetEngineMethod · 0.45

Tested by

no test coverage detected