1
0
Fork 0

Codechange: Use enum class for NewsType.

pull/13472/head
Peter Nelson 2025-02-02 17:58:55 +00:00 committed by Peter Nelson
parent 4fd1929bf7
commit ca75a8ce19
19 changed files with 111 additions and 110 deletions

View File

@ -1352,9 +1352,9 @@ static void CrashAirplane(Aircraft *v)
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING, victims)); AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING, victims));
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING, victims)); Game::NewEvent(new ScriptEventVehicleCrashed(v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING, victims));
NewsType newstype = NT_ACCIDENT; NewsType newstype = NewsType::Accident;
if (v->owner != _local_company) { if (v->owner != _local_company) {
newstype = NT_ACCIDENT_OTHER; newstype = NewsType::AccidentOther;
} }
AddTileNewsItem(newsitem, newstype, vt, nullptr, st != nullptr ? st->index : INVALID_STATION); AddTileNewsItem(newsitem, newstype, vt, nullptr, st != nullptr ? st->index : INVALID_STATION);
@ -1412,7 +1412,7 @@ static void AircraftEntersTerminal(Aircraft *v)
/* show newsitem of celebrating citizens */ /* show newsitem of celebrating citizens */
AddVehicleNewsItem( AddVehicleNewsItem(
STR_NEWS_FIRST_AIRCRAFT_ARRIVAL, STR_NEWS_FIRST_AIRCRAFT_ARRIVAL,
(v->owner == _local_company) ? NT_ARRIVAL_COMPANY : NT_ARRIVAL_OTHER, (v->owner == _local_company) ? NewsType::ArrivalCompany : NewsType::ArrivalOther,
v->index, v->index,
st->index st->index
); );

View File

@ -433,7 +433,7 @@ set_name:;
SetDParam(1, STR_NEWS_COMPANY_LAUNCH_DESCRIPTION); SetDParam(1, STR_NEWS_COMPANY_LAUNCH_DESCRIPTION);
SetDParamStr(2, cni->company_name); SetDParamStr(2, cni->company_name);
SetDParam(3, t->index); SetDParam(3, t->index);
AddNewsItem(STR_MESSAGE_NEWS_FORMAT, NT_COMPANY_INFO, NewsStyle::Company, {}, NR_TILE, c->last_build_coordinate.base(), NR_NONE, UINT32_MAX, std::move(cni)); AddNewsItem(STR_MESSAGE_NEWS_FORMAT, NewsType::CompanyInfo, NewsStyle::Company, {}, NR_TILE, c->last_build_coordinate.base(), NR_NONE, UINT32_MAX, std::move(cni));
} }
return; return;
} }

View File

@ -148,7 +148,7 @@ static IntervalTimer<TimerGameCalendar> _check_switch_to_euro({TimerGameCalendar
_currency_specs[_settings_game.locale.currency].to_euro != CF_ISEURO && _currency_specs[_settings_game.locale.currency].to_euro != CF_ISEURO &&
TimerGameCalendar::year >= _currency_specs[_settings_game.locale.currency].to_euro) { TimerGameCalendar::year >= _currency_specs[_settings_game.locale.currency].to_euro) {
_settings_game.locale.currency = 2; // this is the index of euro above. _settings_game.locale.currency = 2; // this is the index of euro above.
AddNewsItem(STR_NEWS_EURO_INTRODUCTION, NT_ECONOMY, NewsStyle::Normal, {}); AddNewsItem(STR_NEWS_EURO_INTRODUCTION, NewsType::Economy, NewsStyle::Normal, {});
} }
}); });

View File

