summaryrefslogtreecommitdiff
path: root/src/industry_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-09-25 09:32:20 +0000
committerrubidium <rubidium@openttd.org>2009-09-25 09:32:20 +0000
commit36e70b57ee629ca522e14ec3a3988f6671d37d6f (patch)
tree8c5e0528d899f192138988204aacedf4f1ad2f91 /src/industry_cmd.cpp
parentbc2edd2604b1e93551d0610e9d906bb663388177 (diff)
downloadopenttd-36e70b57ee629ca522e14ec3a3988f6671d37d6f.tar.xz
(svn r17633) -Fix [FS#3233]: [NewGRF] Crash when trying to build an industry that has no industry layout defined.
Diffstat (limited to 'src/industry_cmd.cpp')
-rw-r--r--src/industry_cmd.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 35b6b91a9..e445308aa 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1672,6 +1672,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;
@@ -1724,7 +1725,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
const IndustrySpec *indspec = GetIndustrySpec(it);
/* 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) */
@@ -1862,7 +1863,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 */
@@ -1885,7 +1886,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);
}