OpenTTD Source  20241108-master-g80f628063a
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, NewsType type, NewsFlag flags, NewsReferenceType reftype1=NR_NONE, uint32_t ref1=UINT32_MAX, NewsReferenceType reftype2=NR_NONE, uint32_t ref2=UINT32_MAX, const NewsAllocatedData *data=nullptr)
 Add a new newsitem to be shown. More...
 
void AddCompanyNewsItem (StringID string, CompanyNewsInformation *cni)
 
void AddVehicleNewsItem (StringID string, NewsType type, VehicleID vehicle, StationID station=INVALID_STATION)
 Adds a newsitem referencing a vehicle. More...
 
void AddVehicleAdviceNewsItem (StringID string, VehicleID vehicle)
 Adds a vehicle-advice news item. More...
 
void AddTileNewsItem (StringID string, NewsType type, TileIndex tile, const NewsAllocatedData *data=nullptr, StationID station=INVALID_STATION)
 
void AddIndustryNewsItem (StringID string, NewsType type, IndustryID industry, const NewsAllocatedData *data=nullptr)
 
void NewsLoop ()
 
void InitNewsItemStructs ()
 Initialize the news-items data structures.
 
const NewsItemGetStatusbarNews ()
 Get pointer to the current status bar news item. More...
 
void DeleteInvalidEngineNews ()
 Remove engine announcements for invalid engines.
 
void DeleteVehicleNews (VehicleID vid, StringID news)
 Delete a news item type about a vehicle. More...
 
void DeleteStationNews (StationID sid)
 Remove news regarding given station so there are no 'unknown station now accepts Mail' or 'First train arrived at unknown station' news items. More...
 
void DeleteIndustryNews (IndustryID iid)
 Remove news regarding given industry. More...
 

Detailed Description

Functions related to news.

Definition in file news_func.h.

Function Documentation

◆ AddNewsItem()

void AddNewsItem ( StringID  string,
NewsType  type,
NewsFlag  flags,
NewsReferenceType  reftype1,
uint32_t  ref1,
NewsReferenceType  reftype2,
uint32_t  ref2,
const NewsAllocatedData data 
)

Add a new newsitem to be shown.

Parameters
stringString to display
typenews category
flagsdisplay flags for the news
reftype1Type of ref1
ref1Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news, and for deleting the news when the object is deleted.
reftype2Type of ref2
ref2Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news when the object is deleted.
dataPointer to data that must be released once the news message is cleared.
See also
NewsSubtype

Definition at line 829 of file news_gui.cpp.

Referenced by AddVehicleAdviceNewsItem(), Subsidy::AwardTo(), CmdCustomNewsItem(), CreateSubsidy(), NewVehicleAvailable(), ShowRejectOrAcceptNews(), and TownActionRoadRebuild().

◆ AddVehicleAdviceNewsItem()

void AddVehicleAdviceNewsItem ( StringID  string,
VehicleID  vehicle 
)
inline

Adds a vehicle-advice news item.

Warning
DParam 0 must reference the vehicle!

Definition at line 40 of file news_func.h.

References AddNewsItem(), NF_INCOLOUR, NF_SMALL, NF_VEHICLE_PARAM0, NR_VEHICLE, and NT_ADVICE.

Referenced by AgeVehicle(), AircraftHandleDestTooFar(), BuildReplacementVehicle(), and Vehicle::HandlePathfindingResult().

◆ AddVehicleNewsItem()

void AddVehicleNewsItem ( StringID  string,
NewsType  type,
VehicleID  vehicle,
StationID  station = INVALID_STATION 
)
inline

Adds a newsitem referencing a vehicle.

Warning
The DParams may not reference the vehicle due to autoreplace stuff. See AddVehicleAdviceNewsItem for how that can be done.

Definition at line 30 of file news_func.h.

Referenced by RoadVehArrivesAt(), ShipArrivesAt(), and TrainEnterStation().

◆ DeleteIndustryNews()

void DeleteIndustryNews ( IndustryID  iid)

Remove news regarding given industry.

Parameters
iidindustry to remove news about

Definition at line 953 of file news_gui.cpp.

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

◆ DeleteStationNews()

void DeleteStationNews ( StationID  sid)

Remove news regarding given station so there are no 'unknown station now accepts Mail' or 'First train arrived at unknown station' news items.

Parameters
sidstation to remove news about

Definition at line 942 of file news_gui.cpp.

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

◆ DeleteVehicleNews()

void DeleteVehicleNews ( VehicleID  vid,
StringID  news 
)

Delete a news item type about a vehicle.

When the news item type is INVALID_STRING_ID all news about the vehicle gets deleted.

Parameters
vidThe vehicle to remove the news for.
newsThe news type to remove.

Definition at line 930 of file news_gui.cpp.

References DeleteNews(), INVALID_STRING_ID, NR_VEHICLE, NewsItem::ref1, NewsItem::ref2, NewsItem::reftype1, NewsItem::reftype2, and NewsItem::string_id.

Referenced by AircraftHandleDestTooFar(), DeleteOrderWarnings(), and Vehicle::HandlePathfindingResult().

◆ GetStatusbarNews()

const NewsItem* GetStatusbarNews ( )

Get pointer to the current status bar news item.

Returns
Pointer to the current status bar news item, or nullptr if there is none.

Definition at line 70 of file news_gui.cpp.

References _news, and _statusbar_news.

Referenced by ReadyForNextTickerItem().