summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-03-07 12:20:17 +0000
committeralberth <alberth@openttd.org>2010-03-07 12:20:17 +0000
commit384e870be2d13bc9465a740ed694bb84d42246de (patch)
tree9e03f399f826a3e24fd57898fa532ec8a0ac53ee
parent8d033e964ef50dab43dd1eac309ffc3c13ac5796 (diff)
downloadopenttd-384e870be2d13bc9465a740ed694bb84d42246de.tar.xz
(svn r19362) -Fix [FS#3667] (r19270): Failure to prospect an industry should not cause a crash.
-rw-r--r--src/industry_cmd.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 66686ee9f..0c963e96a 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1824,19 +1824,17 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (ret.Failed()) return ret;
}
- if (flags & DC_EXEC) {
- assert(ind != NULL);
- if (_game_mode != GM_EDITOR) {
- SetDParam(0, indspec->name);
- if (indspec->new_industry_text > STR_LAST_STRINGID) {
- SetDParam(1, STR_TOWN_NAME);
- SetDParam(2, ind->town->index);
- } else {
- SetDParam(1, ind->town->index);
- }
- AddIndustryNewsItem(indspec->new_industry_text, NS_INDUSTRY_OPEN, ind->index);
- AI::BroadcastNewEvent(new AIEventIndustryOpen(ind->index));
+ if ((flags & DC_EXEC) && ind != NULL && _game_mode != GM_EDITOR) {
+ /* Created a new industry in-game, advertise the event. */
+ SetDParam(0, indspec->name);
+ if (indspec->new_industry_text > STR_LAST_STRINGID) {
+ SetDParam(1, STR_TOWN_NAME);
+ SetDParam(2, ind->town->index);
+ } else {
+ SetDParam(1, ind->town->index);
}
+ AddIndustryNewsItem(indspec->new_industry_text, NS_INDUSTRY_OPEN, ind->index);
+ AI::BroadcastNewEvent(new AIEventIndustryOpen(ind->index));
}
return CommandCost(EXPENSES_OTHER, indspec->GetConstructionCost());