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

Function GetEngineCategoryName

src/engine_gui.cpp:40–53  ·  view source on GitHub ↗

* Return the category of an engine. * @param engine Engine to examine. * @return String describing the category ("road veh", "train". "airplane", or "ship") of the engine. */

Source from the content-addressed store, hash-verified

38 * @return String describing the category ("road veh", "train". "airplane", or "ship") of the engine.
39 */
40StringID GetEngineCategoryName(EngineID engine)
41{
42 const Engine *e = Engine::Get(engine);
43 switch (e->type) {
44 default: NOT_REACHED();
45 case VEH_ROAD:
46 return GetRoadTypeInfo(e->VehInfo<RoadVehicleInfo>().roadtype)->strings.new_engine;
47 case VEH_AIRCRAFT: return STR_ENGINE_PREVIEW_AIRCRAFT;
48 case VEH_SHIP: return STR_ENGINE_PREVIEW_SHIP;
49 case VEH_TRAIN:
50 assert(e->VehInfo<RailVehicleInfo>().railtypes.Any());
51 return GetRailTypeInfo(e->VehInfo<RailVehicleInfo>().railtypes.GetNthSetBit(0).value())->strings.new_loco;
52 }
53}
54
55static constexpr std::initializer_list<NWidgetPart> _nested_engine_preview_widgets = {
56 NWidget(NWID_HORIZONTAL),

Callers 4

UpdateWidgetSizeMethod · 0.85
DrawWidgetMethod · 0.85
NewVehicleAvailableFunction · 0.85

Calls 6

NOT_REACHEDFunction · 0.85
GetRoadTypeInfoFunction · 0.85
GetRailTypeInfoFunction · 0.85
AnyMethod · 0.80
GetNthSetBitMethod · 0.80
valueMethod · 0.45

Tested by

no test coverage detected