Fix: Prevents crash when no industries are present

(cherry picked from commit 5ea55f3948)
This commit is contained in:
Andrew Zhou
2021-12-01 21:17:24 -05:00
committed by Jonathan G Rennison
parent 24c07f1640
commit c183f07c15

View File

@@ -499,8 +499,12 @@ public:
/* We've chosen many random industries but no industries have been specified */ /* We've chosen many random industries but no industries have been specified */
SetDParam(0, STR_FUND_INDUSTRY_BUILD_NEW_INDUSTRY); SetDParam(0, STR_FUND_INDUSTRY_BUILD_NEW_INDUSTRY);
} else { } else {
if (count > 0) {
const IndustrySpec *indsp = GetIndustrySpec(this->index[this->selected_index]); const IndustrySpec *indsp = GetIndustrySpec(this->index[this->selected_index]);
SetDParam(0, (_settings_game.construction.raw_industry_construction == 2 && indsp->IsRawIndustry()) ? STR_FUND_INDUSTRY_PROSPECT_NEW_INDUSTRY : STR_FUND_INDUSTRY_FUND_NEW_INDUSTRY); SetDParam(0, (_settings_game.construction.raw_industry_construction == 2 && indsp->IsRawIndustry()) ? STR_FUND_INDUSTRY_PROSPECT_NEW_INDUSTRY : STR_FUND_INDUSTRY_FUND_NEW_INDUSTRY);
} else {
SetDParam(0, STR_FUND_INDUSTRY_FUND_NEW_INDUSTRY);
}
} }
break; break;
} }
@@ -732,6 +736,7 @@ public:
void OnHundredthTick() override void OnHundredthTick() override
{ {
if (_game_mode == GM_EDITOR) return; if (_game_mode == GM_EDITOR) return;
if (this->count == 0) return;
const IndustrySpec *indsp = GetIndustrySpec(this->selected_type); const IndustrySpec *indsp = GetIndustrySpec(this->selected_type);
if (indsp->enabled) { if (indsp->enabled) {