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

Function GetCargoSubtypeText

src/vehicle_gui.cpp:1387–1402  ·  view source on GitHub ↗

Get the cargo subtype text from NewGRF for the vehicle details window. */

Source from the content-addressed store, hash-verified

1385
1386/** Get the cargo subtype text from NewGRF for the vehicle details window. */
1387StringID GetCargoSubtypeText(const Vehicle *v)
1388{
1389 if (!EngInfo(v->engine_type)->callback_mask.Test(VehicleCallbackMask::CargoSuffix)) return STR_EMPTY;
1390 std::array<int32_t, 1> regs100;
1391 uint16_t cb = GetVehicleCallback(CBID_VEHICLE_CARGO_SUFFIX, 0, 0, v->engine_type, v, regs100);
1392 if (v->GetGRF()->grf_version < 8 && cb == 0xFF) return STR_EMPTY;
1393 if (cb == CALLBACK_FAILED || cb == 0x400) return STR_EMPTY;
1394 if (cb == 0x40F) {
1395 return GetGRFStringID(v->GetGRFID(), static_cast<GRFStringID>(regs100[0]));
1396 }
1397 if (cb > 0x400) {
1398 ErrorUnknownCallbackResult(v->GetGRFID(), CBID_VEHICLE_CARGO_SUFFIX, cb);
1399 return STR_EMPTY;
1400 }
1401 return GetGRFStringID(v->GetGRFID(), GRFSTR_MISC_GRF_TEXT + cb);
1402}
1403
1404/** Sort vehicle groups by the number of vehicles in the group */
1405static bool VehicleGroupLengthSorter(const GUIVehicleGroup &a, const GUIVehicleGroup &b)

Callers 6

DrawShipDetailsFunction · 0.85
DrawRoadVehDetailsFunction · 0.85
DrawAircraftDetailsFunction · 0.85
GetBestFittingSubTypeFunction · 0.85
BuildRefitListMethod · 0.85

Calls 7

EngInfoFunction · 0.85
GetVehicleCallbackFunction · 0.85
GetGRFStringIDFunction · 0.85
TestMethod · 0.80
GetGRFMethod · 0.45
GetGRFIDMethod · 0.45

Tested by

no test coverage detected