0x0046D87C
| 1595 | |
| 1596 | // 0x0046D87C |
| 1597 | static void formatIndustryString(Window* self, FormatArguments& args) |
| 1598 | { |
| 1599 | int16_t industryIndex = Numerics::bitScanForward(self->var_854); |
| 1600 | |
| 1601 | if (industryIndex == -1) |
| 1602 | { |
| 1603 | auto industries = IndustryManager::industries(); |
| 1604 | auto industryCount = std::distance(std::begin(industries), std::end(industries)); |
| 1605 | |
| 1606 | auto stringId = StringIds::status_num_industries_plural; |
| 1607 | |
| 1608 | if (industryCount == 1) |
| 1609 | { |
| 1610 | stringId = StringIds::status_num_industries_singular; |
| 1611 | } |
| 1612 | |
| 1613 | args.push(stringId); |
| 1614 | args.push(industryCount); |
| 1615 | } |
| 1616 | else |
| 1617 | { |
| 1618 | auto industryCount = 0; |
| 1619 | for (const auto& industry : IndustryManager::industries()) |
| 1620 | { |
| 1621 | if (industry.objectId == industryIndex) |
| 1622 | { |
| 1623 | industryCount++; |
| 1624 | } |
| 1625 | } |
| 1626 | |
| 1627 | auto industryObj = ObjectManager::get<IndustryObject>(industryIndex); |
| 1628 | auto stringId = industryObj->namePlural; |
| 1629 | |
| 1630 | if (industryCount == 1) |
| 1631 | { |
| 1632 | stringId = industryObj->nameSingular; |
| 1633 | } |
| 1634 | |
| 1635 | auto buffer = StringManager::getString(StringIds::buffer_1250); |
| 1636 | char* ptr = const_cast<char*>(buffer); |
| 1637 | |
| 1638 | auto argsBuf = FormatArgumentsBuffer{}; |
| 1639 | auto argsTmp = FormatArguments{ argsBuf }; |
| 1640 | argsTmp.push(industryCount); |
| 1641 | ptr = StringManager::formatString(ptr, stringId, argsTmp); |
| 1642 | |
| 1643 | *ptr++ = ' '; |
| 1644 | *ptr++ = '('; |
| 1645 | |
| 1646 | if (industryObj->requiresCargo()) |
| 1647 | { |
| 1648 | ptr = StringManager::formatString(ptr, StringIds::industry_require); |
| 1649 | |
| 1650 | ptr = industryObj->getRequiredCargoString(ptr); |
| 1651 | |
| 1652 | if (industryObj->producesCargo()) |
| 1653 | { |
| 1654 | ptr = StringManager::formatString(ptr, StringIds::cargo_to_produce); |
no test coverage detected