|
|
@ -68,6 +68,12 @@ void ResetIndustries()
|
|
|
|
memcpy(&_industry_tile_specs, &_origin_industry_tile_specs, sizeof(_origin_industry_tile_specs));
|
|
|
|
memcpy(&_industry_tile_specs, &_origin_industry_tile_specs, sizeof(_origin_industry_tile_specs));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ResetIndustryCreationProbility(IndustryType type)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
assert(type < INVALID_INDUSTRYTYPE);
|
|
|
|
|
|
|
|
_industry_specs[type].appear_creation[_opt.landscape] = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Called if a new block is added to the industry-pool
|
|
|
|
* Called if a new block is added to the industry-pool
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -1666,16 +1672,21 @@ void GenerateIndustries()
|
|
|
|
const IndustrySpec *ind_spc;
|
|
|
|
const IndustrySpec *ind_spc;
|
|
|
|
|
|
|
|
|
|
|
|
/* Find the total amount of industries */
|
|
|
|
/* Find the total amount of industries */
|
|
|
|
for (it = IT_COAL_MINE; it < NUM_INDUSTRYTYPES; it++) {
|
|
|
|
if (_opt.diff.number_industries > 0) {
|
|
|
|
|
|
|
|
for (it = IT_COAL_MINE; it < NUM_INDUSTRYTYPES; it++) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ind_spc = GetIndustrySpec(it);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!CheckIfCallBackAllowsAvailability(it, IACT_MAPGENERATION)) {
|
|
|
|
|
|
|
|
ResetIndustryCreationProbility(it);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ind_spc = GetIndustrySpec(it);
|
|
|
|
|
|
|
|
if (ind_spc->enabled) {
|
|
|
|
|
|
|
|
chance = ind_spc->appear_creation[_opt.landscape];
|
|
|
|
chance = ind_spc->appear_creation[_opt.landscape];
|
|
|
|
if (chance > 0) {
|
|
|
|
if (ind_spc->enabled) && chance > 0 {
|
|
|
|
/* once the chance of appearance is determind, it have to be scaled by
|
|
|
|
/* once the chance of appearance is determind, it have to be scaled by
|
|
|
|
* the difficulty level. The "chance" in question is more an index into
|
|
|
|
* the difficulty level. The "chance" in question is more an index into
|
|
|
|
* the _numof_industry_table,in fact */
|
|
|
|
* the _numof_industry_table,in fact */
|
|
|
|
int num = _numof_industry_table[_opt.diff.number_industries][chance];
|
|
|
|
int num = (chance < 11) ? chance : _numof_industry_table[_opt.diff.number_industries][chance];
|
|
|
|
|
|
|
|
|
|
|
|
/* These are always placed next to the coastline, so we scale by the perimeter instead. */
|
|
|
|
/* These are always placed next to the coastline, so we scale by the perimeter instead. */
|
|
|
|
num = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(num) : ScaleByMapSize(num);
|
|
|
|
num = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(num) : ScaleByMapSize(num);
|
|
|
@ -1686,18 +1697,20 @@ void GenerateIndustries()
|
|
|
|
|
|
|
|
|
|
|
|
SetGeneratingWorldProgress(GWP_INDUSTRY, i);
|
|
|
|
SetGeneratingWorldProgress(GWP_INDUSTRY, i);
|
|
|
|
|
|
|
|
|
|
|
|
for (it = IT_COAL_MINE; it < NUM_INDUSTRYTYPES; it++) {
|
|
|
|
if (_opt.diff.number_industries > 0) {
|
|
|
|
/* Once the number of industries has been determined, let's really create them.
|
|
|
|
for (it = IT_COAL_MINE; it < NUM_INDUSTRYTYPES; it++) {
|
|
|
|
* The test for chance allows us to try create industries that are available only
|
|
|
|
/* Once the number of industries has been determined, let's really create them.
|
|
|
|
* for this landscape.
|
|
|
|
* The test for chance allows us to try create industries that are available only
|
|
|
|
* @todo : Do we really have to pass chance as un-scaled value, since we've already
|
|
|
|
* for this landscape.
|
|
|
|
* processed that scaling above? No, don't think so. Will find a way. */
|
|
|
|
* @todo : Do we really have to pass chance as un-scaled value, since we've already
|
|
|
|
ind_spc = GetIndustrySpec(it);
|
|
|
|
* processed that scaling above? No, don't think so. Will find a way. */
|
|
|
|
if (ind_spc->enabled) {
|
|
|
|
ind_spc = GetIndustrySpec(it);
|
|
|
|
chance = ind_spc->appear_creation[_opt.landscape];
|
|
|
|
if (ind_spc->enabled) {
|
|
|
|
if (chance > 0) PlaceInitialIndustry(it, chance);
|
|
|
|
chance = ind_spc->appear_creation[_opt.landscape];
|
|
|
|
|
|
|
|
if (chance > 0) PlaceInitialIndustry(it, chance);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Change industry production or do closure */
|
|
|
|
/* Change industry production or do closure */
|
|
|
@ -1824,8 +1837,9 @@ static void MaybeNewIndustry(void)
|
|
|
|
for (j = 0; j < NUM_INDUSTRYTYPES; j++) {
|
|
|
|
for (j = 0; j < NUM_INDUSTRYTYPES; j++) {
|
|
|
|
byte chance = GetIndustrySpec(j)->appear_ingame[_opt.landscape];
|
|
|
|
byte chance = GetIndustrySpec(j)->appear_ingame[_opt.landscape];
|
|
|
|
|
|
|
|
|
|
|
|
/* if appearing chance for this landscape is above 0, this industry can be chosen */
|
|
|
|
/* If there is no Callback CBID_INDUSTRY_AVAILABLE or if this one did anot failed,
|
|
|
|
if (chance != 0) {
|
|
|
|
* and if appearing chance for this landscape is above 0, this industry can be chosen */
|
|
|
|
|
|
|
|
if (CheckIfCallBackAllowsAvailability(j, IACT_RANDOMCREATION) && chance != 0) {
|
|
|
|
probability_max += chance;
|
|
|
|
probability_max += chance;
|
|
|
|
/* adds the result for this industry */
|
|
|
|
/* adds the result for this industry */
|
|
|
|
cumulative_probs[num].ind = j;
|
|
|
|
cumulative_probs[num].ind = j;
|
|
|
|