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

Method GetDisplayWeight

src/engine.cpp:407–418  ·  view source on GitHub ↗

* Returns the weight of the engine for display purposes. * For dual-headed train-engines this is the weight of both heads * @return weight in display units metric tons */

Source from the content-addressed store, hash-verified

405 * @return weight in display units metric tons
406 */
407uint Engine::GetDisplayWeight() const
408{
409 /* Only trains and road vehicles have 'weight'. */
410 switch (this->type) {
411 case VEH_TRAIN:
412 return GetEngineProperty(this->index, PROP_TRAIN_WEIGHT, this->VehInfo<RailVehicleInfo>().weight) << (this->VehInfo<RailVehicleInfo>().railveh_type == RAILVEH_MULTIHEAD ? 1 : 0);
413 case VEH_ROAD:
414 return GetEngineProperty(this->index, PROP_ROADVEH_WEIGHT, this->VehInfo<RoadVehicleInfo>().weight) / 4;
415
416 default: NOT_REACHED();
417 }
418}
419
420/**
421 * Returns the tractive effort of the engine for display purposes.

Callers 7

GetTrainEngineInfoStringFunction · 0.80
DrawRoadVehPurchaseInfoFunction · 0.80
GetWeightMethod · 0.80

Calls 2

GetEnginePropertyFunction · 0.85
NOT_REACHEDFunction · 0.85

Tested by

no test coverage detected