|
@@ -1837,17 +1837,17 @@ static Industry *CreateNewIndustry(TileI
|
|
|
assert(i != NULL || ret.Failed());
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Compute the appearance probability for an industry during map creation.
|
|
|
* @param it Industrytype to compute for
|
|
|
* @param force_at_least_one Returns whether at least one instance should be forced on map creation
|
|
|
* @return relative probability for the industry to appear
|
|
|
* @param it Industry type to compute.
|
|
|
* @param [out] force_at_least_one Returns whether at least one instance should be forced on map creation.
|
|
|
* @return Relative probability for the industry to appear.
|
|
|
*/
|
|
|
static uint32 GetScaledIndustryProbability(IndustryType it, bool *force_at_least_one)
|
|
|
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 == 0)) {
|
|
@@ -1906,13 +1906,13 @@ void GenerateIndustries()
|
|
|
uint32 industry_probs[NUM_INDUSTRYTYPES];
|
|
|
bool force_at_least_one[NUM_INDUSTRYTYPES];
|
|
|
uint32 total_prob = 0;
|
|
|
uint num_forced = 0;
|
|
|
|
|
|
for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) {
|
|
|
industry_probs[it] = GetScaledIndustryProbability(it, force_at_least_one + it);
|
|
|
industry_probs[it] = GetScaledIndustryGenerationProbability(it, force_at_least_one + it);
|
|
|
total_prob += industry_probs[it];
|
|
|
if (force_at_least_one[it]) num_forced++;
|
|
|
}
|
|
|
|
|
|
if (total_prob == 0 || total_amount < num_forced) {
|
|
|
/* Only place the forced ones */
|