1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-19 02:12:37 +01:00

(svn r17677) [0.7] -Backport from trunk:

- Fix: [NewGRF] Crash when trying to build an industry that has no industry layout defined [FS#3233] (r17638, r17633)
[0.7] -Prepare for 0.7.3
This commit is contained in:
rubidium
2009-10-01 10:55:05 +00:00
parent 9443dea1f1
commit 9360409b4e
7 changed files with 93 additions and 61 deletions

View File

@@ -1597,6 +1597,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const Ind
*/
static Industry *CreateNewIndustryHelper(TileIndex tile, IndustryType type, DoCommandFlag flags, const IndustrySpec *indspec, uint itspec_index, uint32 seed, Owner founder)
{
assert(itspec_index < indspec->num_table);
const IndustryTileTable *it = indspec->table[itspec_index];
bool custom_shape_check = false;
@@ -1649,9 +1650,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
const Industry *ind = NULL;
/* Check if the to-be built/founded industry is available for this climate. */
if (!indspec->enabled) {
return CMD_ERROR;
}
if (!indspec->enabled || indspec->num_table == 0) return CMD_ERROR;
/* If the setting for raw-material industries is not on, you cannot build raw-material industries.
* Raw material industries are industries that do not accept cargo (at least for now) */
@@ -1788,7 +1787,7 @@ void GenerateIndustries()
}
chance = ind_spc->appear_creation[_settings_game.game_creation.landscape];
if (ind_spc->enabled && chance > 0) {
if (ind_spc->enabled && chance > 0 && ind_spc->num_table > 0) {
/* 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 _numof_industry_table,in fact */
@@ -1811,7 +1810,7 @@ void GenerateIndustries()
* @todo : Do we really have to pass chance as un-scaled value, since we've already
* processed that scaling above? No, don't think so. Will find a way. */
ind_spc = GetIndustrySpec(it);
if (ind_spc->enabled) {
if (ind_spc->enabled && ind_spc->num_table > 0) {
chance = ind_spc->appear_creation[_settings_game.game_creation.landscape];
if (chance > 0) PlaceInitialIndustry(it, chance);
}
@@ -1868,7 +1867,7 @@ static void MaybeNewIndustry(void)
ind_spc = GetIndustrySpec(j);
byte chance = ind_spc->appear_ingame[_settings_game.game_creation.landscape];
if (!ind_spc->enabled || chance == 0) continue;
if (!ind_spc->enabled || chance == 0 || ind_spc->num_table == 0) continue;
/* If there is no Callback CBID_INDUSTRY_AVAILABLE or if this one did anot failed,
* and if appearing chance for this landscape is above 0, this industry can be chosen */