|
@@ -1844,13 +1844,13 @@ static Industry *CreateNewIndustry(TileI
|
|
|
static uint32 GetScaledIndustryGenerationProbability(IndustryType it, bool *force_at_least_one)
|
|
|
{
|
|
|
const IndustrySpec *ind_spc = GetIndustrySpec(it);
|
|
|
uint32 chance = ind_spc->appear_creation[_settings_game.game_creation.landscape] * 16; // * 16 to increase precision
|
|
|
if (!ind_spc->enabled || chance == 0 || ind_spc->num_table == 0 ||
|
|
|
!CheckIfCallBackAllowsAvailability(it, IACT_MAPGENERATION) ||
|
|
|
(_game_mode != GM_EDITOR && _settings_game.difficulty.number_industries == ID_FUND_ONLY)) {
|
|
|
(_game_mode != GM_EDITOR && _settings_game.difficulty.industry_density == ID_FUND_ONLY)) {
|
|
|
*force_at_least_one = false;
|
|
|
return 0;
|
|
|
} else {
|
|
|
/* We want industries appearing at coast to appear less often on bigger maps, as length of coast increases slower than map area.
|
|
|
* For simplicity we scale in both cases, though scaling the probabilities of all industries has no effect. */
|
|
|
chance = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(chance) : ScaleByMapSize(chance);
|
|
@@ -1865,13 +1865,13 @@ static uint32 GetScaledIndustryGeneratio
|
|
|
* @param it Industry type to compute.
|
|
|
* @param [out] min_number Minimal number of industries that should exist at the map.
|
|
|
* @return Relative probability for the industry to appear.
|
|
|
*/
|
|
|
static uint16 GetIndustryGamePlayProbability(IndustryType it, byte *min_number)
|
|
|
{
|
|
|
if (_settings_game.difficulty.number_industries == ID_FUND_ONLY) {
|
|
|
if (_settings_game.difficulty.industry_density == ID_FUND_ONLY) {
|
|
|
*min_number = 0;
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
const IndustrySpec *ind_spc = GetIndustrySpec(it);
|
|
|
byte chance = ind_spc->appear_ingame[_settings_game.game_creation.landscape];
|
|
@@ -1900,13 +1900,13 @@ static uint GetNumberOfIndustries()
|
|
|
25, // low
|
|
|
55, // normal
|
|
|
80, // high
|
|
|
};
|
|
|
|
|
|
assert(lengthof(numof_industry_table) == ID_END);
|
|
|
uint difficulty = (_game_mode != GM_EDITOR) ? _settings_game.difficulty.number_industries : (uint)ID_VERY_LOW;
|
|
|
uint difficulty = (_game_mode != GM_EDITOR) ? _settings_game.difficulty.industry_density : (uint)ID_VERY_LOW;
|
|
|
return ScaleByMapSize(numof_industry_table[difficulty]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Advertise about a new industry opening.
|
|
|
* @param ind Industry being opened.
|
|
@@ -1991,13 +1991,13 @@ void IndustryBuildData::Reset()
|
|
|
}
|
|
|
|
|
|
/** Monthly update of industry build data. */
|
|
|
void IndustryBuildData::MonthlyLoop()
|
|
|
{
|
|
|
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.
|
|
|
if (_settings_game.difficulty.number_industries == ID_FUND_ONLY) return; // 'no industries' setting,
|
|
|
if (_settings_game.difficulty.industry_density == ID_FUND_ONLY) return; // 'no industries' setting,
|
|
|
|
|
|
/* To prevent running out of unused industries for the player to connect,
|
|
|
* add a fraction of new industries each month, but only if the manager can keep up. */
|
|
|
uint max_behind = 1 + min(99u, ScaleByMapSize(3)); // At most 2 industries for small maps, and 100 at the biggest map (about 6 months industry build attempts).
|
|
|
if (GetCurrentTotalNumberOfIndustries() + max_behind >= (this->wanted_inds >> 16)) {
|
|
|
this->wanted_inds += ScaleByMapSize(NEWINDS_PER_MONTH);
|
|
@@ -2007,13 +2007,13 @@ void IndustryBuildData::MonthlyLoop()
|
|
|
/**
|
|
|
* This function will create random industries during game creation.
|
|
|
* It will scale the amount of industries by mapsize and difficulty level.
|
|
|
*/
|
|
|
void GenerateIndustries()
|
|
|
{
|
|
|
if (_game_mode != GM_EDITOR && _settings_game.difficulty.number_industries == ID_FUND_ONLY) return; // No industries in the game.
|
|
|
if (_game_mode != GM_EDITOR && _settings_game.difficulty.industry_density == ID_FUND_ONLY) return; // No industries in the game.
|
|
|
|
|
|
uint32 industry_probs[NUM_INDUSTRYTYPES];
|
|
|
bool force_at_least_one[NUM_INDUSTRYTYPES];
|
|
|
uint32 total_prob = 0;
|
|
|
uint num_forced = 0;
|
|
|
|