Monthly update of industry build data. */
| 2444 | |
| 2445 | /** Monthly update of industry build data. */ |
| 2446 | void IndustryBuildData::EconomyMonthlyLoop() |
| 2447 | { |
| 2448 | static const int NEWINDS_PER_MONTH = 0x38000 / (10 * 12); // lower 16 bits is a float fraction, 3.5 industries per decade, divided by 10 * 12 months. |
| 2449 | if (_settings_game.difficulty.industry_density == ID_FUND_ONLY) return; // 'no industries' setting. |
| 2450 | |
| 2451 | /* To prevent running out of unused industries for the player to connect, |
| 2452 | * add a fraction of new industries each month, but only if the manager can keep up. */ |
| 2453 | uint max_behind = 1 + std::min(99u, Map::ScaleBySize(3)); // At most 2 industries for small maps, and 100 at the biggest map (about 6 months industry build attempts). |
| 2454 | if (GetCurrentTotalNumberOfIndustries() + max_behind >= (this->wanted_inds >> 16)) { |
| 2455 | this->wanted_inds += Map::ScaleBySize(NEWINDS_PER_MONTH); |
| 2456 | } |
| 2457 | } |
| 2458 | |
| 2459 | struct IndustryGenerationProbabilities { |
| 2460 | std::array<uint32_t, NUM_INDUSTRYTYPES> probs{}; |
no test coverage detected