MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / formatVehicleString

Function formatVehicleString

src/OpenLoco/src/Ui/Windows/MapWindow.cpp:1545–1594  ·  view source on GitHub ↗

0x0046D81F

Source from the content-addressed store, hash-verified

1543
1544 // 0x0046D81F
1545 static void formatVehicleString(Window* self, FormatArguments& args)
1546 {
1547 static constexpr StringId vehicleStringSingular[] = {
1548 StringIds::num_trains_singular,
1549 StringIds::num_buses_singular,
1550 StringIds::num_trucks_singular,
1551 StringIds::num_trams_singular,
1552 StringIds::num_aircrafts_singular,
1553 StringIds::num_ships_singular,
1554 };
1555
1556 static constexpr StringId vehicleStringPlural[] = {
1557 StringIds::num_trains_plural,
1558 StringIds::num_buses_plural,
1559 StringIds::num_trucks_plural,
1560 StringIds::num_trams_plural,
1561 StringIds::num_aircrafts_plural,
1562 StringIds::num_ships_plural,
1563 };
1564
1565 int16_t vehicleIndex = Numerics::bitScanForward(self->var_854);
1566 uint16_t totalVehicleCount = 0;
1567 auto stringId = StringIds::status_num_vehicles_plural;
1568
1569 if (vehicleIndex == -1)
1570 {
1571 for (auto i = 0; i < 6; i++)
1572 {
1573 totalVehicleCount += _vehicleTypeCounts[i];
1574 }
1575
1576 if (totalVehicleCount == 1)
1577 {
1578 stringId = StringIds::status_num_vehicles_singular;
1579 }
1580 }
1581 else
1582 {
1583 totalVehicleCount = _vehicleTypeCounts[vehicleIndex];
1584 stringId = vehicleStringPlural[vehicleIndex];
1585
1586 if (totalVehicleCount == 1)
1587 {
1588 stringId = vehicleStringSingular[vehicleIndex];
1589 }
1590 }
1591
1592 args.push(stringId);
1593 args.push(totalVehicleCount);
1594 }
1595
1596 // 0x0046D87C
1597 static void formatIndustryString(Window* self, FormatArguments& args)

Callers 1

drawFunction · 0.85

Calls 2

bitScanForwardFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected