summaryrefslogtreecommitdiff
path: root/src/industry_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-04-28 16:07:28 +0000
committerfrosch <frosch@openttd.org>2012-04-28 16:07:28 +0000
commit789c95d4b830604529fe7e38b8db3a3ef6c20370 (patch)
treea5c131ea6cb32f0c7be2b77866430bc350d0fa73 /src/industry_cmd.cpp
parente2ad59fbe180a42b9a1e0ac81d7dd0fb5ec8e5cd (diff)
downloadopenttd-789c95d4b830604529fe7e38b8db3a3ef6c20370.tar.xz
(svn r24185) -Codechange: Deduplicate some only partly deduplicated code.
Diffstat (limited to 'src/industry_cmd.cpp')
-rw-r--r--src/industry_cmd.cpp50
1 files changed, 20 insertions, 30 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 8a5d7e36c..f331f3a21 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1582,6 +1582,25 @@ static CommandCost CheckIfFarEnoughFromConflictingIndustry(TileIndex tile, int t
}
/**
+ * Advertise about a new industry opening.
+ * @param ind Industry being opened.
+ */
+static void AdvertiseIndustryOpening(const Industry *ind)
+{
+ const IndustrySpec *ind_spc = GetIndustrySpec(ind->type);
+ SetDParam(0, ind_spc->name);
+ if (ind_spc->new_industry_text > STR_LAST_STRINGID) {
+ SetDParam(1, STR_TOWN_NAME);
+ SetDParam(2, ind->town->index);
+ } else {
+ SetDParam(1, ind->town->index);
+ }
+ AddIndustryNewsItem(ind_spc->new_industry_text, NS_INDUSTRY_OPEN, ind->index);
+ AI::BroadcastNewEvent(new ScriptEventIndustryOpen(ind->index));
+ Game::NewEvent(new ScriptEventIndustryOpen(ind->index));
+}
+
+/**
* Put an industry on the map.
* @param i Just allocated poolitem, mostly empty.
* @param tile North tile of the industry.
@@ -1867,17 +1886,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
}
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 ScriptEventIndustryOpen(ind->index));
- Game::NewEvent(new ScriptEventIndustryOpen(ind->index));
+ AdvertiseIndustryOpening(ind);
}
return CommandCost(EXPENSES_OTHER, indspec->GetConstructionCost());
@@ -1976,25 +1985,6 @@ static uint GetNumberOfIndustries()
}
/**
- * Advertise about a new industry opening.
- * @param ind Industry being opened.
- */
-static void AdvertiseIndustryOpening(const Industry *ind)
-{
- const IndustrySpec *ind_spc = GetIndustrySpec(ind->type);
- SetDParam(0, ind_spc->name);
- if (ind_spc->new_industry_text > STR_LAST_STRINGID) {
- SetDParam(1, STR_TOWN_NAME);
- SetDParam(2, ind->town->index);
- } else {
- SetDParam(1, ind->town->index);
- }
- AddIndustryNewsItem(ind_spc->new_industry_text, NS_INDUSTRY_OPEN, ind->index);
- AI::BroadcastNewEvent(new ScriptEventIndustryOpen(ind->index));
- Game::NewEvent(new ScriptEventIndustryOpen(ind->index));
-}
-
-/**
* Try to place the industry in the game.
* Since there is no feedback why placement fails, there is no other option
* than to try a few times before concluding it does not work.