@ -246,7 +246,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
v->age = CalendarTime::MIN_DATE; v->age = CalendarTime::MIN_DATE;
SetDParam(0, GetStationIndex(v->tile)); SetDParam(0, GetStationIndex(v->tile));
AddTileNewsItem(STR_NEWS_DISASTER_ZEPPELIN, NT_ACCIDENT, v->tile); AddTileNewsItem(STR_NEWS_DISASTER_ZEPPELIN, NewsType::Accident, v->tile);
AI::NewEvent(GetTileOwner(v->tile), new ScriptEventDisasterZeppelinerCrashed(GetStationIndex(v->tile))); AI::NewEvent(GetTileOwner(v->tile), new ScriptEventDisasterZeppelinerCrashed(GetStationIndex(v->tile)));
} }
} }
@ -387,7 +387,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
uint victims = u->Crash(); uint victims = u->Crash();
u->disaster_vehicle = INVALID_VEHICLE; u->disaster_vehicle = INVALID_VEHICLE;
AddTileNewsItem(STR_NEWS_DISASTER_SMALL_UFO, NT_ACCIDENT, u->tile); AddTileNewsItem(STR_NEWS_DISASTER_SMALL_UFO, NewsType::Accident, u->tile);
AI::NewEvent(u->owner, new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO, victims)); AI::NewEvent(u->owner, new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO, victims));
Game::NewEvent(new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO, victims)); Game::NewEvent(new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO, victims));
@ -466,7 +466,7 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16_t image_override, b
DestructIndustry(i); DestructIndustry(i);
SetDParam(0, i->town->index); SetDParam(0, i->town->index);
AddIndustryNewsItem(news_message, NT_ACCIDENT, i->index); AddIndustryNewsItem(news_message, NewsType::Accident, i->index);
if (_settings_client.sound.disaster) SndPlayTileFx(SND_12_EXPLOSION, i->location.tile); if (_settings_client.sound.disaster) SndPlayTileFx(SND_12_EXPLOSION, i->location.tile);
} }
} else if (v->state == 0) { } else if (v->state == 0) {
@ -562,7 +562,7 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v)
Town *t = ClosestTownFromTile(v->dest_tile, UINT_MAX); Town *t = ClosestTownFromTile(v->dest_tile, UINT_MAX);
SetDParam(0, t->index); SetDParam(0, t->index);
AddTileNewsItem(STR_NEWS_DISASTER_BIG_UFO, NT_ACCIDENT, v->tile); AddTileNewsItem(STR_NEWS_DISASTER_BIG_UFO, NewsType::Accident, v->tile);
if (!Vehicle::CanAllocateItem(2)) { if (!Vehicle::CanAllocateItem(2)) {
delete v; delete v;
@ -888,7 +888,7 @@ static void Disaster_CoalMine_Init()
for (const Industry *i : Industry::Iterate()) { for (const Industry *i : Industry::Iterate()) {
if (GetIndustrySpec(i->type)->behaviour.Test(IndustryBehaviour::CanSubsidence) && --index < 0) { if (GetIndustrySpec(i->type)->behaviour.Test(IndustryBehaviour::CanSubsidence) && --index < 0) {
SetDParam(0, i->town->index); SetDParam(0, i->town->index);
AddTileNewsItem(STR_NEWS_DISASTER_COAL_MINE_SUBSIDENCE, NT_ACCIDENT, i->location.tile + TileDiffXY(1, 1)); // keep the news, even when the mine closes AddTileNewsItem(STR_NEWS_DISASTER_COAL_MINE_SUBSIDENCE, NewsType::Accident, i->location.tile + TileDiffXY(1, 1)); // keep the news, even when the mine closes
{ {
TileIndex tile = i->location.tile; TileIndex tile = i->location.tile;

View File

@ -873,10 +873,10 @@ static void HandleEconomyFluctuations()
if (_economy.fluct == 0) { if (_economy.fluct == 0) {
_economy.fluct = -(int)GB(Random(), 0, 2); _economy.fluct = -(int)GB(Random(), 0, 2);
AddNewsItem(STR_NEWS_BEGIN_OF_RECESSION, NT_ECONOMY, NewsStyle::Normal, {}); AddNewsItem(STR_NEWS_BEGIN_OF_RECESSION, NewsType::Economy, NewsStyle::Normal, {});
} else if (_economy.fluct == -12) { } else if (_economy.fluct == -12) {
_economy.fluct = GB(Random(), 0, 8) + 312; _economy.fluct = GB(Random(), 0, 8) + 312;
AddNewsItem(STR_NEWS_END_OF_RECESSION, NT_ECONOMY, NewsStyle::Normal, {}); AddNewsItem(STR_NEWS_END_OF_RECESSION, NewsType::Economy, NewsStyle::Normal, {});
} }
} }

View File

@ -1131,7 +1131,7 @@ static void NewVehicleAvailable(Engine *e)
if (!IsVehicleTypeDisabled(e->type, false) && !e->info.extra_flags.Test(ExtraEngineFlag::NoNews)) { if (!IsVehicleTypeDisabled(e->type, false) && !e->info.extra_flags.Test(ExtraEngineFlag::NoNews)) {
SetDParam(0, GetEngineCategoryName(index)); SetDParam(0, GetEngineCategoryName(index));
SetDParam(1, PackEngineNameDParam(index, EngineNameContext::PreviewNews)); SetDParam(1, PackEngineNameDParam(index, EngineNameContext::PreviewNews));
AddNewsItem(STR_NEWS_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE, NT_NEW_VEHICLES, NewsStyle::Vehicle, {}, NR_ENGINE, index); AddNewsItem(STR_NEWS_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE, NewsType::NewVehicles, NewsStyle::Vehicle, {}, NR_ENGINE, index);
} }
/* Update the toolbar. */ /* Update the toolbar. */

View File

@ -1722,7 +1722,7 @@ static void AdvertiseIndustryOpening(const Industry *ind)
} else { } else {
SetDParam(1, ind->town->index); SetDParam(1, ind->town->index);
} }
AddIndustryNewsItem(ind_spc->new_industry_text, NT_INDUSTRY_OPEN, ind->index); AddIndustryNewsItem(ind_spc->new_industry_text, NewsType::IndustryOpen, ind->index);
AI::BroadcastNewEvent(new ScriptEventIndustryOpen(ind->index)); AI::BroadcastNewEvent(new ScriptEventIndustryOpen(ind->index));
Game::NewEvent(new ScriptEventIndustryOpen(ind->index)); Game::NewEvent(new ScriptEventIndustryOpen(ind->index));
} }
@ -2183,9 +2183,9 @@ CommandCost CmdIndustrySetProduction(DoCommandFlag flags, IndustryID ind_id, uin
if (show_news && str != STR_NULL) { if (show_news && str != STR_NULL) {
NewsType nt; NewsType nt;
switch (WhoCanServiceIndustry(ind)) { switch (WhoCanServiceIndustry(ind)) {
case 0: nt = NT_INDUSTRY_NOBODY; break; case 0: nt = NewsType::IndustryNobody; break;
case 1: nt = NT_INDUSTRY_OTHER; break; case 1: nt = NewsType::IndustryOther; break;
case 2: nt = NT_INDUSTRY_COMPANY; break; case 2: nt = NewsType::IndustryCompany; break;
default: NOT_REACHED(); default: NOT_REACHED();
} }
@ -2769,9 +2769,9 @@ static void ReportNewsProductionChangeIndustry(Industry *ind, CargoType type, in
NewsType nt; NewsType nt;
switch (WhoCanServiceIndustry(ind)) { switch (WhoCanServiceIndustry(ind)) {
case 0: nt = NT_INDUSTRY_NOBODY; break; case 0: nt = NewsType::IndustryNobody; break;
case 1: nt = NT_INDUSTRY_OTHER; break; case 1: nt = NewsType::IndustryOther; break;
case 2: nt = NT_INDUSTRY_COMPANY; break; case 2: nt = NewsType::IndustryCompany; break;
default: NOT_REACHED(); default: NOT_REACHED();
} }
SetDParam(2, abs(percent)); SetDParam(2, abs(percent));
@ -2969,14 +2969,14 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
NewsType nt; NewsType nt;
/* Compute news category */ /* Compute news category */
if (closeit) { if (closeit) {
nt = NT_INDUSTRY_CLOSE; nt = NewsType::IndustryClose;
AI::BroadcastNewEvent(new ScriptEventIndustryClose(i->index)); AI::BroadcastNewEvent(new ScriptEventIndustryClose(i->index));
Game::NewEvent(new ScriptEventIndustryClose(i->index)); Game::NewEvent(new ScriptEventIndustryClose(i->index));
} else { } else {
switch (WhoCanServiceIndustry(i)) { switch (WhoCanServiceIndustry(i)) {
case 0: nt = NT_INDUSTRY_NOBODY; break; case 0: nt = NewsType::IndustryNobody; break;
case 1: nt = NT_INDUSTRY_OTHER; break; case 1: nt = NewsType::IndustryOther; break;
case 2: nt = NT_INDUSTRY_COMPANY; break; case 2: nt = NewsType::IndustryCompany; break;
default: NOT_REACHED(); default: NOT_REACHED();
} }
} }

View File

@ -19,7 +19,7 @@ void AddNewsItem(StringID string, NewsType type, NewsStyle style, NewsFlags flag
inline void AddCompanyNewsItem(StringID string, std::unique_ptr<CompanyNewsInformation> cni) inline void AddCompanyNewsItem(StringID string, std::unique_ptr<CompanyNewsInformation> cni)
{ {
AddNewsItem(string, NT_COMPANY_INFO, NewsStyle::Company, {}, NR_NONE, UINT32_MAX, NR_NONE, UINT32_MAX, std::move(cni)); AddNewsItem(string, NewsType::CompanyInfo, NewsStyle::Company, {}, NR_NONE, UINT32_MAX, NR_NONE, UINT32_MAX, std::move(cni));
} }
/** /**
@ -39,7 +39,7 @@ inline void AddVehicleNewsItem(StringID string, NewsType type, VehicleID vehicle
*/ */
inline void AddVehicleAdviceNewsItem(AdviceType advice_type, StringID string, VehicleID vehicle) inline void AddVehicleAdviceNewsItem(AdviceType advice_type, StringID string, VehicleID vehicle)
{ {
AddNewsItem(string, NT_ADVICE, NewsStyle::Small, {NewsFlag::InColour, NewsFlag::VehicleParam0}, NR_VEHICLE, vehicle, NR_NONE, {}, nullptr, advice_type); AddNewsItem(string, NewsType::Advice, NewsStyle::Small, {NewsFlag::InColour, NewsFlag::VehicleParam0}, NR_VEHICLE, vehicle, NR_NONE, {}, nullptr, advice_type);
} }
inline void AddTileNewsItem(StringID string, NewsType type, TileIndex tile, std::unique_ptr<NewsAllocatedData> &&data = nullptr, StationID station = INVALID_STATION) inline void AddTileNewsItem(StringID string, NewsType type, TileIndex tile, std::unique_ptr<NewsAllocatedData> &&data = nullptr, StationID station = INVALID_STATION)

View File

@ -313,25 +313,25 @@ static WindowDesc &GetNewsWindowLayout(NewsStyle style)
*/ */
static NewsTypeData _news_type_data[] = { static NewsTypeData _news_type_data[] = {
/* name, age, sound, */ /* name, age, sound, */
NewsTypeData("news_display.arrival_player", 60, SND_1D_APPLAUSE ), ///< NT_ARRIVAL_COMPANY NewsTypeData("news_display.arrival_player", 60, SND_1D_APPLAUSE ), ///< NewsType::ArrivalCompany
NewsTypeData("news_display.arrival_other", 60, SND_1D_APPLAUSE ), ///< NT_ARRIVAL_OTHER NewsTypeData("news_display.arrival_other", 60, SND_1D_APPLAUSE ), ///< NewsType::ArrivalOther
NewsTypeData("news_display.accident", 90, SND_BEGIN ), ///< NT_ACCIDENT NewsTypeData("news_display.accident", 90, SND_BEGIN ), ///< NewsType::Accident
NewsTypeData("news_display.accident_other", 90, SND_BEGIN ), ///< NT_ACCIDENT_OTHER NewsTypeData("news_display.accident_other", 90, SND_BEGIN ), ///< NewsType::AccidentOther
NewsTypeData("news_display.company_info", 60, SND_BEGIN ), ///< NT_COMPANY_INFO NewsTypeData("news_display.company_info", 60, SND_BEGIN ), ///< NewsType::CompanyInfo
NewsTypeData("news_display.open", 90, SND_BEGIN ), ///< NT_INDUSTRY_OPEN NewsTypeData("news_display.open", 90, SND_BEGIN ), ///< NewsType::IndustryOpen
NewsTypeData("news_display.close", 90, SND_BEGIN ), ///< NT_INDUSTRY_CLOSE NewsTypeData("news_display.close", 90, SND_BEGIN ), ///< NewsType::IndustryClose
NewsTypeData("news_display.economy", 30, SND_BEGIN ), ///< NT_ECONOMY NewsTypeData("news_display.economy", 30, SND_BEGIN ), ///< NewsType::Economy
NewsTypeData("news_display.production_player", 30, SND_BEGIN ), ///< NT_INDUSTRY_COMPANY NewsTypeData("news_display.production_player", 30, SND_BEGIN ), ///< NewsType::IndustryCompany
NewsTypeData("news_display.production_other", 30, SND_BEGIN ), ///< NT_INDUSTRY_OTHER NewsTypeData("news_display.production_other", 30, SND_BEGIN ), ///< NewsType::IndustryOther
NewsTypeData("news_display.production_nobody", 30, SND_BEGIN ), ///< NT_INDUSTRY_NOBODY NewsTypeData("news_display.production_nobody", 30, SND_BEGIN ), ///< NewsType::IndustryNobody
NewsTypeData("news_display.advice", 150, SND_BEGIN ), ///< NT_ADVICE NewsTypeData("news_display.advice", 150, SND_BEGIN ), ///< NewsType::Advice
NewsTypeData("news_display.new_vehicles", 30, SND_1E_NEW_ENGINE), ///< NT_NEW_VEHICLES NewsTypeData("news_display.new_vehicles", 30, SND_1E_NEW_ENGINE), ///< NewsType::NewVehicles
NewsTypeData("news_display.acceptance", 90, SND_BEGIN ), ///< NT_ACCEPTANCE NewsTypeData("news_display.acceptance", 90, SND_BEGIN ), ///< NewsType::Acceptance
NewsTypeData("news_display.subsidies", 180, SND_BEGIN ), ///< NT_SUBSIDIES NewsTypeData("news_display.subsidies", 180, SND_BEGIN ), ///< NewsType::Subsidies
NewsTypeData("news_display.general", 60, SND_BEGIN ), ///< NT_GENERAL NewsTypeData("news_display.general", 60, SND_BEGIN ), ///< NewsType::General
}; };
static_assert(lengthof(_news_type_data) == NT_END); static_assert(std::size(_news_type_data) == to_underlying(NewsType::End));
/** /**
* Return the news display option. * Return the news display option.
@ -341,7 +341,7 @@ NewsDisplay NewsTypeData::GetDisplay() const
{ {
const SettingDesc *sd = GetSettingFromName(this->name); const SettingDesc *sd = GetSettingFromName(this->name);
assert(sd != nullptr && sd->IsIntSetting()); assert(sd != nullptr && sd->IsIntSetting());
return (NewsDisplay)sd->AsIntSetting()->Read(nullptr); return static_cast<NewsDisplay>(sd->AsIntSetting()->Read(nullptr));
} }
/** Window class displaying a news item. */ /** Window class displaying a news item. */
@ -700,7 +700,7 @@ private:
/** Open up an own newspaper window for the news item */ /** Open up an own newspaper window for the news item */
static void ShowNewspaper(const NewsItem *ni) static void ShowNewspaper(const NewsItem *ni)
{ {
SoundFx sound = _news_type_data[ni->type].sound; SoundFx sound = _news_type_data[to_underlying(ni->type)].sound;
if (sound != 0 && _settings_client.sound.news_full) SndPlayFx(sound); if (sound != 0 && _settings_client.sound.news_full) SndPlayFx(sound);
new NewsWindow(GetNewsWindowLayout(ni->style), ni); new NewsWindow(GetNewsWindowLayout(ni->style), ni);
@ -768,19 +768,19 @@ static void MoveToNextTickerItem()
const NewsType type = _statusbar_news->type; const NewsType type = _statusbar_news->type;
/* check the date, don't show too old items */ /* check the date, don't show too old items */
if (TimerGameEconomy::date - _news_type_data[type].age > _statusbar_news->economy_date) continue; if (TimerGameEconomy::date - _news_type_data[to_underlying(type)].age > _statusbar_news->economy_date) continue;
switch (_news_type_data[type].GetDisplay()) { switch (_news_type_data[to_underlying(type)].GetDisplay()) {
default: NOT_REACHED(); default: NOT_REACHED();
case ND_OFF: // Off - show nothing only a small reminder in the status bar case NewsDisplay::Off: // Show nothing only a small reminder in the status bar.
InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SHOW_REMINDER); InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SHOW_REMINDER);
return; return;
case ND_SUMMARY: // Summary - show ticker case NewsDisplay::Summary: // Show ticker.
ShowTicker(_statusbar_news); ShowTicker(_statusbar_news);
return; return;
case ND_FULL: // Full - show newspaper, skipped here case NewsDisplay::Full: // Show newspaper, skipped here.
break;; break;;
} }
} }
@ -806,17 +806,17 @@ static void MoveToNextNewsItem()
const NewsType type = _current_news->type; const NewsType type = _current_news->type;
/* check the date, don't show too old items */ /* check the date, don't show too old items */
if (TimerGameEconomy::date - _news_type_data[type].age > _current_news->economy_date) continue; if (TimerGameEconomy::date - _news_type_data[to_underlying(type)].age > _current_news->economy_date) continue;
switch (_news_type_data[type].GetDisplay()) { switch (_news_type_data[to_underlying(type)].GetDisplay()) {
default: NOT_REACHED(); default: NOT_REACHED();
case ND_OFF: // Off - show nothing only a small reminder in the status bar, skipped here case NewsDisplay::Off: // Show nothing only a small reminder in the status bar, skipped here.
break; break;
case ND_SUMMARY: // Summary - show ticker, skipped here case NewsDisplay::Summary: // Show ticker, skipped here.
break;; break;
case ND_FULL: // Full - show newspaper case NewsDisplay::Full: // Sshow newspaper.
ShowNewspaper(&*_current_news); ShowNewspaper(&*_current_news);
return; return;
} }
@ -870,7 +870,7 @@ static std::list<NewsItem>::iterator DeleteNewsItem(std::list<NewsItem>::iterato
* @param reftype2 Type of ref2. * @param reftype2 Type of ref2.
* @param ref2 Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news when the object is deleted. * @param ref2 Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news when the object is deleted.
* @param data Pointer to data that must be released once the news message is cleared. * @param data Pointer to data that must be released once the news message is cleared.
* @param advice_type Sub-type in case the news type is #NT_ADVICE. * @param advice_type Sub-type in case the news type is #NewsType::Advice.
* *
* @see NewsSubtype * @see NewsSubtype
*/ */
@ -892,7 +892,7 @@ NewsItem::NewsItem(StringID string_id, NewsType type, NewsStyle style, NewsFlags
* @param reftype2 Type of ref2 * @param reftype2 Type of ref2
* @param ref2 Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news when the object is deleted. * @param ref2 Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news when the object is deleted.
* @param data Pointer to data that must be released once the news message is cleared. * @param data Pointer to data that must be released once the news message is cleared.
* @param advice_type Sub-type in case the news type is #NT_ADVICE. * @param advice_type Sub-type in case the news type is #NewsType::Advice.
* *
* @see NewsSubtype * @see NewsSubtype
*/ */
@ -926,7 +926,7 @@ CommandCost CmdCustomNewsItem(DoCommandFlag flags, NewsType type, NewsReferenceT
if (_current_company != OWNER_DEITY) return CMD_ERROR; if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (company != INVALID_OWNER && !Company::IsValidID(company)) return CMD_ERROR; if (company != INVALID_OWNER && !Company::IsValidID(company)) return CMD_ERROR;
if (type >= NT_END) return CMD_ERROR; if (type >= NewsType::End) return CMD_ERROR;
if (text.empty()) return CMD_ERROR; if (text.empty()) return CMD_ERROR;
switch (reftype1) { switch (reftype1) {
@ -1041,7 +1041,7 @@ void DeleteInvalidEngineNews()
static void RemoveOldNewsItems() static void RemoveOldNewsItems()
{ {
DeleteNews<MIN_NEWS_AMOUNT>([](const auto &ni) { DeleteNews<MIN_NEWS_AMOUNT>([](const auto &ni) {
return TimerGameEconomy::date - _news_type_data[ni.type].age * _settings_client.gui.news_message_timeout > ni.economy_date; return TimerGameEconomy::date - _news_type_data[to_underlying(ni.type)].age * _settings_client.gui.news_message_timeout > ni.economy_date;
}); });
} }
@ -1131,7 +1131,7 @@ void ShowLastNewsMessage()
} }
bool wrap = false; bool wrap = false;
for (;;) { for (;;) {
if (_news_type_data[ni->type].GetDisplay() != ND_OFF) { if (_news_type_data[to_underlying(ni->type)].GetDisplay() != NewsDisplay::Off) {
ShowNewsMessage(ni); ShowNewsMessage(ni);
break; break;
} }

View File

@ -20,27 +20,28 @@
/** /**
* Type of news. * Type of news.
*/ */
enum NewsType : uint8_t { enum class NewsType : uint8_t {
NT_ARRIVAL_COMPANY, ///< First vehicle arrived for company ArrivalCompany, ///< First vehicle arrived for company
NT_ARRIVAL_OTHER, ///< First vehicle arrived for competitor ArrivalOther, ///< First vehicle arrived for competitor
NT_ACCIDENT, ///< An accident or disaster has occurred Accident, ///< An accident or disaster has occurred
NT_ACCIDENT_OTHER, ///< An accident or disaster has occurred AccidentOther, ///< An accident or disaster has occurred
NT_COMPANY_INFO, ///< Company info (new companies, bankruptcy messages) CompanyInfo, ///< Company info (new companies, bankruptcy messages)
NT_INDUSTRY_OPEN, ///< Opening of industries IndustryOpen, ///< Opening of industries
NT_INDUSTRY_CLOSE, ///< Closing of industries IndustryClose, ///< Closing of industries
NT_ECONOMY, ///< Economic changes (recession, industry up/dowm) Economy, ///< Economic changes (recession, industry up/dowm)
NT_INDUSTRY_COMPANY,///< Production changes of industry serviced by local company IndustryCompany, ///< Production changes of industry serviced by local company
NT_INDUSTRY_OTHER, ///< Production changes of industry serviced by competitor(s) IndustryOther, ///< Production changes of industry serviced by competitor(s)
NT_INDUSTRY_NOBODY, ///< Other industry production changes IndustryNobody, ///< Other industry production changes
NT_ADVICE, ///< Bits of news about vehicles of the company Advice, ///< Bits of news about vehicles of the company
NT_NEW_VEHICLES, ///< New vehicle has become available NewVehicles, ///< New vehicle has become available
NT_ACCEPTANCE, ///< A type of cargo is (no longer) accepted Acceptance, ///< A type of cargo is (no longer) accepted
NT_SUBSIDIES, ///< News about subsidies (announcements, expirations, acceptance) Subsidies, ///< News about subsidies (announcements, expirations, acceptance)
NT_GENERAL, ///< General news (from towns) General, ///< General news (from towns)
NT_END, ///< end-of-array marker
End, ///< end-of-array marker
}; };
/** Sub type of the #NT_ADVICE to be able to remove specific news items. */ /** Sub type of the #NewsType::Advice to be able to remove specific news items. */
enum class AdviceType : uint8_t { enum class AdviceType : uint8_t {
AircraftDestinationTooFar, ///< Next (order) destination is too far for the aircraft type. AircraftDestinationTooFar, ///< Next (order) destination is too far for the aircraft type.
AutorenewFailed, ///< Autorenew or autoreplace failed. AutorenewFailed, ///< Autorenew or autoreplace failed.
@ -98,10 +99,10 @@ using NewsFlags = EnumBitSet<NewsFlag, uint8_t>;
/** /**
* News display options * News display options
*/ */
enum NewsDisplay : uint8_t { enum class NewsDisplay : uint8_t {
ND_OFF, ///< Only show a reminder in the status bar Off, ///< Only show a reminder in the status bar
ND_SUMMARY, ///< Show ticker Summary, ///< Show ticker
ND_FULL, ///< Show newspaper Full, ///< Show newspaper
}; };
/** /**

View File

@ -550,10 +550,10 @@ static void RoadVehCrash(RoadVehicle *v)
SetDParam(0, victims); SetDParam(0, victims);
StringID newsitem = (victims == 1) ? STR_NEWS_ROAD_VEHICLE_CRASH_DRIVER : STR_NEWS_ROAD_VEHICLE_CRASH; StringID newsitem = (victims == 1) ? STR_NEWS_ROAD_VEHICLE_CRASH_DRIVER : STR_NEWS_ROAD_VEHICLE_CRASH;
NewsType newstype = NT_ACCIDENT; NewsType newstype = NewsType::Accident;
if (v->owner != _local_company) { if (v->owner != _local_company) {
newstype = NT_ACCIDENT_OTHER; newstype = NewsType::AccidentOther;
} }
AddTileNewsItem(newsitem, newstype, v->tile); AddTileNewsItem(newsitem, newstype, v->tile);
@ -692,7 +692,7 @@ static void RoadVehArrivesAt(const RoadVehicle *v, Station *st)
SetDParam(0, st->index); SetDParam(0, st->index);
AddVehicleNewsItem( AddVehicleNewsItem(
RoadTypeIsRoad(v->roadtype) ? STR_NEWS_FIRST_BUS_ARRIVAL : STR_NEWS_FIRST_PASSENGER_TRAM_ARRIVAL, RoadTypeIsRoad(v->roadtype) ? STR_NEWS_FIRST_BUS_ARRIVAL : STR_NEWS_FIRST_PASSENGER_TRAM_ARRIVAL,
(v->owner == _local_company) ? NT_ARRIVAL_COMPANY : NT_ARRIVAL_OTHER, (v->owner == _local_company) ? NewsType::ArrivalCompany : NewsType::ArrivalOther,
v->index, v->index,
st->index st->index
); );
@ -706,7 +706,7 @@ static void RoadVehArrivesAt(const RoadVehicle *v, Station *st)
SetDParam(0, st->index); SetDParam(0, st->index);
AddVehicleNewsItem( AddVehicleNewsItem(
RoadTypeIsRoad(v->roadtype) ? STR_NEWS_FIRST_TRUCK_ARRIVAL : STR_NEWS_FIRST_CARGO_TRAM_ARRIVAL, RoadTypeIsRoad(v->roadtype) ? STR_NEWS_FIRST_TRUCK_ARRIVAL : STR_NEWS_FIRST_CARGO_TRAM_ARRIVAL,
(v->owner == _local_company) ? NT_ARRIVAL_COMPANY : NT_ARRIVAL_OTHER, (v->owner == _local_company) ? NewsType::ArrivalCompany : NewsType::ArrivalOther,
v->index, v->index,
st->index st->index
); );

View File

@ -293,7 +293,7 @@
* \li GSEngine::IsValidEngine and GSEngine::IsBuildable when outside GSCompanyMode scope * \li GSEngine::IsValidEngine and GSEngine::IsBuildable when outside GSCompanyMode scope
* \li GSEventExclusiveTransportRights * \li GSEventExclusiveTransportRights
* \li GSEventRoadReconstruction * \li GSEventRoadReconstruction
* \li GSNews::NT_ACCIDENT, GSNews::NT_COMPANY_INFO, GSNews::NT_ADVICE, GSNews::NT_ACCEPTANCE * \li GSNews::NewsType::Accident, GSNews::NewsType::CompanyInfo, GSNews::NewsType::Advice, GSNews::NewsType::Acceptance
* \li GSIndustryType::IsProcessingIndustry * \li GSIndustryType::IsProcessingIndustry
* \li GSStation::IsAirportClosed * \li GSStation::IsAirportClosed
* \li GSStation::OpenCloseAirport * \li GSStation::OpenCloseAirport

View File

@ -24,13 +24,13 @@ public:
*/ */
enum NewsType { enum NewsType {
/* Arbitrary selection of NewsTypes which might make sense for scripts */ /* Arbitrary selection of NewsTypes which might make sense for scripts */
NT_ACCIDENT = ::NT_ACCIDENT, ///< Category accidents. NT_ACCIDENT = to_underlying(::NewsType::Accident), ///< Category accidents.
NT_COMPANY_INFO = ::NT_COMPANY_INFO, ///< Category company info. NT_COMPANY_INFO = to_underlying(::NewsType::CompanyInfo), ///< Category company info.
NT_ECONOMY = ::NT_ECONOMY, ///< Category economy. NT_ECONOMY = to_underlying(::NewsType::Economy), ///< Category economy.
NT_ADVICE = ::NT_ADVICE, ///< Category vehicle advice. NT_ADVICE = to_underlying(::NewsType::Advice), ///< Category vehicle advice.
NT_ACCEPTANCE = ::NT_ACCEPTANCE, ///< Category acceptance changes. NT_ACCEPTANCE = to_underlying(::NewsType::Acceptance), ///< Category acceptance changes.
NT_SUBSIDIES = ::NT_SUBSIDIES, ///< Category subsidies. NT_SUBSIDIES = to_underlying(::NewsType::Subsidies), ///< Category subsidies.
NT_GENERAL = ::NT_GENERAL, ///< Category general. NT_GENERAL = to_underlying(::NewsType::General), ///< Category general.
}; };
/** /**
@ -58,7 +58,7 @@ public:
* - For #NR_INDUSTRY this parameter should be a valid industryID (ScriptIndustry::IsValidIndustry). * - For #NR_INDUSTRY this parameter should be a valid industryID (ScriptIndustry::IsValidIndustry).
* - For #NR_TOWN this parameter should be a valid townID (ScriptTown::IsValidTown). * - For #NR_TOWN this parameter should be a valid townID (ScriptTown::IsValidTown).
* @return True if the action succeeded. * @return True if the action succeeded.
* @pre type must be #NT_ECONOMY, #NT_SUBSIDIES, or #NT_GENERAL. * @pre type must be #NewsType::Economy, #NewsType::Subsidies, or #NewsType::General.
* @pre text != null. * @pre text != null.
* @pre company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID. * @pre company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID.
* @pre The \a reference condition must be fulfilled. * @pre The \a reference condition must be fulfilled.

View File

@ -474,7 +474,7 @@ static void ShipArrivesAt(const Vehicle *v, Station *st)
SetDParam(0, st->index); SetDParam(0, st->index);
AddVehicleNewsItem( AddVehicleNewsItem(
STR_NEWS_FIRST_SHIP_ARRIVAL, STR_NEWS_FIRST_SHIP_ARRIVAL,
(v->owner == _local_company) ? NT_ARRIVAL_COMPANY : NT_ARRIVAL_OTHER, (v->owner == _local_company) ? NewsType::ArrivalCompany : NewsType::ArrivalOther,
v->index, v->index,
st->index st->index
); );

View File

@ -532,7 +532,7 @@ static void ShowRejectOrAcceptNews(const Station *st, CargoTypes cargoes, bool r
SetDParam(0, st->index); SetDParam(0, st->index);
SetDParam(1, cargoes); SetDParam(1, cargoes);
StringID msg = reject ? STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_LIST : STR_NEWS_STATION_NOW_ACCEPTS_CARGO_LIST; StringID msg = reject ? STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_LIST : STR_NEWS_STATION_NOW_ACCEPTS_CARGO_LIST;
AddNewsItem(msg, NT_ACCEPTANCE, NewsStyle::Small, NewsFlag::InColour, NR_STATION, st->index); AddNewsItem(msg, NewsType::Acceptance, NewsStyle::Small, NewsFlag::InColour, NR_STATION, st->index);
} }
/** /**

View File

@ -56,7 +56,7 @@ void Subsidy::AwardTo(CompanyID company)
SetDParamStr(0, company_name); SetDParamStr(0, company_name);
AddNewsItem( AddNewsItem(
STR_NEWS_SERVICE_SUBSIDY_AWARDED_HALF + _settings_game.difficulty.subsidy_multiplier, STR_NEWS_SERVICE_SUBSIDY_AWARDED_HALF + _settings_game.difficulty.subsidy_multiplier,
NT_SUBSIDIES, NewsStyle::Normal, {}, NewsType::Subsidies, NewsStyle::Normal, {},
reftype.first, this->src, reftype.second, this->dst reftype.first, this->src, reftype.second, this->dst
); );
AI::BroadcastNewEvent(new ScriptEventSubsidyAwarded(this->index)); AI::BroadcastNewEvent(new ScriptEventSubsidyAwarded(this->index));
@ -222,7 +222,7 @@ void CreateSubsidy(CargoType cargo_type, SourceType src_type, SourceID src, Sour
s->awarded = INVALID_COMPANY; s->awarded = INVALID_COMPANY;
std::pair<NewsReferenceType, NewsReferenceType> reftype = SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::NewsOffered); std::pair<NewsReferenceType, NewsReferenceType> reftype = SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::NewsOffered);
AddNewsItem(STR_NEWS_SERVICE_SUBSIDY_OFFERED, NT_SUBSIDIES, NewsStyle::Normal, {}, reftype.first, s->src, reftype.second, s->dst); AddNewsItem(STR_NEWS_SERVICE_SUBSIDY_OFFERED, NewsType::Subsidies, NewsStyle::Normal, {}, reftype.first, s->src, reftype.second, s->dst);
SetPartOfSubsidyFlag(s->src_type, s->src, POS_SRC); SetPartOfSubsidyFlag(s->src_type, s->src, POS_SRC);
SetPartOfSubsidyFlag(s->dst_type, s->dst, POS_DST); SetPartOfSubsidyFlag(s->dst_type, s->dst, POS_DST);
AI::BroadcastNewEvent(new ScriptEventSubsidyOffer(s->index)); AI::BroadcastNewEvent(new ScriptEventSubsidyOffer(s->index));
@ -488,13 +488,13 @@ static IntervalTimer<TimerGameEconomy> _economy_subsidies_monthly({TimerGameEcon
if (--s->remaining == 0) { if (--s->remaining == 0) {
if (!s->IsAwarded()) { if (!s->IsAwarded()) {
std::pair<NewsReferenceType, NewsReferenceType> reftype = SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::NewsWithdrawn); std::pair<NewsReferenceType, NewsReferenceType> reftype = SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::NewsWithdrawn);
AddNewsItem(STR_NEWS_OFFER_OF_SUBSIDY_EXPIRED, NT_SUBSIDIES, NewsStyle::Normal, {}, reftype.first, s->src, reftype.second, s->dst); AddNewsItem(STR_NEWS_OFFER_OF_SUBSIDY_EXPIRED, NewsType::Subsidies, NewsStyle::Normal, {}, reftype.first, s->src, reftype.second, s->dst);
AI::BroadcastNewEvent(new ScriptEventSubsidyOfferExpired(s->index)); AI::BroadcastNewEvent(new ScriptEventSubsidyOfferExpired(s->index));
Game::NewEvent(new ScriptEventSubsidyOfferExpired(s->index)); Game::NewEvent(new ScriptEventSubsidyOfferExpired(s->index));
} else { } else {
if (s->awarded == _local_company) { if (s->awarded == _local_company) {
std::pair<NewsReferenceType, NewsReferenceType> reftype = SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::NewsWithdrawn); std::pair<NewsReferenceType, NewsReferenceType> reftype = SetupSubsidyDecodeParam(s, SubsidyDecodeParamType::NewsWithdrawn);
AddNewsItem(STR_NEWS_SUBSIDY_WITHDRAWN_SERVICE, NT_SUBSIDIES, NewsStyle::Normal, {}, reftype.first, s->src, reftype.second, s->dst); AddNewsItem(STR_NEWS_SUBSIDY_WITHDRAWN_SERVICE, NewsType::Subsidies, NewsStyle::Normal, {}, reftype.first, s->src, reftype.second, s->dst);
} }
AI::BroadcastNewEvent(new ScriptEventSubsidyExpired(s->index)); AI::BroadcastNewEvent(new ScriptEventSubsidyExpired(s->index));
Game::NewEvent(new ScriptEventSubsidyExpired(s->index)); Game::NewEvent(new ScriptEventSubsidyExpired(s->index));

View File

@ -2229,7 +2229,7 @@ std::tuple<CommandCost, Money, TownID> CmdFoundTown(DoCommandFlag flags, TileInd
if (_current_company == OWNER_DEITY) { if (_current_company == OWNER_DEITY) {
SetDParam(0, t->index); SetDParam(0, t->index);
AddTileNewsItem(STR_NEWS_NEW_TOWN_UNSPONSORED, NT_INDUSTRY_OPEN, tile); AddTileNewsItem(STR_NEWS_NEW_TOWN_UNSPONSORED, NewsType::IndustryOpen, tile);
} else { } else {
SetDParam(0, _current_company); SetDParam(0, _current_company);
std::string company_name = GetString(STR_COMPANY_NAME); std::string company_name = GetString(STR_COMPANY_NAME);
@ -2237,7 +2237,7 @@ std::tuple<CommandCost, Money, TownID> CmdFoundTown(DoCommandFlag flags, TileInd
SetDParamStr(0, company_name); SetDParamStr(0, company_name);
SetDParam(1, t->index); SetDParam(1, t->index);
AddTileNewsItem(STR_NEWS_NEW_TOWN, NT_INDUSTRY_OPEN, tile); AddTileNewsItem(STR_NEWS_NEW_TOWN, NewsType::IndustryOpen, tile);
} }
AI::BroadcastNewEvent(new ScriptEventTownFounded(t->index)); AI::BroadcastNewEvent(new ScriptEventTownFounded(t->index));
Game::NewEvent(new ScriptEventTownFounded(t->index)); Game::NewEvent(new ScriptEventTownFounded(t->index));
@ -3388,7 +3388,7 @@ static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlag flags)
AddNewsItem( AddNewsItem(
TimerGameEconomy::UsingWallclockUnits() ? STR_NEWS_ROAD_REBUILDING_MINUTES : STR_NEWS_ROAD_REBUILDING_MONTHS, TimerGameEconomy::UsingWallclockUnits() ? STR_NEWS_ROAD_REBUILDING_MINUTES : STR_NEWS_ROAD_REBUILDING_MONTHS,
NT_GENERAL, NewsStyle::Normal, {}, NR_TOWN, t->index, NR_NONE, UINT32_MAX); NewsType::General, NewsStyle::Normal, {}, NR_TOWN, t->index, NR_NONE, UINT32_MAX);
AI::BroadcastNewEvent(new ScriptEventRoadReconstruction((ScriptCompany::CompanyID)(Owner)_current_company, t->index)); AI::BroadcastNewEvent(new ScriptEventRoadReconstruction((ScriptCompany::CompanyID)(Owner)_current_company, t->index));
Game::NewEvent(new ScriptEventRoadReconstruction((ScriptCompany::CompanyID)(Owner)_current_company, t->index)); Game::NewEvent(new ScriptEventRoadReconstruction((ScriptCompany::CompanyID)(Owner)_current_company, t->index));
} }
@ -3543,7 +3543,7 @@ static CommandCost TownActionBuyRights(Town *t, DoCommandFlag flags)
SetDParam(1, TimerGameEconomy::UsingWallclockUnits() ? STR_NEWS_EXCLUSIVE_RIGHTS_DESCRIPTION_MINUTES : STR_NEWS_EXCLUSIVE_RIGHTS_DESCRIPTION_MONTHS); SetDParam(1, TimerGameEconomy::UsingWallclockUnits() ? STR_NEWS_EXCLUSIVE_RIGHTS_DESCRIPTION_MINUTES : STR_NEWS_EXCLUSIVE_RIGHTS_DESCRIPTION_MONTHS);
SetDParam(2, t->index); SetDParam(2, t->index);
SetDParamStr(3, cni->company_name); SetDParamStr(3, cni->company_name);
AddNewsItem(STR_MESSAGE_NEWS_FORMAT, NT_GENERAL, NewsStyle::Company, {}, NR_TOWN, t->index, NR_NONE, UINT32_MAX, std::move(cni)); AddNewsItem(STR_MESSAGE_NEWS_FORMAT, NewsType::General, NewsStyle::Company, {}, NR_TOWN, t->index, NR_NONE, UINT32_MAX, std::move(cni));
AI::BroadcastNewEvent(new ScriptEventExclusiveTransportRights((ScriptCompany::CompanyID)(Owner)_current_company, t->index)); AI::BroadcastNewEvent(new ScriptEventExclusiveTransportRights((ScriptCompany::CompanyID)(Owner)_current_company, t->index));
Game::NewEvent(new ScriptEventExclusiveTransportRights((ScriptCompany::CompanyID)(Owner)_current_company, t->index)); Game::NewEvent(new ScriptEventExclusiveTransportRights((ScriptCompany::CompanyID)(Owner)_current_company, t->index));
} }

View File

@ -3011,7 +3011,7 @@ static void TrainEnterStation(Train *v, StationID station)
SetDParam(0, st->index); SetDParam(0, st->index);
AddVehicleNewsItem( AddVehicleNewsItem(
STR_NEWS_FIRST_TRAIN_ARRIVAL, STR_NEWS_FIRST_TRAIN_ARRIVAL,
v->owner == _local_company ? NT_ARRIVAL_COMPANY : NT_ARRIVAL_OTHER, v->owner == _local_company ? NewsType::ArrivalCompany : NewsType::ArrivalOther,
v->index, v->index,
st->index st->index
); );
@ -3246,7 +3246,7 @@ static bool CheckTrainCollision(Train *v)
if (tcc.num == 0) return false; if (tcc.num == 0) return false;
SetDParam(0, tcc.num); SetDParam(0, tcc.num);
AddTileNewsItem(STR_NEWS_TRAIN_CRASH, NT_ACCIDENT, v->tile); AddTileNewsItem(STR_NEWS_TRAIN_CRASH, NewsType::Accident, v->tile);
ModifyStationRatingAround(v->tile, v->owner, -160, 30); ModifyStationRatingAround(v->tile, v->owner, -160, 30);
if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_13_TRAIN_COLLISION, v); if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_13_TRAIN_COLLISION, v);

View File

@ -1009,7 +1009,7 @@ static void FloodVehicle(Vehicle *v)
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_FLOODED, victims)); AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_FLOODED, victims));
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_FLOODED, victims)); Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_FLOODED, victims));
SetDParam(0, victims); SetDParam(0, victims);
AddTileNewsItem(STR_NEWS_DISASTER_FLOOD_VEHICLE, NT_ACCIDENT, v->tile); AddTileNewsItem(STR_NEWS_DISASTER_FLOOD_VEHICLE, NewsType::Accident, v->tile);
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE); CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v); if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);
} }