mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 10:30:28 +00:00
(svn r24185) -Codechange: Deduplicate some only partly deduplicated code.
This commit is contained in:
parent
e2ad59fbe1
commit
789c95d4b8
@ -1581,6 +1581,25 @@ static CommandCost CheckIfFarEnoughFromConflictingIndustry(TileIndex tile, int t
|
|||||||
return CommandCost();
|
return CommandCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Put an industry on the map.
|
||||||
* @param i Just allocated poolitem, mostly empty.
|
* @param i Just allocated poolitem, mostly empty.
|
||||||
@ -1867,17 +1886,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((flags & DC_EXEC) && ind != NULL && _game_mode != GM_EDITOR) {
|
if ((flags & DC_EXEC) && ind != NULL && _game_mode != GM_EDITOR) {
|
||||||
/* Created a new industry in-game, advertise the event. */
|
AdvertiseIndustryOpening(ind);
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return CommandCost(EXPENSES_OTHER, indspec->GetConstructionCost());
|
return CommandCost(EXPENSES_OTHER, indspec->GetConstructionCost());
|
||||||
@ -1975,25 +1984,6 @@ static uint GetNumberOfIndustries()
|
|||||||
return ScaleByMapSize(numof_industry_table[difficulty]);
|
return ScaleByMapSize(numof_industry_table[difficulty]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
* Try to place the industry in the game.
|
||||||
* Since there is no feedback why placement fails, there is no other option
|
* Since there is no feedback why placement fails, there is no other option
|
||||||
|
Loading…
Reference in New Issue
Block a user