Skip to content

Commit

Permalink
Fix OpenTTD#8311, b98c776: Industry probability at map generation was…
Browse files Browse the repository at this point in the history
… scaled differently when set via property or callback.
  • Loading branch information
frosch123 authored and michicc committed Sep 24, 2020
1 parent 0110fa1 commit df5362a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/industry_cmd.cpp
Expand Up @@ -2079,13 +2079,14 @@ static Industry *CreateNewIndustry(TileIndex tile, IndustryType type, IndustryAv
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
uint32 chance = ind_spc->appear_creation[_settings_game.game_creation.landscape];
if (!ind_spc->enabled || ind_spc->layouts.empty() ||
(_game_mode != GM_EDITOR && _settings_game.difficulty.industry_density == ID_FUND_ONLY) ||
(chance = GetIndustryProbabilityCallback(it, IACT_MAPGENERATION, chance)) == 0) {
*force_at_least_one = false;
return 0;
} else {
chance *= 16; // to increase precision
/* 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);
Expand Down

0 comments on commit df5362a

Please sign in to comment.