Changeset - r8763:c2c776621d56
[Not reviewed]
master
1 26 2
rubidium - 17 years ago 2008-03-28 08:53:36
rubidium@openttd.org
(svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
29 files changed with 326 insertions and 347 deletions:
0 comments (0 inline, 0 general)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -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(Vehic
 

	
 
	/* 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);
 
	}
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -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 
 
					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 
 
			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;
src/currency.cpp
Show inline comments
 
@@ -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);
 
	}
 
}
 

	
src/disaster_cmd.cpp
Show inline comments
 
@@ -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(Vehi
 

	
 
				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(Vehicl
 
			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(Vehi
 
			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
 
		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;
src/economy.cpp
Show inline comments
 
@@ -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 
 

	
 
	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 
 

	
 
			/* 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 
 
	}
 
}
 

	
 
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 *fro
 
			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;
src/engine.cpp
Show inline comments
 
@@ -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 *
 
			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()
src/engine_gui.cpp
Show inline comments
 
@@ -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(co
 
	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));
src/industry_cmd.cpp
Show inline comments
 
@@ -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 t
 
							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 ReportNewsProductionChangeIn
 
	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(Ind
 
		}
 
		/* 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);
 
	}
 
}
src/main_gui.cpp
Show inline comments
 
@@ -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"
src/misc.cpp
Show inline comments
 
@@ -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"
src/news.h
Show inline comments
 
deleted file
src/news_func.h
Show inline comments
 
new file 100644
 
/* $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 */
src/news_gui.cpp
Show inline comments
 
@@ -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_NE
 
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_NEW
 

	
 
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;
 
		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);
 
			switch (ni->display_mode) {
 
				case NM_NORMAL:
 
				case NM_THIN: {
 
					DrawNewsBorder(w);
 

	
 
				DrawString(2, 1, STR_00C6, TC_FROMSTRING);
 
					DrawString(2, 1, STR_00C6, TC_FROMSTRING);
 

	
 
				SetDParam(0, ni->date);
 
				DrawStringRightAligned(428, 1, STR_01FF, 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;
 
					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)
 
					);
 
						/* 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);
 
						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;
 
			}
 

	
 
			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);
 
				case NM_CALLBACK: {
 
					_draw_news_callback[ni->callback](w, ni);
 
					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);
 
				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_KEYPRESS:
 
		if (e->we.keypress.keycode == WKC_SPACE) {
 
			/* Don't continue. */
 
			e->we.keypress.cont = false;
 
			DeleteWindow(w);
 
		}
 
		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);
 
				}
 
			} 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_KEYPRESS:
 
			if (e->we.keypress.keycode == WKC_SPACE) {
 
				/* Don't continue. */
 
				e->we.keypress.cont = false;
 
				DeleteWindow(w);
 
			}
 
			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_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;
 

	
 
		if (w->viewport != NULL)
 
			w->viewport->top += y - w->top;
 
		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;
 

	
 
		diff = Delta(w->top, y);
 
		w->top = y;
 
			if (w->viewport != NULL)
 
				w->viewport->top += y - w->top;
 

	
 
		SetDirtyBlocks(w->left, w->top - diff, w->left + w->width, w->top + w->height);
 
	} break;
 
			diff = Delta(w->top, y);
 
			w->top = y;
 

	
 
			SetDirtyBlocks(w->left, w->top - diff, w->left + w->width, w->top + w->height);
 
		} break;
 
	}
 
}
 

	
 
@@ -254,17 +264,15 @@ static inline NewsID decreaseIndex(NewsI
 

	
 
/**
 
 * 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(NewsI
 
 *    @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
 
	  _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));
 
	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);
 
	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;
 
	/* 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));
 
	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));
 

	
 
		w = FindWindowById(WC_MESSAGE_HISTORY, 0);
 
		if (w == NULL) return;
 
		SetWindowDirty(w);
 
		w->vscroll.count = _total_news;
 
	}
 
	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] = {
src/news_type.h
Show inline comments
 
new file 100644
 
/* $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 */
src/openttd.cpp
Show inline comments
 
@@ -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"
src/openttd.h
Show inline comments
 
@@ -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)
src/order_cmd.cpp
Show inline comments
 
@@ -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
 
		);
src/players.cpp
Show inline comments
 
@@ -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
 

	
 
			/* 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);
src/roadveh_cmd.cpp
Show inline comments
 
@@ -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 Vehic
 
	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
 
			);
src/settings.cpp
Show inline comments
 
@@ -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"
src/ship_cmd.cpp
Show inline comments
 
@@ -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*
 
{
 
	/* 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);
 
	}
src/station.cpp
Show inline comments
 
@@ -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"
src/station_cmd.cpp
Show inline comments
 
@@ -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
 
	}
 

	
 
	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);
 
}
 

	
 
/**
src/strings.cpp
Show inline comments
 
@@ -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"
src/town_cmd.cpp
Show inline comments
 
@@ -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* 
 
	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)
src/train_cmd.cpp
Show inline comments
 
@@ -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
 
				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
 
	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 
 

	
 
	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);
 
			}
src/vehicle.cpp
Show inline comments
 
@@ -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(Vehicl
 

	
 
	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);
 
			}
 
		}
 
	}
src/water_cmd.cpp
Show inline comments
 
@@ -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);
src/window_gui.h
Show inline comments
 
@@ -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;
0 comments (0 inline, 0 general)