0x004597FD
| 775 | |
| 776 | // 0x004597FD |
| 777 | static void generateIndustries(uint32_t minProgress, uint32_t maxProgress) |
| 778 | { |
| 779 | auto numIndustriesAvailable = 0; |
| 780 | for (auto indObjId = 0U; indObjId < ObjectManager::getMaxObjects(ObjectType::industry); indObjId++) |
| 781 | { |
| 782 | if (ObjectManager::get<IndustryObject>(indObjId) != nullptr) |
| 783 | { |
| 784 | numIndustriesAvailable++; |
| 785 | } |
| 786 | } |
| 787 | |
| 788 | if (numIndustriesAvailable == 0) |
| 789 | { |
| 790 | return; |
| 791 | } |
| 792 | |
| 793 | GameCommands::setUpdatingCompanyId(CompanyId::neutral); |
| 794 | |
| 795 | auto progressTicksPerIndustry = (maxProgress - minProgress) / numIndustriesAvailable; |
| 796 | auto currentProgress = minProgress; |
| 797 | |
| 798 | for (auto indObjId = 0U; indObjId < ObjectManager::getMaxObjects(ObjectType::industry); indObjId++) |
| 799 | { |
| 800 | auto* industryObj = ObjectManager::get<IndustryObject>(indObjId); |
| 801 | if (industryObj == nullptr) |
| 802 | { |
| 803 | continue; |
| 804 | } |
| 805 | |
| 806 | currentProgress += progressTicksPerIndustry; |
| 807 | updateProgress(currentProgress); |
| 808 | |
| 809 | // Check if industry is available at present |
| 810 | if (getCurrentYear() < industryObj->designedYear || getCurrentYear() >= industryObj->obsoleteYear) |
| 811 | { |
| 812 | continue; |
| 813 | } |
| 814 | |
| 815 | // Check if required cargo is available |
| 816 | if (industryObj->requiredCargoType[0] != 0xFF) |
| 817 | { |
| 818 | auto numCargoSpecified = 0; |
| 819 | auto numCargoAvailable = 0; |
| 820 | for (auto cargoType : industryObj->requiredCargoType) |
| 821 | { |
| 822 | if (cargoType == 0xFF) |
| 823 | { |
| 824 | continue; |
| 825 | } |
| 826 | |
| 827 | numCargoSpecified++; |
| 828 | if (isCargoProducedAnywhere(cargoType)) |
| 829 | { |
| 830 | numCargoAvailable++; |
| 831 | } |
| 832 | } |
| 833 | |
| 834 | if (industryObj->hasFlags(IndustryObjectFlags::requiresAllCargo)) |
no test coverage detected