summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-03-28 08:53:36 +0000
committerrubidium <rubidium@openttd.org>2008-03-28 08:53:36 +0000
commiteeabab4555bf20ea9769bfea05c1fc278a493fa3 (patch)
tree6ac53730ac3371086562388c2590d8323adb6b80
parentd8cfb4f064d5492770d3325ef6e288b630e34e7c (diff)
downloadopenttd-eeabab4555bf20ea9769bfea05c1fc278a493fa3.tar.xz
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
-rw-r--r--src/aircraft_cmd.cpp9
-rw-r--r--src/autoreplace_cmd.cpp6
-rw-r--r--src/currency.cpp4
-rw-r--r--src/disaster_cmd.cpp14
-rw-r--r--src/economy.cpp29
-rw-r--r--src/engine.cpp4
-rw-r--r--src/engine_gui.cpp6
-rw-r--r--src/industry_cmd.cpp10
-rw-r--r--src/main_gui.cpp2
-rw-r--r--src/misc.cpp2
-rw-r--r--src/news.h122
-rw-r--r--src/news_func.h29
-rw-r--r--src/news_gui.cpp275
-rw-r--r--src/news_type.h96
-rw-r--r--src/openttd.cpp2
-rw-r--r--src/openttd.h1
-rw-r--r--src/order_cmd.cpp4
-rw-r--r--src/players.cpp6
-rw-r--r--src/roadveh_cmd.cpp14
-rw-r--r--src/settings.cpp2
-rw-r--r--src/ship_cmd.cpp7
-rw-r--r--src/station.cpp1
-rw-r--r--src/station_cmd.cpp4
-rw-r--r--src/strings.cpp1
-rw-r--r--src/town_cmd.cpp4
-rw-r--r--src/train_cmd.cpp13
-rw-r--r--src/vehicle.cpp8
-rw-r--r--src/water_cmd.cpp4
-rw-r--r--src/window_gui.h10
29 files changed, 334 insertions, 355 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index c15ad0e0f..65654e1a2 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -13,7 +13,7 @@
#include "depot.h"
#include "engine.h"
#include "station.h"
-#include "news.h"
+#include "news_func.h"
#include "aircraft.h"
#include "airport.h"
#include "vehicle_gui.h"
@@ -1465,7 +1465,7 @@ static void CrashAirplane(Vehicle *v)
SetDParam(1, st->index);
AddNewsItem(newsitem,
- NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0),
+ NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, DNC_NONE,
v->index,
0);
@@ -1505,15 +1505,12 @@ static void AircraftEntersTerminal(Vehicle *v)
/* Check if station was ever visited before */
if (!(st->had_vehicle_of_type & HVOT_AIRCRAFT)) {
- uint32 flags;
-
st->had_vehicle_of_type |= HVOT_AIRCRAFT;
SetDParam(0, st->index);
/* show newsitem of celebrating citizens */
- flags = (v->owner == _local_player) ? NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_PLAYER, 0) : NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_OTHER, 0);
AddNewsItem(
STR_A033_CITIZENS_CELEBRATE_FIRST,
- flags,
+ NM_THIN, NF_VIEWPORT | NF_VEHICLE, (v->owner == _local_player) ? NT_ARRIVAL_PLAYER : NT_ARRIVAL_OTHER, DNC_NONE,
v->index,
0);
}
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index ae49128d7..58e38a39d 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -4,7 +4,7 @@
#include "openttd.h"
#include "roadveh.h"
#include "ship.h"
-#include "news.h"
+#include "news_func.h"
#include "player_func.h"
#include "engine.h"
#include "debug.h"
@@ -377,7 +377,7 @@ CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs)
default: NOT_REACHED(); message = 0; break;
}
- AddNewsItem(message, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), v->index, 0);
+ AddNewsItem(message, NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, DNC_NONE, v->index, 0);
}
if (stopped) v->vehstatus &= ~VS_STOPPED;
if (display_costs) _current_player = OWNER_NONE;
@@ -408,7 +408,7 @@ CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs)
if (w == NULL) {
// we failed to make the train short enough
SetDParam(0, v->unitnumber);
- AddNewsItem(STR_TRAIN_TOO_LONG_AFTER_REPLACEMENT, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), v->index, 0);
+ AddNewsItem(STR_TRAIN_TOO_LONG_AFTER_REPLACEMENT, NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE, v->index, 0);
break;
}
temp = w;
diff --git a/src/currency.cpp b/src/currency.cpp
index db90fa1b0..d732bcbfb 100644
--- a/src/currency.cpp
+++ b/src/currency.cpp
@@ -5,7 +5,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "currency.h"
-#include "news.h"
+#include "news_func.h"
#include "settings_type.h"
#include "date_func.h"
@@ -154,7 +154,7 @@ void CheckSwitchToEuro()
_currency_specs[_opt.currency].to_euro != CF_ISEURO &&
_cur_year >= _currency_specs[_opt.currency].to_euro) {
_opt.currency = 2; // this is the index of euro above.
- AddNewsItem(STR_EURO_INTRODUCE, NEWS_FLAGS(NM_NORMAL, 0, NT_ECONOMY, 0), 0, 0);
+ AddNewsItem(STR_EURO_INTRODUCE, NM_NORMAL, NF_NONE, NT_ECONOMY, DNC_NONE, 0, 0);
}
}
diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp
index 4981aa31c..12d9f649d 100644
--- a/src/disaster_cmd.cpp
+++ b/src/disaster_cmd.cpp
@@ -24,7 +24,7 @@
#include "station_map.h"
#include "command_func.h"
#include "tile_cmd.h"
-#include "news.h"
+#include "news_func.h"
#include "station.h"
#include "waypoint.h"
#include "town.h"
@@ -233,7 +233,7 @@ static void DisasterTick_Zeppeliner(Vehicle *v)
SetDParam(0, GetStationIndex(tile));
AddNewsItem(STR_B000_ZEPPELIN_DISASTER_AT,
- NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, 0),
+ NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, DNC_NONE,
v->index,
0);
}
@@ -366,7 +366,7 @@ static void DisasterTick_Ufo(Vehicle *v)
u->vehstatus |= VS_CRASHED;
AddNewsItem(STR_B001_ROAD_VEHICLE_DESTROYED,
- NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, 0),
+ NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, DNC_NONE,
u->index,
0);
}
@@ -441,7 +441,7 @@ static void DisasterTick_Airplane(Vehicle *v)
DestructIndustry(i);
SetDParam(0, i->town->index);
- AddNewsItem(STR_B002_OIL_REFINERY_EXPLOSION, NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, 0), i->xy, 0);
+ AddNewsItem(STR_B002_OIL_REFINERY_EXPLOSION, NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, DNC_NONE, i->xy, 0);
SndPlayTileFx(SND_12_EXPLOSION, i->xy);
}
} else if (v->current_order.dest == 0) {
@@ -514,7 +514,7 @@ static void DisasterTick_Helicopter(Vehicle *v)
DestructIndustry(i);
SetDParam(0, i->town->index);
- AddNewsItem(STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS, NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, 0), i->xy, 0);
+ AddNewsItem(STR_B003_FACTORY_DESTROYED_IN_SUSPICIOUS, NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, DNC_NONE, i->xy, 0);
SndPlayTileFx(SND_12_EXPLOSION, i->xy);
}
} else if (v->current_order.dest == 0) {
@@ -599,7 +599,7 @@ static void DisasterTick_Big_Ufo(Vehicle *v)
t = ClosestTownFromTile(v->dest_tile, (uint)-1);
SetDParam(0, t->index);
AddNewsItem(STR_B004_UFO_LANDS_NEAR,
- NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, 0),
+ NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, DNC_NONE,
v->tile,
0);
@@ -977,7 +977,7 @@ static void Disaster_CoalMine_Init()
if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CAN_SUBSIDENCE) && --index < 0) {
SetDParam(0, i->town->index);
AddNewsItem(STR_B005_COAL_MINE_SUBSIDENCE_LEAVES,
- NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, 0), i->xy + TileDiffXY(1, 1), 0);
+ NM_THIN, NF_VIEWPORT | NF_TILE, NT_ACCIDENT, DNC_NONE, i->xy + TileDiffXY(1, 1), 0);
{
TileIndex tile = i->xy;
diff --git a/src/economy.cpp b/src/economy.cpp
index 643047764..70f0d8849 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -6,7 +6,6 @@
#include "openttd.h"
#include "currency.h"
#include "landscape.h"
-#include "news.h"
#include "player_base.h"
#include "player_func.h"
#include "station.h"
@@ -14,6 +13,7 @@
#include "saveload.h"
#include "industry.h"
#include "town.h"
+#include "news_func.h"
#include "network/network.h"
#include "engine.h"
#include "network/network_data.h"
@@ -513,15 +513,15 @@ static void PlayersCheckBankrupt(Player *p)
switch (p->quarters_of_bankrupcy) {
case 2:
- AddNewsItem( (StringID)(owner | NB_BTROUBLE),
- NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
+ AddNewsItem((StringID)(owner | NB_BTROUBLE),
+ NM_CALLBACK, NF_NONE, NT_COMPANY_INFO, DNC_BANKRUPCY, 0, 0);
break;
case 3: {
/* XXX - In multiplayer, should we ask other players if it wants to take
over when it is a human company? -- TrueLight */
if (IsHumanPlayer(owner)) {
- AddNewsItem( (StringID)(owner | NB_BTROUBLE),
- NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
+ AddNewsItem((StringID)(owner | NB_BTROUBLE),
+ NM_CALLBACK, NF_NONE, NT_COMPANY_INFO, DNC_BANKRUPCY, 0, 0);
break;
}
@@ -542,7 +542,7 @@ static void PlayersCheckBankrupt(Player *p)
/* Show bankrupt news */
SetDParam(0, p->index);
- AddNewsItem( (StringID)(owner | NB_BBANKRUPT), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
+ AddNewsItem((StringID)(owner | NB_BBANKRUPT), NM_CALLBACK, NF_NONE, NT_COMPANY_INFO, DNC_BANKRUPCY, 0, 0);
if (IsHumanPlayer(owner)) {
/* XXX - If we are in offline mode, leave the player playing. Eg. there
@@ -568,11 +568,10 @@ static void PlayersCheckBankrupt(Player *p)
}
}
-void DrawNewsBankrupcy(Window *w)
+void DrawNewsBankrupcy(Window *w, const NewsItem *ni)
{
DrawNewsBorder(w);
- const NewsItem *ni = WP(w, news_d).ni;
Player *p = GetPlayer((PlayerID)GB(ni->string_id, 0, 4));
DrawPlayerFace(p->face, p->player_color, 2, 23);
GfxFillRect(3, 23, 3 + 91, 23 + 118, PALETTE_TO_STRUCT_GREY | (1 << USE_COLORTABLE));
@@ -786,10 +785,10 @@ static void HandleEconomyFluctuations()
if (--_economy.fluct == 0) {
_economy.fluct = -(int)GB(Random(), 0, 2);
- AddNewsItem(STR_7073_WORLD_RECESSION_FINANCIAL, NEWS_FLAGS(NM_NORMAL,0,NT_ECONOMY,0), 0, 0);
+ AddNewsItem(STR_7073_WORLD_RECESSION_FINANCIAL, NM_NORMAL, NF_NONE, NT_ECONOMY, DNC_NONE, 0, 0);
} else if (_economy.fluct == -12) {
_economy.fluct = GB(Random(), 0, 8) + 312;
- AddNewsItem(STR_7074_RECESSION_OVER_UPTURN_IN, NEWS_FLAGS(NM_NORMAL,0,NT_ECONOMY,0), 0, 0);
+ AddNewsItem(STR_7074_RECESSION_OVER_UPTURN_IN, NM_NORMAL, NF_NONE, NT_ECONOMY, DNC_NONE, 0, 0);
}
}
@@ -1129,14 +1128,14 @@ static void SubsidyMonthlyHandler()
if (s->age == 12-1) {
pair = SetupSubsidyDecodeParam(s, 1);
- AddNewsItem(STR_202E_OFFER_OF_SUBSIDY_EXPIRED, NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_SUBSIDIES, 0), pair.a, pair.b);
+ AddNewsItem(STR_202E_OFFER_OF_SUBSIDY_EXPIRED, NM_NORMAL, NF_TILE, NT_SUBSIDIES, DNC_NONE, pair.a, pair.b);
s->cargo_type = CT_INVALID;
modified = true;
} else if (s->age == 2*12-1) {
st = GetStation(s->to);
if (st->owner == _local_player) {
pair = SetupSubsidyDecodeParam(s, 1);
- AddNewsItem(STR_202F_SUBSIDY_WITHDRAWN_SERVICE, NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_SUBSIDIES, 0), pair.a, pair.b);
+ AddNewsItem(STR_202F_SUBSIDY_WITHDRAWN_SERVICE, NM_NORMAL, NF_TILE, NT_SUBSIDIES, DNC_NONE, pair.a, pair.b);
}
s->cargo_type = CT_INVALID;
modified = true;
@@ -1175,7 +1174,7 @@ static void SubsidyMonthlyHandler()
if (!CheckSubsidyDuplicate(s)) {
s->age = 0;
pair = SetupSubsidyDecodeParam(s, 0);
- AddNewsItem(STR_2030_SERVICE_SUBSIDY_OFFERED, NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_SUBSIDIES, 0), pair.a, pair.b);
+ AddNewsItem(STR_2030_SERVICE_SUBSIDY_OFFERED, NM_NORMAL, NF_TILE, NT_SUBSIDIES, DNC_NONE, pair.a, pair.b);
modified = true;
break;
}
@@ -1392,7 +1391,7 @@ static bool CheckSubsidised(Station *from, Station *to, CargoID cargo_type)
SetDParam(0, _current_player);
AddNewsItem(
STR_2031_SERVICE_SUBSIDY_AWARDED + _opt.diff.subsidy_multiplier,
- NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_SUBSIDIES, 0),
+ NM_NORMAL, NF_TILE, NT_SUBSIDIES, DNC_NONE,
pair.a, pair.b
);
@@ -1829,7 +1828,7 @@ static void DoAcquireCompany(Player *p)
SetDParam(0, p->index);
SetDParam(1, p->bankrupt_value);
- AddNewsItem( (StringID)(_current_player | NB_BMERGER), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
+ AddNewsItem((StringID)(_current_player | NB_BMERGER), NM_CALLBACK, NF_NONE, NT_COMPANY_INFO, DNC_BANKRUPCY, 0, 0);
/* original code does this a little bit differently */
PlayerID pi = p->index;
diff --git a/src/engine.cpp b/src/engine.cpp
index 699486c1e..7f2c77054 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -9,7 +9,7 @@
#include "player_base.h"
#include "player_func.h"
#include "command_func.h"
-#include "news.h"
+#include "news_func.h"
#include "saveload.h"
#include "variables.h"
#include "train.h"
@@ -338,7 +338,7 @@ static void NewVehicleAvailable(Engine *e)
if (p->is_active) SetBit(p->avail_roadtypes, HasBit(EngInfo(index)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
}
}
- AddNewsItem(index, NEWS_FLAGS(NM_CALLBACK, 0, NT_NEW_VEHICLES, DNC_VEHICLEAVAIL), 0, 0);
+ AddNewsItem(index, NM_CALLBACK, NF_NONE, NT_NEW_VEHICLES, DNC_VEHICLEAVAIL, 0, 0);
}
void EnginesMonthlyLoop()
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index 51bfc3076..4611e700c 100644
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -10,7 +10,7 @@
#include "engine.h"
#include "command_func.h"
#include "economy_func.h"
-#include "news.h"
+#include "news_func.h"
#include "variables.h"
#include "newgrf_engine.h"
#include "strings_func.h"
@@ -182,11 +182,11 @@ StringID GetNewsStringNewVehicleAvail(const NewsItem *ni)
return STR_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE;
}
-void DrawNewsNewVehicleAvail(Window *w)
+void DrawNewsNewVehicleAvail(Window *w, const NewsItem *ni)
{
DrawNewsBorder(w);
- EngineID engine = WP(w, news_d).ni->string_id;
+ EngineID engine = ni->string_id;
const DrawEngineInfo *dei = &_draw_engine_list[GetEngine(engine)->type];
SetDParam(0, GetEngineCategoryName(engine));
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 7b8d840e9..9dd1077ec 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -13,7 +13,7 @@
#include "command_func.h"
#include "industry.h"
#include "town.h"
-#include "news.h"
+#include "news_func.h"
#include "saveload.h"
#include "variables.h"
#include "genworld.h"
@@ -1641,7 +1641,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
SetDParam(1, ind->town->index);
}
AddNewsItem(indspec->new_industry_text,
- NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_OPENCLOSE, 0), ind->xy, 0);
+ NM_THIN, NF_VIEWPORT | NF_TILE, NT_OPENCLOSE, DNC_NONE, ind->xy, 0);
break;
}
}
@@ -1860,7 +1860,7 @@ static void MaybeNewIndustry(void)
SetDParam(1, ind->town->index);
}
AddNewsItem(ind_spc->new_industry_text,
- NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_OPENCLOSE, 0), ind->xy, 0);
+ NM_THIN, NF_VIEWPORT | NF_TILE, NT_OPENCLOSE, DNC_NONE, ind->xy, 0);
}
/**
@@ -2003,7 +2003,7 @@ static void ReportNewsProductionChangeIndustry(Industry *ind, CargoID type, int
SetDParam(1, ind->index);
AddNewsItem(
percent >= 0 ? STR_INDUSTRY_PROD_GOUP : STR_INDUSTRY_PROD_GODOWN,
- NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, nt, 0),
+ NM_THIN, NF_VIEWPORT | NF_TILE, nt, DNC_NONE,
ind->xy + TileDiffXY(1, 1), 0
);
}
@@ -2196,7 +2196,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
}
/* and report the news to the user */
AddNewsItem(str,
- NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, nt, 0),
+ NM_THIN, NF_VIEWPORT | NF_TILE, nt, DNC_NONE,
i->xy + TileDiffXY(1, 1), 0);
}
}
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 26c66013f..3bf1ed798 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -13,7 +13,7 @@
#include "textbuf_gui.h"
#include "viewport_func.h"
#include "command_func.h"
-#include "news.h"
+#include "news_func.h"
#include "town.h"
#include "console.h"
#include "signs.h"
diff --git a/src/misc.cpp b/src/misc.cpp
index 4d828c9b7..80fb667f0 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -6,7 +6,7 @@
#include "openttd.h"
#include "currency.h"
#include "landscape.h"
-#include "news.h"
+#include "news_func.h"
#include "saveload.h"
#include "engine.h"
#include "vehicle_gui.h"
diff --git a/src/news.h b/src/news.h
deleted file mode 100644
index 075378326..000000000
--- a/src/news.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* $Id$ */
-
-/** @file news.h */
-
-#ifndef NEWS_H
-#define NEWS_H
-
-#include "window_type.h"
-#include "vehicle_type.h"
-#include "tile_type.h"
-#include "date_type.h"
-#include "strings_type.h"
-
-struct NewsItem {
- StringID string_id; ///< Message text (sometimes also used for storing other info)
- uint16 duration; ///< Remaining time for showing this news message
- Date date; ///< Date of the news
- byte flags; ///< NewsFlags bits @see NewsFlags
- byte display_mode; ///< Display mode value @see NewsMode
- byte type; ///< News category @see NewsType
- byte callback; ///< Call-back function
-
- TileIndex data_a; ///< Reference to tile or vehicle
- TileIndex data_b; ///< Reference to second tile or vehicle
-
- uint64 params[10];
-};
-
-typedef bool ValidationProc ( uint data_a, uint data_b );
-typedef void DrawNewsCallbackProc(Window *w);
-typedef StringID GetNewsStringCallbackProc(const NewsItem *ni);
-
-/**
- * Macro for creating news flags.
- * @param mode (bits 0 - 7) Display_mode, one of the NewsMode enums (NM_)
- * @param flag (bits 8 - 15) OR-able news flags, any of the NewsFlags enums (NF_)
- * @param type (bits 16-23) News category, one of the NewsType enums (NT_)
- * @param cb (bits 24-31) Call-back function, one of the NewsCallback enums (DNC_) or 0 if no callback
- * @see NewsMode
- * @see NewsFlags
- * @see NewsType
- * @see NewsCallback
- * @see AddNewsItem
- */
-#define NEWS_FLAGS(mode, flag, type, cb) ((cb) << 24 | (type) << 16 | (flag) << 8 | (mode))
-
-void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b);
-void NewsLoop();
-void DrawNewsBorder(const Window *w);
-void InitNewsItemStructs();
-
-extern NewsItem _statusbar_news_item;
-extern uint32 _news_display_opt;
-extern bool _news_ticker_sound;
-
-/** Type of news. */
-enum NewsType {
- NT_ARRIVAL_PLAYER, ///< Cargo arrived for player
- NT_ARRIVAL_OTHER, ///< Cargo arrived for competitor
- NT_ACCIDENT, ///< An accident or disaster has occurred
- NT_COMPANY_INFO, ///< Company info (new companies, bankrupcy messages)
- NT_OPENCLOSE, ///< Opening and closing of industries
- NT_ECONOMY, ///< Economic changes (recession, industry up/dowm)
- NT_INDUSTRY_PLAYER, ///< Production changes of industry serviced by local player
- NT_INDUSTRY_OTHER, ///< Production changes of industry serviced by competitor(s)
- NT_INDUSTRY_NOBODY, ///< Other industry production changes
- NT_ADVICE, ///< Bits of news about vehicles of the player
- NT_NEW_VEHICLES, ///< New vehicle has become available
- NT_ACCEPTANCE, ///< A type of cargo is (no longer) accepted
- NT_SUBSIDIES, ///< News about subsidies (announcements, expirations, acceptance)
- NT_GENERAL, ///< General news (from towns)
- NT_END, ///< end-of-array marker
-};
-
-extern const char *_news_display_name[NT_END];
-
-/**
- * News mode.
- * @see NEWS_FLAGS
- */
-enum NewsMode {
- NM_SMALL = 0, ///< Show only a small popup informing us about vehicle age for example
- NM_NORMAL = 1, ///< Show a simple news message (height 170 pixels)
- NM_THIN = 2, ///< Show a simple news message (height 130 pixels)
- NM_CALLBACK = 3, ///< Do some special processing before displaying news message. Which callback to call is in NewsCallback
-};
-
-/**
- * Various OR-able news-item flags.
- * note: NF_INCOLOR is set automatically if needed
- * @see NEWS_FLAGS
- */
-enum NewsFlags {
- NF_VIEWPORT = (1 << 1), ///< Does the news message have a viewport? (ingame picture of happening)
- NF_TILE = (1 << 2), ///< When clicked on the news message scroll to a given tile? Tile is in data_a/data_b
- NF_VEHICLE = (1 << 3), ///< When clicked on the message scroll to the vehicle? VehicleID is in data_a
- NF_FORCE_BIG = (1 << 4), ///< Force the appearance of a news message if it has already been shown (internal)
- NF_INCOLOR = (1 << 5), ///< Show the newsmessage in colour, otherwise it defaults to black & white
-};
-
-/** Special news items */
-enum NewsCallback {
- DNC_VEHICLEAVAIL = 0, ///< Show new vehicle available message. StringID is EngineID
- DNC_BANKRUPCY = 1, ///< Show bankrupcy message. StringID is PlayerID (0-3) and NewsBankrupcy (4-7)
-};
-
-/** Kinds of bankrupcy */
-enum NewsBankrupcy {
- NB_BTROUBLE = (1 << 4), ///< Company is in trouble (warning)
- NB_BMERGER = (2 << 4), ///< Company has been bought by another company
- NB_BBANKRUPT = (3 << 4), ///< Company has gone bankrupt
- NB_BNEWCOMPANY = (4 << 4), ///< A new company has been started
-};
-
-/**
- * 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 DeleteVehicleNews(VehicleID, StringID news);
-
-#endif /* NEWS_H */
diff --git a/src/news_func.h b/src/news_func.h
new file mode 100644
index 000000000..97797db88
--- /dev/null
+++ b/src/news_func.h
@@ -0,0 +1,29 @@
+/* $Id$ */
+
+/** @file news_func.h Functions related to news. */
+
+#ifndef NEWS_FUNC_H
+#define NEWS_FUNC_H
+
+#include "news_type.h"
+#include "vehicle_type.h"
+
+void AddNewsItem(StringID string, NewsMode mode, NewsFlag flag, NewsType type, NewsCallback callback, uint data_a, uint data_b);
+void NewsLoop();
+void DrawNewsBorder(const Window *w);
+void InitNewsItemStructs();
+
+extern NewsItem _statusbar_news_item;
+extern uint32 _news_display_opt;
+extern bool _news_ticker_sound;
+
+extern const char *_news_display_name[NT_END];
+
+/**
+ * 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 DeleteVehicleNews(VehicleID, StringID news);
+
+#endif /* NEWS_FUNC_H */
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 1528ee38f..d927bfff7 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -6,7 +6,7 @@
#include "gui.h"
#include "window_gui.h"
#include "viewport_func.h"
-#include "news.h"
+#include "news_func.h"
#include "settings_type.h"
#include "transparency.h"
#include "strings_func.h"
@@ -60,6 +60,16 @@ static NewsID _current_news = INVALID_NEWS; ///< points to news item that should
static NewsID _oldest_news = 0; ///< points to first item in fifo queue
static NewsID _latest_news = INVALID_NEWS; ///< points to last item in fifo queue
+struct news_d {
+ uint16 follow_vehicle;
+ int32 scrollpos_x;
+ int32 scrollpos_y;
+ int32 dest_scrollpos_x;
+ int32 dest_scrollpos_y;
+ NewsItem *ni;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d));
+
/** Forced news item.
* Users can force an item by accessing the history or "last message".
* If the message being shown was forced by the user, its index is stored in
@@ -68,8 +78,8 @@ static NewsID _forced_news = INVALID_NEWS;
static byte _total_news = 0; ///< Number of news items in FIFO queue @see _news_items
-void DrawNewsNewVehicleAvail(Window *w);
-void DrawNewsBankrupcy(Window *w);
+void DrawNewsNewVehicleAvail(Window *w, const NewsItem *ni);
+void DrawNewsBankrupcy(Window *w, const NewsItem *ni);
static void MoveToNextItem();
StringID GetNewsStringNewVehicleAvail(const NewsItem *ni);
@@ -117,118 +127,118 @@ void DrawNewsBorder(const Window *w)
static void NewsWindowProc(Window *w, WindowEvent *e)
{
switch (e->event) {
- case WE_CREATE: { // If chatbar is open at creation time, we need to go above it
- const Window *w1 = FindWindowById(WC_SEND_NETWORK_MSG, 0);
- w->message.msg = (w1 != NULL) ? w1->height : 0;
- } break;
+ case WE_CREATE: { // If chatbar is open at creation time, we need to go above it
+ const Window *w1 = FindWindowById(WC_SEND_NETWORK_MSG, 0);
+ w->message.msg = (w1 != NULL) ? w1->height : 0;
+ } break;
- case WE_PAINT: {
- const NewsItem *ni = WP(w, news_d).ni;
- ViewPort *vp;
-
- switch (ni->display_mode) {
- case NM_NORMAL:
- case NM_THIN: {
- DrawNewsBorder(w);
-
- DrawString(2, 1, STR_00C6, TC_FROMSTRING);
-
- SetDParam(0, ni->date);
- DrawStringRightAligned(428, 1, STR_01FF, TC_FROMSTRING);
-
- if (!(ni->flags & NF_VIEWPORT)) {
- CopyInDParam(0, ni->params, lengthof(ni->params));
- DrawStringMultiCenter(215, ni->display_mode == NM_NORMAL ? 76 : 56,
- ni->string_id, w->width - 4);
- } else {
- /* Back up transparency options to draw news view */
- TransparencyOptionBits to_backup = _transparency_opt;
- _transparency_opt = 0;
- DrawWindowViewport(w);
- _transparency_opt = to_backup;
-
- /* Shade the viewport into gray, or color*/
- vp = w->viewport;
- GfxFillRect(vp->left - w->left, vp->top - w->top,
- vp->left - w->left + vp->width - 1, vp->top - w->top + vp->height - 1,
- (ni->flags & NF_INCOLOR ? PALETTE_TO_TRANSPARENT : PALETTE_TO_STRUCT_GREY) | (1 << USE_COLORTABLE)
- );
-
- CopyInDParam(0, ni->params, lengthof(ni->params));
- DrawStringMultiCenter(w->width / 2, 20, ni->string_id, w->width - 4);
+ case WE_PAINT: {
+ const NewsItem *ni = WP(w, news_d).ni;
+ ViewPort *vp;
+
+ switch (ni->display_mode) {
+ case NM_NORMAL:
+ case NM_THIN: {
+ DrawNewsBorder(w);
+
+ DrawString(2, 1, STR_00C6, TC_FROMSTRING);
+
+ SetDParam(0, ni->date);
+ DrawStringRightAligned(428, 1, STR_01FF, TC_FROMSTRING);
+
+ if (!(ni->flags & NF_VIEWPORT)) {
+ CopyInDParam(0, ni->params, lengthof(ni->params));
+ DrawStringMultiCenter(215, ni->display_mode == NM_NORMAL ? 76 : 56,
+ ni->string_id, w->width - 4);
+ } else {
+ /* Back up transparency options to draw news view */
+ TransparencyOptionBits to_backup = _transparency_opt;
+ _transparency_opt = 0;
+ DrawWindowViewport(w);
+ _transparency_opt = to_backup;
+
+ /* Shade the viewport into gray, or color*/
+ vp = w->viewport;
+ GfxFillRect(vp->left - w->left, vp->top - w->top,
+ vp->left - w->left + vp->width - 1, vp->top - w->top + vp->height - 1,
+ (ni->flags & NF_INCOLOR ? PALETTE_TO_TRANSPARENT : PALETTE_TO_STRUCT_GREY) | (1 << USE_COLORTABLE)
+ );
+
+ CopyInDParam(0, ni->params, lengthof(ni->params));
+ DrawStringMultiCenter(w->width / 2, 20, ni->string_id, w->width - 4);
+ }
+ break;
}
- break;
- }
- case NM_CALLBACK: {
- _draw_news_callback[ni->callback](w);
- break;
- }
+ case NM_CALLBACK: {
+ _draw_news_callback[ni->callback](w, ni);
+ break;
+ }
- default: {
- DrawWindowWidgets(w);
- if (!(ni->flags & NF_VIEWPORT)) {
- CopyInDParam(0, ni->params, lengthof(ni->params));
- DrawStringMultiCenter(140, 38, ni->string_id, 276);
- } else {
- DrawWindowViewport(w);
- CopyInDParam(0, ni->params, lengthof(ni->params));
- DrawStringMultiCenter(w->width / 2, w->height - 16, ni->string_id, w->width - 4);
+ default: {
+ DrawWindowWidgets(w);
+ if (!(ni->flags & NF_VIEWPORT)) {
+ CopyInDParam(0, ni->params, lengthof(ni->params));
+ DrawStringMultiCenter(140, 38, ni->string_id, 276);
+ } else {
+ DrawWindowViewport(w);
+ CopyInDParam(0, ni->params, lengthof(ni->params));
+ DrawStringMultiCenter(w->width / 2, w->height - 16, ni->string_id, w->width - 4);
+ }
+ break;
}
- break;
}
- }
- } break;
-
- case WE_CLICK: {
- switch (e->we.click.widget) {
- case 1: {
- NewsItem *ni = WP(w, news_d).ni;
- DeleteWindow(w);
- ni->duration = 0;
- _forced_news = INVALID_NEWS;
} break;
- case 0: {
- NewsItem *ni = WP(w, news_d).ni;
- if (ni->flags & NF_VEHICLE) {
- Vehicle *v = GetVehicle(ni->data_a);
- ScrollMainWindowTo(v->x_pos, v->y_pos);
- } else if (ni->flags & NF_TILE) {
- if (!ScrollMainWindowToTile(ni->data_a) && ni->data_b != 0)
- ScrollMainWindowToTile(ni->data_b);
+
+ case WE_CLICK: {
+ switch (e->we.click.widget) {
+ case 1: {
+ NewsItem *ni = WP(w, news_d).ni;
+ DeleteWindow(w);
+ ni->duration = 0;
+ _forced_news = INVALID_NEWS;
+ } break;
+ case 0: {
+ NewsItem *ni = WP(w, news_d).ni;
+ if (ni->flags & NF_VEHICLE) {
+ Vehicle *v = GetVehicle(ni->data_a);
+ ScrollMainWindowTo(v->x_pos, v->y_pos);
+ } else if (ni->flags & NF_TILE) {
+ if (!ScrollMainWindowToTile(ni->data_a) && ni->data_b != 0)
+ ScrollMainWindowToTile(ni->data_b);
+ }
+ } break;
}
} break;
- }
- } break;
- case WE_KEYPRESS:
- if (e->we.keypress.keycode == WKC_SPACE) {
- /* Don't continue. */
- e->we.keypress.cont = false;
- DeleteWindow(w);
- }
- break;
+ case WE_KEYPRESS:
+ if (e->we.keypress.keycode == WKC_SPACE) {
+ /* Don't continue. */
+ e->we.keypress.cont = false;
+ DeleteWindow(w);
+ }
+ break;
- case WE_MESSAGE: // The chatbar has notified us that is was either created or closed
- switch (e->we.message.msg) {
- case WE_CREATE: w->message.msg = e->we.message.wparam; break;
- case WE_DESTROY: w->message.msg = 0; break;
- }
- break;
+ case WE_MESSAGE: // The chatbar has notified us that is was either created or closed
+ switch (e->we.message.msg) {
+ case WE_CREATE: w->message.msg = e->we.message.wparam; break;
+ case WE_DESTROY: w->message.msg = 0; break;
+ }
+ break;
- case WE_TICK: { // Scroll up newsmessages from the bottom in steps of 4 pixels
- int diff;
- int y = max(w->top - 4, _screen.height - w->height - 12 - w->message.msg);
- if (y == w->top) return;
+ case WE_TICK: { // Scroll up newsmessages from the bottom in steps of 4 pixels
+ int diff;
+ int y = max(w->top - 4, _screen.height - w->height - 12 - w->message.msg);
+ if (y == w->top) return;
- if (w->viewport != NULL)
- w->viewport->top += y - w->top;
+ if (w->viewport != NULL)
+ w->viewport->top += y - w->top;
- diff = Delta(w->top, y);
- w->top = y;
+ diff = Delta(w->top, y);
+ w->top = y;
- SetDirtyBlocks(w->left, w->top - diff, w->left + w->width, w->top + w->height);
- } break;
+ SetDirtyBlocks(w->left, w->top - diff, w->left + w->width, w->top + w->height);
+ } break;
}
}
@@ -254,17 +264,15 @@ static inline NewsID decreaseIndex(NewsID i)
/**
* Add a new newsitem to be shown.
- * @param string String to display, can have special values based on parameter \a flags
- * @param flags various control bits that will show various news-types. See macro NEWS_FLAGS()
+ * @param string String to display, can have special values based on parameter \a display_mode
+ * @param display_mode, any of the NewsMode enums (NM_)
+ * @param flags any of the NewsFlag enums (NF_)
+ * @param type news category, any of the NewsType enums (NT_)
+ * @param callback news callback function, any of the NewsCallback enums (DNC_)
* @param data_a news-specific value based on news type
* @param data_b news-specific value based on news type
- * @note flags exists of 4 byte-sized extra parameters.
- * -# Bits 0 - 7 display_mode, any of the NewsMode enums (NM_)
- * -# Bits 8 - 15 news flags, any of the NewsFlags enums (NF_)
- * -# Bits 16 - 23 news category, any of the NewsType enums (NT_)
- * -# Bits 24 - 31 news callback function, any of the NewsCallback enums (DNC_)
*
- * If the display mode is NM_CALLBACK, special news is shown and parameter
+ * @note If the display mode is NM_CALLBACK, special news is shown and parameter
* \a string has a special meaning.
* - For DNC_TRAINAVAIL, DNC_ROADAVAIL, DNC_SHIPAVAIL, DNC_AIRCRAFTAVAIL messages: StringID is
* the index of the engine that is shown
@@ -274,11 +282,11 @@ static inline NewsID decreaseIndex(NewsID i)
* @see NewsBankrupcy
*
* @see NewsMode
- * @see NewsFlags
+ * @see NewsFlag
* @see NewsType
* @see NewsCallback
*/
-void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b)
+void AddNewsItem(StringID string, NewsMode display_mode, NewsFlag flags, NewsType type, NewsCallback callback, uint data_a, uint data_b)
{
NewsID l_news;
@@ -306,36 +314,33 @@ void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b)
_current_news, _oldest_news, _latest_news, _forced_news, _total_news);*/
/* Add news to _latest_news */
- {
- Window *w;
- NewsItem *ni = &_news_items[_latest_news];
- memset(ni, 0, sizeof(*ni));
-
- ni->string_id = string;
- ni->display_mode = (byte)flags;
- ni->flags = (byte)(flags >> 8);
-
- /* show this news message in color? */
- if (_cur_year >= _patches.colored_news_year) ni->flags |= NF_INCOLOR;
-
- ni->type = (byte)(flags >> 16);
- ni->callback = (byte)(flags >> 24);
- ni->data_a = data_a;
- ni->data_b = data_b;
- ni->date = _date;
- CopyOutDParam(ni->params, 0, lengthof(ni->params));
-
- w = FindWindowById(WC_MESSAGE_HISTORY, 0);
- if (w == NULL) return;
- SetWindowDirty(w);
- w->vscroll.count = _total_news;
- }
+ NewsItem *ni = &_news_items[_latest_news];
+ memset(ni, 0, sizeof(*ni));
+
+ ni->string_id = string;
+ ni->display_mode = display_mode;
+ ni->flags = flags;
+
+ /* show this news message in color? */
+ if (_cur_year >= _patches.colored_news_year) ni->flags |= NF_INCOLOR;
+
+ ni->type = type;
+ ni->callback = callback;
+ ni->data_a = data_a;
+ ni->data_b = data_b;
+ ni->date = _date;
+ CopyOutDParam(ni->params, 0, lengthof(ni->params));
+
+ Window *w = FindWindowById(WC_MESSAGE_HISTORY, 0);
+ if (w == NULL) return;
+ SetWindowDirty(w);
+ w->vscroll.count = _total_news;
}
/**
* Maximum age of news items.
- * Don't show item if it's older than x days, corresponds with NewsType in news.h
+ * Don't show item if it's older than x days, corresponds with NewsType in news_type.h
* @see NewsType
*/
static const byte _news_items_age[NT_END] = {
diff --git a/src/news_type.h b/src/news_type.h
new file mode 100644
index 000000000..a168eccb7
--- /dev/null
+++ b/src/news_type.h
@@ -0,0 +1,96 @@
+/* $Id$ */
+
+/** @file news_type.h Types related to news. */
+
+#ifndef NEWS_TYPE_H
+#define NEWS_TYPE_H
+
+#include "window_type.h"
+#include "date_type.h"
+#include "strings_type.h"
+
+/**
+ * Type of news.
+ */
+enum NewsType {
+ NT_ARRIVAL_PLAYER, ///< Cargo arrived for player
+ NT_ARRIVAL_OTHER, ///< Cargo arrived for competitor
+ NT_ACCIDENT, ///< An accident or disaster has occurred
+ NT_COMPANY_INFO, ///< Company info (new companies, bankrupcy messages)
+ NT_OPENCLOSE, ///< Opening and closing of industries
+ NT_ECONOMY, ///< Economic changes (recession, industry up/dowm)
+ NT_INDUSTRY_PLAYER, ///< Production changes of industry serviced by local player
+ NT_INDUSTRY_OTHER, ///< Production changes of industry serviced by competitor(s)
+ NT_INDUSTRY_NOBODY, ///< Other industry production changes
+ NT_ADVICE, ///< Bits of news about vehicles of the player
+ NT_NEW_VEHICLES, ///< New vehicle has become available
+ NT_ACCEPTANCE, ///< A type of cargo is (no longer) accepted
+ NT_SUBSIDIES, ///< News about subsidies (announcements, expirations, acceptance)
+ NT_GENERAL, ///< General news (from towns)
+ NT_END, ///< end-of-array marker
+};
+
+/**
+ * News mode.
+ */
+enum NewsMode {
+ NM_SMALL = 0, ///< Show only a small popup informing us about vehicle age for example
+ NM_NORMAL = 1, ///< Show a simple news message (height 170 pixels)
+ NM_THIN = 2, ///< Show a simple news message (height 130 pixels)
+ NM_CALLBACK = 3, ///< Do some special processing before displaying news message. Which callback to call is in NewsCallback
+};
+
+/**
+ * Various OR-able news-item flags.
+ * note: NF_INCOLOR is set automatically if needed
+ */
+enum NewsFlag {
+ NF_NONE = 0, ///< No flag is set.
+ NF_VIEWPORT = (1 << 1), ///< Does the news message have a viewport? (ingame picture of happening)
+ NF_TILE = (1 << 2), ///< When clicked on the news message scroll to a given tile? Tile is in data_a/data_b
+ NF_VEHICLE = (1 << 3), ///< When clicked on the message scroll to the vehicle? VehicleID is in data_a
+ NF_FORCE_BIG = (1 << 4), ///< Force the appearance of a news message if it has already been shown (internal)
+ NF_INCOLOR = (1 << 5), ///< Show the newsmessage in colour, otherwise it defaults to black & white
+};
+DECLARE_ENUM_AS_BIT_SET(NewsFlag);
+
+
+/**
+ * Special news items
+ */
+enum NewsCallback {
+ DNC_VEHICLEAVAIL = 0, ///< Show new vehicle available message. StringID is EngineID
+ DNC_BANKRUPCY = 1, ///< Show bankrupcy message. StringID is PlayerID (0-3) and NewsBankrupcy (4-7)
+ DNC_NONE = 0xFF, ///< No news callback.
+};
+
+/**
+ * Kinds of bankrupcy
+ */
+enum NewsBankrupcy {
+ NB_BTROUBLE, ///< Company is in trouble (warning)
+ NB_BMERGER, ///< Company has been bought by another company
+ NB_BBANKRUPT, ///< Company has gone bankrupt
+ NB_BNEWCOMPANY, ///< A new company has been started
+};
+
+struct NewsItem {
+ StringID string_id; ///< Message text (sometimes also used for storing other info)
+ uint16 duration; ///< Remaining time for showing this news message
+ Date date; ///< Date of the news
+ NewsFlag flags; ///< NewsFlags bits @see NewsFlag
+ NewsMode display_mode; ///< Display mode value @see NewsMode
+ NewsType type; ///< News category @see NewsType
+ NewsCallback callback; ///< Call-back function
+
+ uint data_a; ///< Reference to tile or vehicle
+ uint data_b; ///< Reference to second tile or vehicle
+
+ uint64 params[10];
+};
+
+typedef bool ValidationProc(uint data_a, uint data_b);
+typedef void DrawNewsCallbackProc(Window *w, const NewsItem *ni);
+typedef StringID GetNewsStringCallbackProc(const NewsItem *ni);
+
+#endif /* NEWS_TYPE_H */
diff --git a/src/openttd.cpp b/src/openttd.cpp
index d4dc25aaa..14412d8e4 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -28,7 +28,7 @@
#include "command_func.h"
#include "town.h"
#include "industry.h"
-#include "news.h"
+#include "news_func.h"
#include "engine.h"
#include "fileio.h"
#include "fios.h"
diff --git a/src/openttd.h b/src/openttd.h
index 1050d1679..ac3d94698 100644
--- a/src/openttd.h
+++ b/src/openttd.h
@@ -13,7 +13,6 @@ struct Depot;
struct Waypoint;
struct Station;
struct ViewPort;
-struct NewsItem;
struct DrawPixelInfo;
struct Group;
typedef byte VehicleOrderID; ///< The index of an order within its current vehicle (not pool related)
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 2085fb1f9..b968a2852 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -11,7 +11,7 @@
#include "command_func.h"
#include "station.h"
#include "player_func.h"
-#include "news.h"
+#include "news_func.h"
#include "saveload.h"
#include "vehicle_gui.h"
#include "cargotype.h"
@@ -1135,7 +1135,7 @@ void CheckOrders(const Vehicle* v)
SetDParam(0, v->unitnumber);
AddNewsItem(
message,
- NEWS_FLAGS(NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, 0),
+ NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE,
v->index,
0
);
diff --git a/src/players.cpp b/src/players.cpp
index 0e2bf5086..18df770bd 100644
--- a/src/players.cpp
+++ b/src/players.cpp
@@ -9,7 +9,7 @@
#include "player_gui.h"
#include "town.h"
#include "station.h"
-#include "news.h"
+#include "news_func.h"
#include "saveload.h"
#include "command_func.h"
#include "network/network.h"
@@ -336,7 +336,7 @@ set_name:;
if (!IsHumanPlayer(p->index)) {
SetDParam(0, t->index);
- AddNewsItem((StringID)(p->index | NB_BNEWCOMPANY), NEWS_FLAGS(NM_CALLBACK, NF_TILE, NT_COMPANY_INFO, DNC_BANKRUPCY), p->last_build_coordinate, 0);
+ AddNewsItem((StringID)(p->index | NB_BNEWCOMPANY), NM_CALLBACK, NF_TILE, NT_COMPANY_INFO, DNC_BANKRUPCY, p->last_build_coordinate, 0);
}
return;
}
@@ -902,7 +902,7 @@ CommandCost CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* Show the bankrupt news */
SetDParam(0, p->index);
- AddNewsItem( (StringID)(p->index | NB_BBANKRUPT), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
+ AddNewsItem((StringID)(p->index | NB_BBANKRUPT), NM_CALLBACK, NF_NONE, NT_COMPANY_INFO, DNC_BANKRUPCY, 0, 0);
/* Remove the company */
ChangeOwnershipOfPlayerItems(p->index, PLAYER_SPECTATOR);
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index d4cb02163..954e5900f 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -14,7 +14,7 @@
#include "engine.h"
#include "command_func.h"
#include "station.h"
-#include "news.h"
+#include "news_func.h"
#include "pathfind.h"
#include "npf.h"
#include "player_func.h"
@@ -699,7 +699,7 @@ static void RoadVehCrash(Vehicle *v)
AddNewsItem(
(pass == 1) ?
STR_9031_ROAD_VEHICLE_CRASH_DRIVER : STR_9032_ROAD_VEHICLE_CRASH_DIE,
- NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0),
+ NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, DNC_NONE,
v->index,
0
);
@@ -918,28 +918,22 @@ static void RoadVehArrivesAt(const Vehicle* v, Station* st)
if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) {
/* Check if station was ever visited before */
if (!(st->had_vehicle_of_type & HVOT_BUS)) {
- uint32 flags;
-
st->had_vehicle_of_type |= HVOT_BUS;
SetDParam(0, st->index);
- flags = (v->owner == _local_player) ? NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_PLAYER, 0) : NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_OTHER, 0);
AddNewsItem(
v->u.road.roadtype == ROADTYPE_ROAD ? STR_902F_CITIZENS_CELEBRATE_FIRST : STR_CITIZENS_CELEBRATE_FIRST_PASSENGER_TRAM,
- flags,
+ NM_THIN, NF_VIEWPORT | NF_VEHICLE, (v->owner == _local_player) ? NT_ARRIVAL_PLAYER : NT_ARRIVAL_OTHER, DNC_NONE,
v->index,
0);
}
} else {
/* Check if station was ever visited before */
if (!(st->had_vehicle_of_type & HVOT_TRUCK)) {
- uint32 flags;
-
st->had_vehicle_of_type |= HVOT_TRUCK;
SetDParam(0, st->index);
- flags = (v->owner == _local_player) ? NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_PLAYER, 0) : NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_OTHER, 0);
AddNewsItem(
v->u.road.roadtype == ROADTYPE_ROAD ? STR_9030_CITIZENS_CELEBRATE_FIRST : STR_CITIZENS_CELEBRATE_FIRST_CARGO_TRAM,
- flags,
+ NM_THIN, NF_VIEWPORT | NF_VEHICLE, (v->owner == _local_player) ? NT_ARRIVAL_PLAYER : NT_ARRIVAL_OTHER, DNC_NONE,
v->index,
0
);
diff --git a/src/settings.cpp b/src/settings.cpp
index 46dfd72d9..a89c2b713 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -37,7 +37,7 @@
#include "genworld.h"
#include "rail.h"
#include "train.h"
-#include "news.h"
+#include "news_func.h"
#include "window_func.h"
#include "strings_func.h"
#include "vehicle_func.h"
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index dea4d2296..17c35d6d3 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -12,7 +12,7 @@
#include "pathfind.h"
#include "station_map.h"
#include "station.h"
-#include "news.h"
+#include "news_func.h"
#include "engine.h"
#include "player_func.h"
#include "player_base.h"
@@ -406,15 +406,12 @@ static void ShipArrivesAt(const Vehicle* v, Station* st)
{
/* Check if station was ever visited before */
if (!(st->had_vehicle_of_type & HVOT_SHIP)) {
- uint32 flags;
-
st->had_vehicle_of_type |= HVOT_SHIP;
SetDParam(0, st->index);
- flags = (v->owner == _local_player) ? NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_PLAYER, 0) : NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_OTHER, 0);
AddNewsItem(
STR_9833_CITIZENS_CELEBRATE_FIRST,
- flags,
+ NM_THIN, NF_VIEWPORT | NF_VEHICLE, (v->owner == _local_player) ? NT_ARRIVAL_PLAYER : NT_ARRIVAL_OTHER, DNC_NONE,
v->index,
0);
}
diff --git a/src/station.cpp b/src/station.cpp
index a09727b55..de7925d4e 100644
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -9,7 +9,6 @@
#include "station_map.h"
#include "station.h"
#include "town.h"
-#include "news.h"
#include "saveload.h"
#include "player_func.h"
#include "airport.h"
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 5ad63954f..aa354cfae 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -15,7 +15,7 @@
#include "viewport_func.h"
#include "command_func.h"
#include "town.h"
-#include "news.h"
+#include "news_func.h"
#include "saveload.h"
#include "airport.h"
#include "sprite.h"
@@ -432,7 +432,7 @@ static void ShowRejectOrAcceptNews(const Station *st, uint num_items, CargoID *c
}
SetDParam(0, st->index);
- AddNewsItem(msg, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT | NF_TILE, NT_ACCEPTANCE, 0), st->xy, 0);
+ AddNewsItem(msg, NM_SMALL, NF_VIEWPORT | NF_TILE, NT_ACCEPTANCE, DNC_NONE, st->xy, 0);
}
/**
diff --git a/src/strings.cpp b/src/strings.cpp
index 0608fc12e..f6af86831 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -8,7 +8,6 @@
#include "namegen.h"
#include "station.h"
#include "town.h"
-#include "news.h"
#include "screenshot.h"
#include "waypoint.h"
#include "industry.h"
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 35ffed7c3..acde0e3c4 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -17,7 +17,7 @@
#include "industry.h"
#include "station.h"
#include "player_base.h"
-#include "news.h"
+#include "news_func.h"
#include "saveload.h"
#include "gui.h"
#include "unmovable_map.h"
@@ -2118,7 +2118,7 @@ static void TownActionRoadRebuild(Town* t)
SetDParam(1, _current_player);
AddNewsItem(STR_2055_TRAFFIC_CHAOS_IN_ROAD_REBUILDING,
- NEWS_FLAGS(NM_NORMAL, NF_TILE, NT_GENERAL, 0), t->xy, 0);
+ NM_NORMAL, NF_TILE, NT_GENERAL, DNC_NONE, t->xy, 0);
}
static bool DoBuildStatueOfCompany(TileIndex tile, TownID town_id)
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index a5cffd820..e10843c77 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -17,7 +17,7 @@
#include "pathfind.h"
#include "npf.h"
#include "station.h"
-#include "news.h"
+#include "news_func.h"
#include "engine.h"
#include "player_func.h"
#include "player_base.h"
@@ -2495,7 +2495,7 @@ static Track ChooseTrainTrack(Vehicle* v, TileIndex tile, DiagDirection enterdir
SetDParam(0, v->unitnumber);
AddNewsItem(
STR_TRAIN_IS_LOST,
- NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
+ NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE,
v->index,
0);
}
@@ -2765,12 +2765,9 @@ static void TrainEnterStation(Vehicle *v, StationID station)
if (!(st->had_vehicle_of_type & HVOT_TRAIN)) {
st->had_vehicle_of_type |= HVOT_TRAIN;
SetDParam(0, st->index);
- uint32 flags = v->owner == _local_player ?
- NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ARRIVAL_PLAYER, 0) :
- NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ARRIVAL_OTHER, 0);
AddNewsItem(
STR_8801_CITIZENS_CELEBRATE_FIRST,
- flags,
+ NM_THIN, NF_VIEWPORT | NF_VEHICLE, v->owner == _local_player ? NT_ARRIVAL_PLAYER : NT_ARRIVAL_OTHER, DNC_NONE,
v->index,
0
);
@@ -3019,7 +3016,7 @@ static void CheckTrainCollision(Vehicle *v)
SetDParam(0, tcc.num);
AddNewsItem(STR_8868_TRAIN_CRASH_DIE_IN_FIREBALL,
- NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, 0),
+ NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, DNC_NONE,
v->index,
0
);
@@ -3739,7 +3736,7 @@ void TrainsYearlyLoop()
SetDParam(0, v->unitnumber);
AddNewsItem(
STR_TRAIN_IS_UNPROFITABLE,
- NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
+ NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE,
v->index,
0);
}
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 4fd3e0d42..16a1346f1 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -13,7 +13,7 @@
#include "timetable.h"
#include "viewport_func.h"
#include "gfx_func.h"
-#include "news.h"
+#include "news_func.h"
#include "command_func.h"
#include "saveload.h"
#include "player_func.h"
@@ -1544,7 +1544,7 @@ static void ShowVehicleGettingOld(Vehicle *v, StringID msg)
SetDParam(0, _vehicle_type_names[v->type]);
SetDParam(1, v->unitnumber);
- AddNewsItem(msg, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), v->index, 0);
+ AddNewsItem(msg, NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE, v->index, 0);
}
void AgeVehicle(Vehicle *v)
@@ -2258,7 +2258,7 @@ void VehicleEnterDepot(Vehicle *v)
/* Notify the user that we stopped the vehicle */
SetDParam(0, _vehicle_type_names[v->type]);
SetDParam(1, v->unitnumber);
- AddNewsItem(STR_ORDER_REFIT_FAILED, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), v->index, 0);
+ AddNewsItem(STR_ORDER_REFIT_FAILED, NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE, v->index, 0);
}
} else if (v->owner == _local_player && cost.GetCost() != 0) {
ShowCostOrIncomeAnimation(v->x_pos, v->y_pos, v->z_pos, cost.GetCost());
@@ -2284,7 +2284,7 @@ void VehicleEnterDepot(Vehicle *v)
}
SetDParam(0, v->unitnumber);
- AddNewsItem(string, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), v->index, 0);
+ AddNewsItem(string, NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, DNC_NONE, v->index, 0);
}
}
}
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index e41773e7e..678c94b14 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -13,7 +13,7 @@
#include "viewport_func.h"
#include "command_func.h"
#include "town.h"
-#include "news.h"
+#include "news_func.h"
#include "depot.h"
#include "vehicle_gui.h"
#include "train.h"
@@ -855,7 +855,7 @@ static void FloodVehicle(Vehicle *v)
SetDParam(0, pass);
AddNewsItem(STR_B006_FLOOD_VEHICLE_DESTROYED,
- NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, 0),
+ NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, DNC_NONE,
v->index,
0);
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
diff --git a/src/window_gui.h b/src/window_gui.h
index ce1efe256..97e3b9520 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -392,16 +392,6 @@ struct vp_d {
};
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d));
-struct news_d {
- uint16 follow_vehicle;
- int32 scrollpos_x;
- int32 scrollpos_y;
- int32 dest_scrollpos_x;
- int32 dest_scrollpos_y;
- NewsItem *ni;
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d));
-
struct highscore_d {
uint32 background_img;
int8 rank;