# news_func.h File Reference

Functions related to news. More...

`#include "news_type.h"`
`#include "vehicle_type.h"`
`#include "station_type.h"`
`#include "industry_type.h"`

Go to the source code of this file.

## Functions

void | AddNewsItem (StringID string, NewsSubtype subtype, NewsReferenceType reftype1=NR_NONE, uint32 ref1=UINT32_MAX, NewsReferenceType reftype2=NR_NONE, uint32 ref2=UINT32_MAX, void *free_data=NULL)
| Add a new newsitem to be shown.
static void | AddCompanyNewsItem (StringID string, NewsSubtype subtype, CompanyNewsInformation *cni)
static void | AddVehicleNewsItem (StringID string, NewsSubtype subtype, VehicleID vehicle, StationID station=INVALID_STATION)
| Adds a newsitem referencing a vehicle.
static void | AddIndustryNewsItem (StringID string, NewsSubtype subtype, IndustryID industry)
void | NewsLoop ()
void | InitNewsItemStructs ()
| Initialize the news-items data structures.
void | DeleteVehicleNews (VehicleID vid, StringID news)
| Delete a news item type about a vehicle if the news item type is INVALID_STRING_ID all news about the vehicle get deleted.
void | DeleteStationNews (StationID sid)
| Delete news associated with given station.
void | DeleteIndustryNews (IndustryID iid)
| Delete news associated with given station.

## Variables

const NewsItem * | _statusbar_news_item
bool | _news_ticker_sound
| Make a ticker sound when a news item is published.
NewsTypeData | _news_type_data []
| Per-NewsType data.

## Detailed Description

Functions related to news.

Definition in file news_func.h.

## Function Documentation

void AddNewsItem | ( | StringID | string,
|  | NewsSubtype | subtype,
|  | NewsReferenceType | reftype1,
|  | uint32 | ref1,
|  | NewsReferenceType | reftype2,
|  | uint32 | ref2,
|  | void * | free_data |
| ) |  |  |

Add a new newsitem to be shown.

Parameters:

  | string | String to display
  | subtype | news category, any of the NewsSubtype enums (NS_)
  | reftype1 | Type of ref1
  | ref1 | Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news, and for deleteing the news when the object is deleted.
  | reftype2 | Type of ref2
  | ref2 | Reference 2 to some object: Used for scrolling after clicking on the news, and for deleteing the news when the object is deleted.
  | free_data | Pointer to data that must be freed once the news message is cleared

See also:
  NewsSubtype

Definition at line 663 of file news_gui.cpp.

References _cur_year, _date, _settings_client, _total_news, GUISettings::coloured_news_year, CopyOutDParam(), NewsItem::date, NewsSubtypeData::flags, NewsItem::flags, NewsItem::free_data, ClientSettings::gui, lengthof, NewsItem::next, NF_INCOLOUR, NewsItem::prev, NewsItem::ref1, NewsItem::ref2, NewsItem::reftype1, NewsItem::reftype2, SetWindowDirty(), NewsItem::string_id, and NewsItem::subtype.

Referenced by AddVehicleNewsItem(), Subsidy::AwardTo(), ChangeIndustryProduction(), CheckSwitchToEuro(), CmdFoundTown(), Disaster_CoalMine_Init(), DisasterTick_Big_Ufo(), and ShowRejectOrAcceptNews().

static void AddVehicleNewsItem | ( | StringID | string,
|  | NewsSubtype | subtype,
|  | VehicleID | vehicle,
|  | StationID | station = `INVALID_STATION` |
| ) |  |  | `[inline, static]`

Adds a newsitem referencing a vehicle.

Warning:
  Be careful! Vehicles are a special case, as news are kept when vehicles are autoreplaced/renewed. You have to make sure, ChangeVehicleNews catches the DParams of your message. This is NOT ensured by the references.

Definition at line 36 of file news_func.h.

References AddNewsItem(), NR_NONE, NR_STATION, and NR_VEHICLE.

Referenced by AircraftEntersTerminal(), CheckOrders(), CheckTrainCollision(), DisasterTick_Ufo(), and DisasterTick_Zeppeliner().

void DeleteIndustryNews | ( | IndustryID | iid | ) |

Delete news associated with given station.

Delete news associated with given station.

Parameters:

  | iid | industry to remove news about

Definition at line 767 of file news_gui.cpp.

References DeleteNewsItem(), NewsItem::next, NR_INDUSTRY, NewsItem::ref1, NewsItem::ref2, NewsItem::reftype1, and NewsItem::reftype2.

void DeleteStationNews | ( | StationID | sid | ) |

Delete news associated with given station.

Delete news associated with given station.

Parameters:

  | sid | station to remove news about

Definition at line 751 of file news_gui.cpp.

References DeleteNewsItem(), NewsItem::next, NR_STATION, NewsItem::ref1, NewsItem::ref2, NewsItem::reftype1, and NewsItem::reftype2.

Referenced by Station::~Station().