mirror of https://github.com/OpenTTD/OpenTTD
(svn r24283) -Codechange: Add AddTileNewsItem function to preemptively deduplicate code.
parent
00b3ff80bb
commit
a0be398da9
|
@ -530,10 +530,7 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v)
|
||||||
|
|
||||||
Town *t = ClosestTownFromTile(v->dest_tile, UINT_MAX);
|
Town *t = ClosestTownFromTile(v->dest_tile, UINT_MAX);
|
||||||
SetDParam(0, t->index);
|
SetDParam(0, t->index);
|
||||||
AddNewsItem(STR_NEWS_DISASTER_BIG_UFO,
|
AddTileNewsItem(STR_NEWS_DISASTER_BIG_UFO, NS_ACCIDENT, v->tile);
|
||||||
NS_ACCIDENT,
|
|
||||||
NR_TILE,
|
|
||||||
v->tile);
|
|
||||||
|
|
||||||
if (!Vehicle::CanAllocateItem(2)) {
|
if (!Vehicle::CanAllocateItem(2)) {
|
||||||
delete v;
|
delete v;
|
||||||
|
@ -878,8 +875,7 @@ static void Disaster_CoalMine_Init()
|
||||||
FOR_ALL_INDUSTRIES(i) {
|
FOR_ALL_INDUSTRIES(i) {
|
||||||
if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CAN_SUBSIDENCE) && --index < 0) {
|
if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CAN_SUBSIDENCE) && --index < 0) {
|
||||||
SetDParam(0, i->town->index);
|
SetDParam(0, i->town->index);
|
||||||
AddNewsItem(STR_NEWS_DISASTER_COAL_MINE_SUBSIDENCE,
|
AddTileNewsItem(STR_NEWS_DISASTER_COAL_MINE_SUBSIDENCE, NS_ACCIDENT, i->location.tile + TileDiffXY(1, 1)); // keep the news, even when the mine closes
|
||||||
NS_ACCIDENT, NR_TILE, i->location.tile + TileDiffXY(1, 1)); // keep the news, even when the mine closes
|
|
||||||
|
|
||||||
{
|
{
|
||||||
TileIndex tile = i->location.tile;
|
TileIndex tile = i->location.tile;
|
||||||
|
|
|
@ -2627,10 +2627,11 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
|
||||||
SetDParam(0, i->index);
|
SetDParam(0, i->index);
|
||||||
}
|
}
|
||||||
/* and report the news to the user */
|
/* and report the news to the user */
|
||||||
AddNewsItem(str,
|
if (closeit) {
|
||||||
ns,
|
AddTileNewsItem(str, ns, i->location.tile + TileDiffXY(1, 1));
|
||||||
closeit ? NR_TILE : NR_INDUSTRY,
|
} else {
|
||||||
closeit ? i->location.tile + TileDiffXY(1, 1) : i->index);
|
AddIndustryNewsItem(str, ns, i->index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,11 @@ static inline void AddVehicleAdviceNewsItem(StringID string, VehicleID vehicle)
|
||||||
AddNewsItem(string, NS_ADVICE, NR_VEHICLE, vehicle);
|
AddNewsItem(string, NS_ADVICE, NR_VEHICLE, vehicle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void AddTileNewsItem(StringID string, NewsSubtype subtype, TileIndex tile, void *free_data = NULL)
|
||||||
|
{
|
||||||
|
AddNewsItem(string, subtype, NR_TILE, tile, NR_NONE, UINT32_MAX, free_data);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void AddIndustryNewsItem(StringID string, NewsSubtype subtype, IndustryID industry)
|
static inline void AddIndustryNewsItem(StringID string, NewsSubtype subtype, IndustryID industry)
|
||||||
{
|
{
|
||||||
AddNewsItem(string, subtype, NR_INDUSTRY, industry);
|
AddNewsItem(string, subtype, NR_INDUSTRY, industry);
|
||||||
|
|
|
@ -1694,7 +1694,7 @@ CommandCost CmdFoundTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||||
SetDParamStr(0, cn);
|
SetDParamStr(0, cn);
|
||||||
SetDParam(1, t->index);
|
SetDParam(1, t->index);
|
||||||
|
|
||||||
AddNewsItem(STR_NEWS_NEW_TOWN, NS_INDUSTRY_OPEN, NR_TILE, tile, NR_NONE, UINT32_MAX, cn);
|
AddTileNewsItem(STR_NEWS_NEW_TOWN, NS_INDUSTRY_OPEN, tile, cn);
|
||||||
AI::BroadcastNewEvent(new ScriptEventTownFounded(t->index));
|
AI::BroadcastNewEvent(new ScriptEventTownFounded(t->index));
|
||||||
Game::NewEvent(new ScriptEventTownFounded(t->index));
|
Game::NewEvent(new ScriptEventTownFounded(t->index));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue