0x00459722 & 0x004598F0
| 419 | |
| 420 | // 0x00459722 & 0x004598F0 |
| 421 | int32_t capOfTypeOfIndustry(const uint8_t indObjId, const uint8_t numIndustriesFactor) |
| 422 | { |
| 423 | const auto* indObj = ObjectManager::get<IndustryObject>(indObjId); |
| 424 | |
| 425 | // totalOfTypeInScenario is in the range of 1->32 inclusive |
| 426 | // numIndustriesFactor is in the range of 0->2 (low, med, high) |
| 427 | // This formula is ultimately staticPreferredTotalOfType = 1/4 * ((numIndustriesFactor + 1) * indObj->totalOfTypeInScenario) |
| 428 | // but we will do it in two steps to keep identical results. |
| 429 | const auto intermediate1 = ((numIndustriesFactor + 1) * indObj->totalOfTypeInScenario) / 3; |
| 430 | const auto staticPreferredTotalOfType = intermediate1 - intermediate1 / 4; |
| 431 | |
| 432 | // The preferred total can vary by up to a half of the static preferred total. |
| 433 | const auto randomPreferredTotalOfType = (staticPreferredTotalOfType / 2) * (gPrng1().randNext(0xFF) / 256); |
| 434 | return staticPreferredTotalOfType + randomPreferredTotalOfType; |
| 435 | } |
| 436 | |
| 437 | // 0x00459722 |
| 438 | static bool hasReachedCapOfTypeOfIndustry(const uint8_t indObjId) |
no test coverage detected