diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 9d630d3dc0..ae88417751 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -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)); 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) { - newstype = NT_ACCIDENT_OTHER; + newstype = NewsType::AccidentOther; } 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 */ AddVehicleNewsItem( 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, st->index ); diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index a274ec0415..b7c98434d4 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -433,7 +433,7 @@ set_name:; SetDParam(1, STR_NEWS_COMPANY_LAUNCH_DESCRIPTION); SetDParamStr(2, cni->company_name); 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; } diff --git a/src/currency.cpp b/src/currency.cpp index a3d559e39a..aae59a5c5d 100644 --- a/src/currency.cpp +++ b/src/currency.cpp @@ -148,7 +148,7 @@ static IntervalTimer _check_switch_to_euro({TimerGameCalendar _currency_specs[_settings_game.locale.currency].to_euro != CF_ISEURO && TimerGameCalendar::year >= _currency_specs[_settings_game.locale.currency].to_euro) { _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, {}); } }); diff --git a/src/disaster_vehicle.cpp b/src/disaster_vehicle.cpp index f5891de93e..12fd4adde3 100644 --- a/src/disaster_vehicle.cpp +++ b/src/disaster_vehicle.cpp @@ -246,7 +246,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v) v->age = CalendarTime::MIN_DATE; 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))); } } @@ -387,7 +387,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v) uint victims = u->Crash(); 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)); 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); 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); } } else if (v->state == 0) { @@ -562,7 +562,7 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v) Town *t = ClosestTownFromTile(v->dest_tile, UINT_MAX); 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)) { delete v; @@ -888,7 +888,7 @@ static void Disaster_CoalMine_Init() for (const Industry *i : Industry::Iterate()) { if (GetIndustrySpec(i->type)->behaviour.Test(IndustryBehaviour::CanSubsidence) && --index < 0) { 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; diff --git a/src/economy.cpp b/src/economy.cpp index 0dcdfb65ec..955685a10c 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -873,10 +873,10 @@ static void HandleEconomyFluctuations() if (_economy.fluct == 0) { _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) { _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, {}); } } diff --git a/src/engine.cpp b/src/engine.cpp index 2090d1faf2..39df04e39a 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -1131,7 +1131,7 @@ static void NewVehicleAvailable(Engine *e) if (!IsVehicleTypeDisabled(e->type, false) && !e->info.extra_flags.Test(ExtraEngineFlag::NoNews)) { SetDParam(0, GetEngineCategoryName(index)); 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. */ diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index ad9f9b9f64..2df4b79d44 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -1722,7 +1722,7 @@ static void AdvertiseIndustryOpening(const Industry *ind) } else { 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)); Game::NewEvent(new ScriptEventIndustryOpen(ind->index)); } @@ -2183,9 +2183,9 @@ CommandCost CmdIndustrySetProduction(DoCommandFlag flags, IndustryID ind_id, uin if (show_news && str != STR_NULL) { NewsType nt; switch (WhoCanServiceIndustry(ind)) { - case 0: nt = NT_INDUSTRY_NOBODY; break; - case 1: nt = NT_INDUSTRY_OTHER; break; - case 2: nt = NT_INDUSTRY_COMPANY; break; + case 0: nt = NewsType::IndustryNobody; break; + case 1: nt = NewsType::IndustryOther; break; + case 2: nt = NewsType::IndustryCompany; break; default: NOT_REACHED(); } @@ -2769,9 +2769,9 @@ static void ReportNewsProductionChangeIndustry(Industry *ind, CargoType type, in NewsType nt; switch (WhoCanServiceIndustry(ind)) { - case 0: nt = NT_INDUSTRY_NOBODY; break; - case 1: nt = NT_INDUSTRY_OTHER; break; - case 2: nt = NT_INDUSTRY_COMPANY; break; + case 0: nt = NewsType::IndustryNobody; break; + case 1: nt = NewsType::IndustryOther; break; + case 2: nt = NewsType::IndustryCompany; break; default: NOT_REACHED(); } SetDParam(2, abs(percent)); @@ -2969,14 +2969,14 @@ static void ChangeIndustryProduction(Industry *i, bool monthly) NewsType nt; /* Compute news category */ if (closeit) { - nt = NT_INDUSTRY_CLOSE; + nt = NewsType::IndustryClose; AI::BroadcastNewEvent(new ScriptEventIndustryClose(i->index)); Game::NewEvent(new ScriptEventIndustryClose(i->index)); } else { switch (WhoCanServiceIndustry(i)) { - case 0: nt = NT_INDUSTRY_NOBODY; break; - case 1: nt = NT_INDUSTRY_OTHER; break; - case 2: nt = NT_INDUSTRY_COMPANY; break; + case 0: nt = NewsType::IndustryNobody; break; + case 1: nt = NewsType::IndustryOther; break; + case 2: nt = NewsType::IndustryCompany; break; default: NOT_REACHED(); } } diff --git a/src/news_func.h b/src/news_func.h index 76a3f178e1..98a44d29ee 100644 --- a/src/news_func.h +++ b/src/news_func.h @@ -19,7 +19,7 @@ void AddNewsItem(StringID string, NewsType type, NewsStyle style, NewsFlags flag inline void AddCompanyNewsItem(StringID string, std::unique_ptr 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) { - 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 &&data = nullptr, StationID station = INVALID_STATION) diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 3b880e3857..94a6fd36f3 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -313,25 +313,25 @@ static WindowDesc &GetNewsWindowLayout(NewsStyle style) */ static NewsTypeData _news_type_data[] = { /* name, age, sound, */ - NewsTypeData("news_display.arrival_player", 60, SND_1D_APPLAUSE ), ///< NT_ARRIVAL_COMPANY - NewsTypeData("news_display.arrival_other", 60, SND_1D_APPLAUSE ), ///< NT_ARRIVAL_OTHER - NewsTypeData("news_display.accident", 90, SND_BEGIN ), ///< NT_ACCIDENT - NewsTypeData("news_display.accident_other", 90, SND_BEGIN ), ///< NT_ACCIDENT_OTHER - NewsTypeData("news_display.company_info", 60, SND_BEGIN ), ///< NT_COMPANY_INFO - NewsTypeData("news_display.open", 90, SND_BEGIN ), ///< NT_INDUSTRY_OPEN - NewsTypeData("news_display.close", 90, SND_BEGIN ), ///< NT_INDUSTRY_CLOSE - NewsTypeData("news_display.economy", 30, SND_BEGIN ), ///< NT_ECONOMY - NewsTypeData("news_display.production_player", 30, SND_BEGIN ), ///< NT_INDUSTRY_COMPANY - NewsTypeData("news_display.production_other", 30, SND_BEGIN ), ///< NT_INDUSTRY_OTHER - NewsTypeData("news_display.production_nobody", 30, SND_BEGIN ), ///< NT_INDUSTRY_NOBODY - NewsTypeData("news_display.advice", 150, SND_BEGIN ), ///< NT_ADVICE - NewsTypeData("news_display.new_vehicles", 30, SND_1E_NEW_ENGINE), ///< NT_NEW_VEHICLES - NewsTypeData("news_display.acceptance", 90, SND_BEGIN ), ///< NT_ACCEPTANCE - NewsTypeData("news_display.subsidies", 180, SND_BEGIN ), ///< NT_SUBSIDIES - NewsTypeData("news_display.general", 60, SND_BEGIN ), ///< NT_GENERAL + NewsTypeData("news_display.arrival_player", 60, SND_1D_APPLAUSE ), ///< NewsType::ArrivalCompany + NewsTypeData("news_display.arrival_other", 60, SND_1D_APPLAUSE ), ///< NewsType::ArrivalOther + NewsTypeData("news_display.accident", 90, SND_BEGIN ), ///< NewsType::Accident + NewsTypeData("news_display.accident_other", 90, SND_BEGIN ), ///< NewsType::AccidentOther + NewsTypeData("news_display.company_info", 60, SND_BEGIN ), ///< NewsType::CompanyInfo + NewsTypeData("news_display.open", 90, SND_BEGIN ), ///< NewsType::IndustryOpen + NewsTypeData("news_display.close", 90, SND_BEGIN ), ///< NewsType::IndustryClose + NewsTypeData("news_display.economy", 30, SND_BEGIN ), ///< NewsType::Economy + NewsTypeData("news_display.production_player", 30, SND_BEGIN ), ///< NewsType::IndustryCompany + NewsTypeData("news_display.production_other", 30, SND_BEGIN ), ///< NewsType::IndustryOther + NewsTypeData("news_display.production_nobody", 30, SND_BEGIN ), ///< NewsType::IndustryNobody + NewsTypeData("news_display.advice", 150, SND_BEGIN ), ///< NewsType::Advice + NewsTypeData("news_display.new_vehicles", 30, SND_1E_NEW_ENGINE), ///< NewsType::NewVehicles + NewsTypeData("news_display.acceptance", 90, SND_BEGIN ), ///< NewsType::Acceptance + NewsTypeData("news_display.subsidies", 180, SND_BEGIN ), ///< NewsType::Subsidies + 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. @@ -341,7 +341,7 @@ NewsDisplay NewsTypeData::GetDisplay() const { const SettingDesc *sd = GetSettingFromName(this->name); assert(sd != nullptr && sd->IsIntSetting()); - return (NewsDisplay)sd->AsIntSetting()->Read(nullptr); + return static_cast(sd->AsIntSetting()->Read(nullptr)); } /** Window class displaying a news item. */ @@ -700,7 +700,7 @@ private: /** Open up an own newspaper window for the news item */ 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); new NewsWindow(GetNewsWindowLayout(ni->style), ni); @@ -768,19 +768,19 @@ static void MoveToNextTickerItem() const NewsType type = _statusbar_news->type; /* 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(); - 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); return; - case ND_SUMMARY: // Summary - show ticker + case NewsDisplay::Summary: // Show ticker. ShowTicker(_statusbar_news); return; - case ND_FULL: // Full - show newspaper, skipped here + case NewsDisplay::Full: // Show newspaper, skipped here. break;; } } @@ -806,17 +806,17 @@ static void MoveToNextNewsItem() const NewsType type = _current_news->type; /* 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(); - 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; - case ND_SUMMARY: // Summary - show ticker, skipped here - break;; + case NewsDisplay::Summary: // Show ticker, skipped here. + break; - case ND_FULL: // Full - show newspaper + case NewsDisplay::Full: // Sshow newspaper. ShowNewspaper(&*_current_news); return; } @@ -870,7 +870,7 @@ static std::list::iterator DeleteNewsItem(std::list::iterato * @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 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 */ @@ -892,7 +892,7 @@ NewsItem::NewsItem(StringID string_id, NewsType type, NewsStyle style, NewsFlags * @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 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 */ @@ -926,7 +926,7 @@ CommandCost CmdCustomNewsItem(DoCommandFlag flags, NewsType type, NewsReferenceT if (_current_company != OWNER_DEITY) 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; switch (reftype1) { @@ -1041,7 +1041,7 @@ void DeleteInvalidEngineNews() static void RemoveOldNewsItems() { DeleteNews([](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; for (;;) { - if (_news_type_data[ni->type].GetDisplay() != ND_OFF) { + if (_news_type_data[to_underlying(ni->type)].GetDisplay() != NewsDisplay::Off) { ShowNewsMessage(ni); break; } diff --git a/src/news_type.h b/src/news_type.h index 898aa91f6c..749c566100 100644 --- a/src/news_type.h +++ b/src/news_type.h @@ -20,27 +20,28 @@ /** * Type of news. */ -enum NewsType : uint8_t { - NT_ARRIVAL_COMPANY, ///< First vehicle arrived for company - NT_ARRIVAL_OTHER, ///< First vehicle arrived for competitor - NT_ACCIDENT, ///< An accident or disaster has occurred - NT_ACCIDENT_OTHER, ///< An accident or disaster has occurred - NT_COMPANY_INFO, ///< Company info (new companies, bankruptcy messages) - NT_INDUSTRY_OPEN, ///< Opening of industries - NT_INDUSTRY_CLOSE, ///< Closing of industries - NT_ECONOMY, ///< Economic changes (recession, industry up/dowm) - NT_INDUSTRY_COMPANY,///< Production changes of industry serviced by local company - 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 company - 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 +enum class NewsType : uint8_t { + ArrivalCompany, ///< First vehicle arrived for company + ArrivalOther, ///< First vehicle arrived for competitor + Accident, ///< An accident or disaster has occurred + AccidentOther, ///< An accident or disaster has occurred + CompanyInfo, ///< Company info (new companies, bankruptcy messages) + IndustryOpen, ///< Opening of industries + IndustryClose, ///< Closing of industries + Economy, ///< Economic changes (recession, industry up/dowm) + IndustryCompany, ///< Production changes of industry serviced by local company + IndustryOther, ///< Production changes of industry serviced by competitor(s) + IndustryNobody, ///< Other industry production changes + Advice, ///< Bits of news about vehicles of the company + NewVehicles, ///< New vehicle has become available + Acceptance, ///< A type of cargo is (no longer) accepted + Subsidies, ///< News about subsidies (announcements, expirations, acceptance) + General, ///< General news (from towns) + + 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 { AircraftDestinationTooFar, ///< Next (order) destination is too far for the aircraft type. AutorenewFailed, ///< Autorenew or autoreplace failed. @@ -98,10 +99,10 @@ using NewsFlags = EnumBitSet; /** * News display options */ -enum NewsDisplay : uint8_t { - ND_OFF, ///< Only show a reminder in the status bar - ND_SUMMARY, ///< Show ticker - ND_FULL, ///< Show newspaper +enum class NewsDisplay : uint8_t { + Off, ///< Only show a reminder in the status bar + Summary, ///< Show ticker + Full, ///< Show newspaper }; /** diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 4ff9cf5d2a..68b2a37db6 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -550,10 +550,10 @@ static void RoadVehCrash(RoadVehicle *v) SetDParam(0, victims); 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) { - newstype = NT_ACCIDENT_OTHER; + newstype = NewsType::AccidentOther; } AddTileNewsItem(newsitem, newstype, v->tile); @@ -692,7 +692,7 @@ static void RoadVehArrivesAt(const RoadVehicle *v, Station *st) SetDParam(0, st->index); AddVehicleNewsItem( 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, st->index ); @@ -706,7 +706,7 @@ static void RoadVehArrivesAt(const RoadVehicle *v, Station *st) SetDParam(0, st->index); AddVehicleNewsItem( 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, st->index ); diff --git a/src/script/api/game_changelog.hpp b/src/script/api/game_changelog.hpp index 249b610586..6b3a90623f 100644 --- a/src/script/api/game_changelog.hpp +++ b/src/script/api/game_changelog.hpp @@ -293,7 +293,7 @@ * \li GSEngine::IsValidEngine and GSEngine::IsBuildable when outside GSCompanyMode scope * \li GSEventExclusiveTransportRights * \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 GSStation::IsAirportClosed * \li GSStation::OpenCloseAirport diff --git a/src/script/api/script_news.hpp b/src/script/api/script_news.hpp index 808964f7ba..75daef912d 100644 --- a/src/script/api/script_news.hpp +++ b/src/script/api/script_news.hpp @@ -24,13 +24,13 @@ public: */ enum NewsType { /* Arbitrary selection of NewsTypes which might make sense for scripts */ - NT_ACCIDENT = ::NT_ACCIDENT, ///< Category accidents. - NT_COMPANY_INFO = ::NT_COMPANY_INFO, ///< Category company info. - NT_ECONOMY = ::NT_ECONOMY, ///< Category economy. - NT_ADVICE = ::NT_ADVICE, ///< Category vehicle advice. - NT_ACCEPTANCE = ::NT_ACCEPTANCE, ///< Category acceptance changes. - NT_SUBSIDIES = ::NT_SUBSIDIES, ///< Category subsidies. - NT_GENERAL = ::NT_GENERAL, ///< Category general. + NT_ACCIDENT = to_underlying(::NewsType::Accident), ///< Category accidents. + NT_COMPANY_INFO = to_underlying(::NewsType::CompanyInfo), ///< Category company info. + NT_ECONOMY = to_underlying(::NewsType::Economy), ///< Category economy. + NT_ADVICE = to_underlying(::NewsType::Advice), ///< Category vehicle advice. + NT_ACCEPTANCE = to_underlying(::NewsType::Acceptance), ///< Category acceptance changes. + NT_SUBSIDIES = to_underlying(::NewsType::Subsidies), ///< Category subsidies. + 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_TOWN this parameter should be a valid townID (ScriptTown::IsValidTown). * @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 company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID. * @pre The \a reference condition must be fulfilled. diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 37c9d94bca..2e6c9db0c5 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -474,7 +474,7 @@ static void ShipArrivesAt(const Vehicle *v, Station *st) SetDParam(0, st->index); AddVehicleNewsItem( 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, st->index ); diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 6a477c13a0..10b54dbf60 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -532,7 +532,7 @@ static void ShowRejectOrAcceptNews(const Station *st, CargoTypes cargoes, bool r SetDParam(0, st->index); SetDParam(1, cargoes); 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); } /** diff --git a/src/subsidy.cpp b/src/subsidy.cpp index e04ddee70c..b0f678497e 100644 --- a/src/subsidy.cpp +++ b/src/subsidy.cpp @@ -56,7 +56,7 @@ void Subsidy::AwardTo(CompanyID company) SetDParamStr(0, company_name); AddNewsItem( 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 ); 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; std::pair 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->dst_type, s->dst, POS_DST); AI::BroadcastNewEvent(new ScriptEventSubsidyOffer(s->index)); @@ -488,13 +488,13 @@ static IntervalTimer _economy_subsidies_monthly({TimerGameEcon if (--s->remaining == 0) { if (!s->IsAwarded()) { std::pair 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)); Game::NewEvent(new ScriptEventSubsidyOfferExpired(s->index)); } else { if (s->awarded == _local_company) { std::pair 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)); Game::NewEvent(new ScriptEventSubsidyExpired(s->index)); diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 5127286271..d44df2f4fa 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -2229,7 +2229,7 @@ std::tuple CmdFoundTown(DoCommandFlag flags, TileInd if (_current_company == OWNER_DEITY) { SetDParam(0, t->index); - AddTileNewsItem(STR_NEWS_NEW_TOWN_UNSPONSORED, NT_INDUSTRY_OPEN, tile); + AddTileNewsItem(STR_NEWS_NEW_TOWN_UNSPONSORED, NewsType::IndustryOpen, tile); } else { SetDParam(0, _current_company); std::string company_name = GetString(STR_COMPANY_NAME); @@ -2237,7 +2237,7 @@ std::tuple CmdFoundTown(DoCommandFlag flags, TileInd SetDParamStr(0, company_name); 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)); Game::NewEvent(new ScriptEventTownFounded(t->index)); @@ -3388,7 +3388,7 @@ static CommandCost TownActionRoadRebuild(Town *t, DoCommandFlag flags) AddNewsItem( 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)); 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(2, t->index); 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)); Game::NewEvent(new ScriptEventExclusiveTransportRights((ScriptCompany::CompanyID)(Owner)_current_company, t->index)); } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index e7aded5e8d..e4fc0261ad 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -3011,7 +3011,7 @@ static void TrainEnterStation(Train *v, StationID station) SetDParam(0, st->index); AddVehicleNewsItem( 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, st->index ); @@ -3246,7 +3246,7 @@ static bool CheckTrainCollision(Train *v) if (tcc.num == 0) return false; 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); if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_13_TRAIN_COLLISION, v); diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 27773d30c7..68edecd872 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -1009,7 +1009,7 @@ static void FloodVehicle(Vehicle *v) 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)); 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); if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v); }