Get the cargo subtype text from NewGRF for the vehicle details window. */
| 1385 | |
| 1386 | /** Get the cargo subtype text from NewGRF for the vehicle details window. */ |
| 1387 | StringID 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 */ |
| 1405 | static bool VehicleGroupLengthSorter(const GUIVehicleGroup &a, const GUIVehicleGroup &b) |
no test coverage detected