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

Method GetDisplayMaxSpeed

src/engine.cpp:357–381  ·  view source on GitHub ↗

* Returns max speed of the engine for display purposes * @return max speed in km-ish/h */

Source from the content-addressed store, hash-verified

355 * @return max speed in km-ish/h
356 */
357uint Engine::GetDisplayMaxSpeed() const
358{
359 switch (this->type) {
360 case VEH_TRAIN:
361 return GetEngineProperty(this->index, PROP_TRAIN_SPEED, this->VehInfo<RailVehicleInfo>().max_speed);
362
363 case VEH_ROAD: {
364 uint max_speed = GetEngineProperty(this->index, PROP_ROADVEH_SPEED, 0);
365 return (max_speed != 0) ? max_speed * 2 : this->VehInfo<RoadVehicleInfo>().max_speed / 2;
366 }
367
368 case VEH_SHIP:
369 return GetEngineProperty(this->index, PROP_SHIP_SPEED, this->VehInfo<ShipVehicleInfo>().max_speed) / 2;
370
371 case VEH_AIRCRAFT: {
372 uint max_speed = GetEngineProperty(this->index, PROP_AIRCRAFT_SPEED, 0);
373 if (max_speed != 0) {
374 return (max_speed * 128) / 10;
375 }
376 return this->VehInfo<AircraftVehicleInfo>().max_speed;
377 }
378
379 default: NOT_REACHED();
380 }
381}
382
383/**
384 * Returns the power of the engine for display

Callers 15

ProcessConditionalOrderFunction · 0.45
PowerChangedMethod · 0.45
GetTrainEngineInfoStringFunction · 0.45
GetShipEngineInfoStringFunction · 0.45
EngineSpeedSorterFunction · 0.45
DrawRoadVehPurchaseInfoFunction · 0.45
DrawShipPurchaseInfoFunction · 0.45
DrawAircraftPurchaseInfoFunction · 0.45

Calls 2

GetEnginePropertyFunction · 0.85
NOT_REACHEDFunction · 0.85

Tested by

no test coverage detected