From cee7f8d34c64675630e86a393c064e814cbb174e Mon Sep 17 00:00:00 2001 From: pizza2004 Date: Sun, 26 Jul 2020 02:46:22 -0600 Subject: [PATCH] Close #12397: Refactor NEWS_ITEM_* to use strong enum --- src/openrct2-ui/windows/GameBottomToolbar.cpp | 22 ++++--- src/openrct2-ui/windows/NewRide.cpp | 2 +- src/openrct2-ui/windows/News.cpp | 34 ++++++---- src/openrct2-ui/windows/Research.cpp | 2 +- src/openrct2/ReplayManager.cpp | 4 +- src/openrct2/actions/RideDemolishAction.hpp | 2 +- src/openrct2/interface/InteractiveConsole.cpp | 24 +++---- src/openrct2/management/Award.cpp | 2 +- src/openrct2/management/Marketing.cpp | 2 +- src/openrct2/management/NewsItem.cpp | 64 ++++++++++--------- src/openrct2/management/NewsItem.h | 53 ++++++++------- src/openrct2/management/Research.cpp | 4 +- src/openrct2/peep/Guest.cpp | 8 +-- src/openrct2/peep/Peep.cpp | 31 ++++----- src/openrct2/rct1/S4Importer.cpp | 7 +- src/openrct2/rct2/S6Exporter.cpp | 2 +- src/openrct2/rct2/S6Importer.cpp | 4 +- src/openrct2/ride/Ride.cpp | 12 ++-- src/openrct2/ride/Vehicle.cpp | 4 +- src/openrct2/scenario/Scenario.cpp | 12 ++-- src/openrct2/scripting/ScPark.hpp | 31 +++++---- 21 files changed, 178 insertions(+), 148 deletions(-) diff --git a/src/openrct2-ui/windows/GameBottomToolbar.cpp b/src/openrct2-ui/windows/GameBottomToolbar.cpp index df1119380b..7d2fd1393a 100644 --- a/src/openrct2-ui/windows/GameBottomToolbar.cpp +++ b/src/openrct2-ui/windows/GameBottomToolbar.cpp @@ -337,7 +337,7 @@ static void window_game_bottom_toolbar_invalidate(rct_window* w) if (subjectLoc == std::nullopt) w->disabled_widgets |= (1 << WIDX_NEWS_LOCATE); - if (!(news_type_properties[newsItem->Type] & NEWS_TYPE_HAS_SUBJECT)) + if (!(news_type_properties[static_cast(newsItem->Type)] & NEWS_TYPE_HAS_SUBJECT)) { w->disabled_widgets |= (1 << WIDX_NEWS_SUBJECT); window_game_bottom_toolbar_widgets[WIDX_NEWS_SUBJECT].type = WWT_EMPTY; @@ -592,11 +592,11 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo* dpi, rc window_game_bottom_toolbar_widgets[WIDX_NEWS_SUBJECT].top }; switch (newsItem->Type) { - case NEWS_ITEM_RIDE: + case News::ItemType::Ride: gfx_draw_sprite(dpi, SPR_RIDE, screenCoords, 0); break; - case NEWS_ITEM_PEEP_ON_RIDE: - case NEWS_ITEM_PEEP: + case News::ItemType::PeepOnRide: + case News::ItemType::Peep: { if (newsItem->Flags & NEWS_FLAG_HAS_BUTTON) break; @@ -650,21 +650,25 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo* dpi, rc } break; } - case NEWS_ITEM_MONEY: + case News::ItemType::Money: gfx_draw_sprite(dpi, SPR_FINANCE, screenCoords, 0); break; - case NEWS_ITEM_RESEARCH: + case News::ItemType::Research: gfx_draw_sprite(dpi, (newsItem->Assoc < 0x10000 ? SPR_NEW_SCENERY : SPR_NEW_RIDE), screenCoords, 0); break; - case NEWS_ITEM_PEEPS: + case News::ItemType::Peeps: gfx_draw_sprite(dpi, SPR_GUESTS, screenCoords, 0); break; - case NEWS_ITEM_AWARD: + case News::ItemType::Award: gfx_draw_sprite(dpi, SPR_AWARD, screenCoords, 0); break; - case NEWS_ITEM_GRAPH: + case News::ItemType::Graph: gfx_draw_sprite(dpi, SPR_GRAPH, screenCoords, 0); break; + case News::ItemType::Null: + case News::ItemType::Blank: + case News::ItemType::Count: + break; } } diff --git a/src/openrct2-ui/windows/NewRide.cpp b/src/openrct2-ui/windows/NewRide.cpp index 356ee5ba58..08b788d88a 100644 --- a/src/openrct2-ui/windows/NewRide.cpp +++ b/src/openrct2-ui/windows/NewRide.cpp @@ -660,7 +660,7 @@ static void window_new_ride_mouseup(rct_window* w, rct_widgetindex widgetIndex) window_close(w); break; case WIDX_LAST_DEVELOPMENT_BUTTON: - news_item_open_subject(NEWS_ITEM_RESEARCH, gResearchLastItem->rawValue); + news_item_open_subject(News::ItemType::Research, gResearchLastItem->rawValue); break; case WIDX_RESEARCH_FUNDING_BUTTON: context_open_window_view(WV_FINANCES_RESEARCH); diff --git a/src/openrct2-ui/windows/News.cpp b/src/openrct2-ui/windows/News.cpp index 0035e00208..cd14646aca 100644 --- a/src/openrct2-ui/windows/News.cpp +++ b/src/openrct2-ui/windows/News.cpp @@ -198,12 +198,16 @@ static void window_news_scrollmousedown(rct_window* w, int32_t scrollIndex, cons buttonIndex = 0; break; } - else if (mutableScreenCoords.x < 351 && news_type_properties[newsItem.Type] & NEWS_TYPE_HAS_SUBJECT) + else if ( + mutableScreenCoords.x < 351 + && news_type_properties[static_cast(newsItem.Type)] & NEWS_TYPE_HAS_SUBJECT) { buttonIndex = 1; break; } - else if (mutableScreenCoords.x < 376 && news_type_properties[newsItem.Type] & NEWS_TYPE_HAS_LOCATION) + else if ( + mutableScreenCoords.x < 376 + && news_type_properties[static_cast(newsItem.Type)] & NEWS_TYPE_HAS_LOCATION) { buttonIndex = 2; break; @@ -269,7 +273,8 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32 gfx_draw_string_left_wrapped(dpi, &text, { 2, y + lineHeight }, 325, STR_BOTTOM_TOOLBAR_NEWS_TEXT, COLOUR_BRIGHT_GREEN); // Subject button - if ((news_type_properties[newsItem.Type] & NEWS_TYPE_HAS_SUBJECT) && !(newsItem.Flags & NEWS_FLAG_HAS_BUTTON)) + if ((news_type_properties[static_cast(newsItem.Type)] & NEWS_TYPE_HAS_SUBJECT) + && !(newsItem.Flags & NEWS_FLAG_HAS_BUTTON)) { auto screenCoords = ScreenCoordsXY{ 328, y + lineHeight + 4 }; @@ -285,11 +290,11 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32 switch (newsItem.Type) { - case NEWS_ITEM_RIDE: + case News::ItemType::Ride: gfx_draw_sprite(dpi, SPR_RIDE, screenCoords, 0); break; - case NEWS_ITEM_PEEP: - case NEWS_ITEM_PEEP_ON_RIDE: + case News::ItemType::Peep: + case News::ItemType::PeepOnRide: { rct_drawpixelinfo cliped_dpi; if (!clip_drawpixelinfo(&cliped_dpi, dpi, screenCoords + ScreenCoordsXY{ 1, 1 }, 22, 22)) @@ -322,26 +327,31 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32 gfx_draw_sprite(&cliped_dpi, image_id, clipCoords, 0); break; } - case NEWS_ITEM_MONEY: + case News::ItemType::Money: gfx_draw_sprite(dpi, SPR_FINANCE, screenCoords, 0); break; - case NEWS_ITEM_RESEARCH: + case News::ItemType::Research: gfx_draw_sprite(dpi, newsItem.Assoc < 0x10000 ? SPR_NEW_SCENERY : SPR_NEW_RIDE, screenCoords, 0); break; - case NEWS_ITEM_PEEPS: + case News::ItemType::Peeps: gfx_draw_sprite(dpi, SPR_GUESTS, screenCoords, 0); break; - case NEWS_ITEM_AWARD: + case News::ItemType::Award: gfx_draw_sprite(dpi, SPR_AWARD, screenCoords, 0); break; - case NEWS_ITEM_GRAPH: + case News::ItemType::Graph: gfx_draw_sprite(dpi, SPR_GRAPH, screenCoords, 0); break; + case News::ItemType::Null: + case News::ItemType::Blank: + case News::ItemType::Count: + break; } } // Location button - if ((news_type_properties[newsItem.Type] & NEWS_TYPE_HAS_LOCATION) && !(newsItem.Flags & NEWS_FLAG_HAS_BUTTON)) + if ((news_type_properties[static_cast(newsItem.Type)] & NEWS_TYPE_HAS_LOCATION) + && !(newsItem.Flags & NEWS_FLAG_HAS_BUTTON)) { auto screenCoords = ScreenCoordsXY{ 352, y + lineHeight + 4 }; diff --git a/src/openrct2-ui/windows/Research.cpp b/src/openrct2-ui/windows/Research.cpp index c11c74897b..0805d3027e 100644 --- a/src/openrct2-ui/windows/Research.cpp +++ b/src/openrct2-ui/windows/Research.cpp @@ -282,7 +282,7 @@ static void window_research_development_mouseup(rct_window* w, rct_widgetindex w window_research_set_page(w, widgetIndex - WIDX_TAB_1); break; case WIDX_LAST_DEVELOPMENT_BUTTON: - news_item_open_subject(NEWS_ITEM_RESEARCH, gResearchLastItem->rawValue); + news_item_open_subject(News::ItemType::Research, gResearchLastItem->rawValue); break; } } diff --git a/src/openrct2/ReplayManager.cpp b/src/openrct2/ReplayManager.cpp index 198f47d837..ff1099c01b 100644 --- a/src/openrct2/ReplayManager.cpp +++ b/src/openrct2/ReplayManager.cpp @@ -339,7 +339,7 @@ namespace OpenRCT2 _currentRecording.reset(); - NewsItem* news = news_item_add_to_queue_raw(NEWS_ITEM_BLANK, "Replay recording stopped", 0); + NewsItem* news = news_item_add_to_queue_raw(News::ItemType::Blank, "Replay recording stopped", 0); news->Flags |= NEWS_FLAG_HAS_BUTTON; // Has no subject. return result; @@ -467,7 +467,7 @@ namespace OpenRCT2 // During normal playback we pause the game if stopped. if (_mode == ReplayMode::PLAYING) { - NewsItem* news = news_item_add_to_queue_raw(NEWS_ITEM_BLANK, "Replay playback complete", 0); + NewsItem* news = news_item_add_to_queue_raw(News::ItemType::Blank, "Replay playback complete", 0); news->Flags |= NEWS_FLAG_HAS_BUTTON; // Has no subject. } diff --git a/src/openrct2/actions/RideDemolishAction.hpp b/src/openrct2/actions/RideDemolishAction.hpp index 9e0e49dd10..add287499d 100644 --- a/src/openrct2/actions/RideDemolishAction.hpp +++ b/src/openrct2/actions/RideDemolishAction.hpp @@ -141,7 +141,7 @@ private: sub_6CB945(ride); ride_clear_leftover_entrances(ride); - news_item_disable_news(NEWS_ITEM_RIDE, _rideIndex); + news_item_disable_news(News::ItemType::Ride, _rideIndex); for (BannerIndex i = 0; i < MAX_BANNERS; i++) { diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index 73c7006042..33e2cdeace 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1659,19 +1659,19 @@ static int32_t cc_add_news_item([[maybe_unused]] InteractiveConsole& console, [[ if (argv.size() < 3) { console.WriteLineWarning("Too few arguments"); - static_assert(NEWS_ITEM_TYPE_COUNT == 10, "NEWS_ITEM_TYPE_COUNT changed, update console command!"); + static_assert(News::ItemTypeCount == 10, "News::ItemType::Count changed, update console command!"); console.WriteLine("add_news_item "); console.WriteLine("type is one of:"); - console.WriteLine(" 0 (NEWS_ITEM_NULL)"); - console.WriteLine(" 1 (NEWS_ITEM_RIDE)"); - console.WriteLine(" 2 (NEWS_ITEM_PEEP_ON_RIDE)"); - console.WriteLine(" 3 (NEWS_ITEM_PEEP)"); - console.WriteLine(" 4 (NEWS_ITEM_MONEY)"); - console.WriteLine(" 5 (NEWS_ITEM_BLANK)"); - console.WriteLine(" 6 (NEWS_ITEM_RESEARCH)"); - console.WriteLine(" 7 (NEWS_ITEM_PEEPS)"); - console.WriteLine(" 8 (NEWS_ITEM_AWARD)"); - console.WriteLine(" 9 (NEWS_ITEM_GRAPH)"); + console.WriteLine(" 0 (News::ItemType::Null)"); + console.WriteLine(" 1 (News::ItemType::Ride)"); + console.WriteLine(" 2 (News::ItemType::PeepOnRide)"); + console.WriteLine(" 3 (News::ItemType::Peep)"); + console.WriteLine(" 4 (News::ItemType::Money)"); + console.WriteLine(" 5 (News::ItemType::Blank)"); + console.WriteLine(" 6 (News::ItemType::Research)"); + console.WriteLine(" 7 (News::ItemType::Peeps)"); + console.WriteLine(" 8 (News::ItemType::Award)"); + console.WriteLine(" 9 (News::ItemType::Graph)"); console.WriteLine("message is the message to display, wrapped in quotes for multiple words"); console.WriteLine("assoc is the associated id of ride/peep/tile/etc."); return 1; @@ -1679,7 +1679,7 @@ static int32_t cc_add_news_item([[maybe_unused]] InteractiveConsole& console, [[ auto type = atoi(argv[0].c_str()); auto msg = argv[1].c_str(); auto assoc = atoi(argv[2].c_str()); - news_item_add_to_queue_raw(type, msg, assoc); + news_item_add_to_queue_raw(static_cast(type), msg, assoc); return 0; } diff --git a/src/openrct2/management/Award.cpp b/src/openrct2/management/Award.cpp index a6a78c57cd..787125b17c 100644 --- a/src/openrct2/management/Award.cpp +++ b/src/openrct2/management/Award.cpp @@ -636,7 +636,7 @@ void award_update_all() gCurrentAwards[freeAwardEntryIndex].Time = 5; if (gConfigNotifications.park_award) { - news_item_add_to_queue(NEWS_ITEM_AWARD, AwardNewsStrings[awardType], 0); + news_item_add_to_queue(News::ItemType::Award, AwardNewsStrings[awardType], 0); } window_invalidate_by_class(WC_PARK_INFORMATION); } diff --git a/src/openrct2/management/Marketing.cpp b/src/openrct2/management/Marketing.cpp index 539e7babc9..bcbef43f02 100644 --- a/src/openrct2/management/Marketing.cpp +++ b/src/openrct2/management/Marketing.cpp @@ -85,7 +85,7 @@ static void marketing_raise_finished_notification(const MarketingCampaign& campa ft.Add(ShopItems[campaign.ShopItemType].Naming.Plural); } - news_item_add_to_queue(NEWS_ITEM_MONEY, MarketingCampaignNames[campaign.Type][2], 0); + news_item_add_to_queue(News::ItemType::Money, MarketingCampaignNames[campaign.Type][2], 0); } } diff --git a/src/openrct2/management/NewsItem.cpp b/src/openrct2/management/NewsItem.cpp index c0a5470883..35cb3e9410 100644 --- a/src/openrct2/management/NewsItem.cpp +++ b/src/openrct2/management/NewsItem.cpp @@ -28,16 +28,16 @@ NewsItemQueues gNewsItems; /** rct2: 0x0097BE7C */ const uint8_t news_type_properties[] = { - 0, // NEWS_ITEM_NULL - NEWS_TYPE_HAS_LOCATION | NEWS_TYPE_HAS_SUBJECT, // NEWS_ITEM_RIDE - NEWS_TYPE_HAS_LOCATION | NEWS_TYPE_HAS_SUBJECT, // NEWS_ITEM_PEEP_ON_RIDE - NEWS_TYPE_HAS_LOCATION | NEWS_TYPE_HAS_SUBJECT, // NEWS_ITEM_PEEP - NEWS_TYPE_HAS_SUBJECT, // NEWS_ITEM_MONEY - NEWS_TYPE_HAS_LOCATION, // NEWS_ITEM_BLANK - NEWS_TYPE_HAS_SUBJECT, // NEWS_ITEM_RESEARCH - NEWS_TYPE_HAS_SUBJECT, // NEWS_ITEM_PEEPS - NEWS_TYPE_HAS_SUBJECT, // NEWS_ITEM_AWARD - NEWS_TYPE_HAS_SUBJECT, // NEWS_ITEM_GRAPH + 0, // News::ItemType::Null + NEWS_TYPE_HAS_LOCATION | NEWS_TYPE_HAS_SUBJECT, // News::ItemType::Ride + NEWS_TYPE_HAS_LOCATION | NEWS_TYPE_HAS_SUBJECT, // News::ItemType::PeepOnRide + NEWS_TYPE_HAS_LOCATION | NEWS_TYPE_HAS_SUBJECT, // News::ItemType::Peep + NEWS_TYPE_HAS_SUBJECT, // News::ItemType::Money + NEWS_TYPE_HAS_LOCATION, // News::ItemType::Blank + NEWS_TYPE_HAS_SUBJECT, // News::ItemType::Research + NEWS_TYPE_HAS_SUBJECT, // News::ItemType::Peeps + NEWS_TYPE_HAS_SUBJECT, // News::ItemType::Award + NEWS_TYPE_HAS_SUBJECT, // News::ItemType::Graph }; NewsItem& NewsItemQueues::Current() @@ -215,13 +215,13 @@ void NewsItemQueues::ArchiveCurrent() * * rct2: 0x0066BA74 */ -std::optional news_item_get_subject_location(int32_t type, int32_t subject) +std::optional news_item_get_subject_location(News::ItemType type, int32_t subject) { std::optional subjectLoc{ std::nullopt }; switch (type) { - case NEWS_ITEM_RIDE: + case News::ItemType::Ride: { Ride* ride = get_ride(subject); if (ride == nullptr || ride->overall_view.isNull()) @@ -232,7 +232,7 @@ std::optional news_item_get_subject_location(int32_t type, int32_t su subjectLoc = CoordsXYZ{ rideViewCentre, tile_element_height(rideViewCentre) }; break; } - case NEWS_ITEM_PEEP_ON_RIDE: + case News::ItemType::PeepOnRide: { auto peep = TryGetEntity(subject); if (peep == nullptr) @@ -269,7 +269,7 @@ std::optional news_item_get_subject_location(int32_t type, int32_t su } break; } - case NEWS_ITEM_PEEP: + case News::ItemType::Peep: { auto peep = TryGetEntity(subject); if (peep != nullptr) @@ -278,7 +278,7 @@ std::optional news_item_get_subject_location(int32_t type, int32_t su } break; } - case NEWS_ITEM_BLANK: + case News::ItemType::Blank: { auto subjectUnsigned = static_cast(subject); auto subjectXY = CoordsXY{ static_cast(subjectUnsigned & 0xFFFF), @@ -306,7 +306,7 @@ NewsItem* NewsItemQueues::FirstOpenOrNewSlot() // The for loop above guarantees there is always an extra element to use assert(Recent.capacity() - Recent.size() >= 2); auto newsItem = res + 1; - newsItem->Type = NEWS_ITEM_NULL; + newsItem->Type = News::ItemType::Null; return &*res; } @@ -315,7 +315,7 @@ NewsItem* NewsItemQueues::FirstOpenOrNewSlot() * * rct2: 0x0066DF55 */ -NewsItem* news_item_add_to_queue(uint8_t type, rct_string_id string_id, uint32_t assoc) +NewsItem* news_item_add_to_queue(News::ItemType type, rct_string_id string_id, uint32_t assoc) { utf8 buffer[256]; void* args = gCommonFormatArgs; @@ -325,7 +325,7 @@ NewsItem* news_item_add_to_queue(uint8_t type, rct_string_id string_id, uint32_t return news_item_add_to_queue_raw(type, buffer, assoc); } -NewsItem* news_item_add_to_queue_raw(uint8_t type, const utf8* text, uint32_t assoc) +NewsItem* news_item_add_to_queue_raw(News::ItemType type, const utf8* text, uint32_t assoc) { NewsItem* newsItem = gNewsItems.FirstOpenOrNewSlot(); newsItem->Type = type; @@ -345,19 +345,19 @@ NewsItem* news_item_add_to_queue_raw(uint8_t type, const utf8* text, uint32_t as * rct2: 0x0066EBE6 * */ -void news_item_open_subject(int32_t type, int32_t subject) +void news_item_open_subject(News::ItemType type, int32_t subject) { switch (type) { - case NEWS_ITEM_RIDE: + case News::ItemType::Ride: { auto intent = Intent(WC_RIDE); intent.putExtra(INTENT_EXTRA_RIDE_ID, subject); context_open_intent(&intent); break; } - case NEWS_ITEM_PEEP_ON_RIDE: - case NEWS_ITEM_PEEP: + case News::ItemType::PeepOnRide: + case News::ItemType::Peep: { auto peep = TryGetEntity(subject); if (peep != nullptr) @@ -368,10 +368,10 @@ void news_item_open_subject(int32_t type, int32_t subject) } break; } - case NEWS_ITEM_MONEY: + case News::ItemType::Money: context_open_window(WC_FINANCES); break; - case NEWS_ITEM_RESEARCH: + case News::ItemType::Research: { auto item = ResearchItem(subject, 0, 0); if (item.type == Research::EntryType::Ride) @@ -405,7 +405,7 @@ void news_item_open_subject(int32_t type, int32_t subject) window_event_mouse_down_call(window, WC_SCENERY__WIDX_SCENERY_TAB_1 + subject); break; } - case NEWS_ITEM_PEEPS: + case News::ItemType::Peeps: { auto intent = Intent(WC_GUEST_LIST); intent.putExtra(INTENT_EXTRA_GUEST_LIST_FILTER, GLFT_GUESTS_THINKING_X); @@ -413,12 +413,16 @@ void news_item_open_subject(int32_t type, int32_t subject) context_open_intent(&intent); break; } - case NEWS_ITEM_AWARD: + case News::ItemType::Award: context_open_window_view(WV_PARK_AWARDS); break; - case NEWS_ITEM_GRAPH: + case News::ItemType::Graph: context_open_window_view(WV_PARK_RATING); break; + case News::ItemType::Null: + case News::ItemType::Blank: + case News::ItemType::Count: + break; } } @@ -426,7 +430,7 @@ void news_item_open_subject(int32_t type, int32_t subject) * * rct2: 0x0066E407 */ -void news_item_disable_news(uint8_t type, uint32_t assoc) +void news_item_disable_news(News::ItemType type, uint32_t assoc) { // TODO: write test invalidating windows gNewsItems.ForeachRecentNews([type, assoc](auto& newsItem) { @@ -462,7 +466,7 @@ void news_item_remove(int32_t index) return; // News item is already null, no need to remove it - if (gNewsItems[index].Type == NEWS_ITEM_NULL) + if (gNewsItems[index].Type == News::ItemType::Null) return; size_t newsBoundary = index < NEWS_ITEM_HISTORY_START ? NEWS_ITEM_HISTORY_START : MAX_NEWS_ITEMS; @@ -470,5 +474,5 @@ void news_item_remove(int32_t index) { gNewsItems[i] = gNewsItems[i + 1]; } - gNewsItems[newsBoundary - 1].Type = NEWS_ITEM_NULL; + gNewsItems[newsBoundary - 1].Type = News::ItemType::Null; } diff --git a/src/openrct2/management/NewsItem.h b/src/openrct2/management/NewsItem.h index 808084b6b7..2d2d2fd56a 100644 --- a/src/openrct2/management/NewsItem.h +++ b/src/openrct2/management/NewsItem.h @@ -18,20 +18,25 @@ struct CoordsXYZ; -enum +namespace News { - NEWS_ITEM_NULL, - NEWS_ITEM_RIDE, - NEWS_ITEM_PEEP_ON_RIDE, - NEWS_ITEM_PEEP, - NEWS_ITEM_MONEY, - NEWS_ITEM_BLANK, - NEWS_ITEM_RESEARCH, - NEWS_ITEM_PEEPS, - NEWS_ITEM_AWARD, - NEWS_ITEM_GRAPH, - NEWS_ITEM_TYPE_COUNT -}; + enum class ItemType : uint8_t + { + Null, + Ride, + PeepOnRide, + Peep, + Money, + Blank, + Research, + Peeps, + Award, + Graph, + Count + }; + + constexpr size_t ItemTypeCount = static_cast(News::ItemType::Count); +} // namespace News enum { @@ -49,7 +54,7 @@ enum */ struct NewsItem { - uint8_t Type; + News::ItemType Type; uint8_t Flags; uint32_t Assoc; uint16_t Ticks; @@ -59,7 +64,7 @@ struct NewsItem constexpr bool IsEmpty() const noexcept { - return Type == NEWS_ITEM_NULL; + return Type == News::ItemType::Null; } }; @@ -88,7 +93,7 @@ public: NewsItemQueue() { - Queue[0].Type = NEWS_ITEM_NULL; + Queue[0].Type = News::ItemType::Null; } constexpr iterator begin() noexcept @@ -146,7 +151,7 @@ public: void pop_front() { std::move(std::begin(Queue) + 1, std::end(Queue), std::begin(Queue)); - Queue[N - 1].Type = NEWS_ITEM_NULL; + Queue[N - 1].Type = News::ItemType::Null; } void push_back(const_reference item) @@ -163,7 +168,7 @@ public: *it = item; ++it; if (std::distance(it, std::end(Queue))) - it->Type = NEWS_ITEM_NULL; + it->Type = News::ItemType::Null; } } @@ -183,7 +188,7 @@ public: void clear() noexcept { - front().Type = NEWS_ITEM_NULL; + front().Type = News::ItemType::Null; } private: @@ -246,14 +251,14 @@ void news_item_init_queue(); void news_item_update_current(); void news_item_close_current(); -std::optional news_item_get_subject_location(int32_t type, int32_t subject); +std::optional news_item_get_subject_location(News::ItemType type, int32_t subject); -NewsItem* news_item_add_to_queue(uint8_t type, rct_string_id string_id, uint32_t assoc); -NewsItem* news_item_add_to_queue_raw(uint8_t type, const utf8* text, uint32_t assoc); +NewsItem* news_item_add_to_queue(News::ItemType type, rct_string_id string_id, uint32_t assoc); +NewsItem* news_item_add_to_queue_raw(News::ItemType type, const utf8* text, uint32_t assoc); -void news_item_open_subject(int32_t type, int32_t subject); +void news_item_open_subject(News::ItemType type, int32_t subject); -void news_item_disable_news(uint8_t type, uint32_t assoc); +void news_item_disable_news(News::ItemType type, uint32_t assoc); NewsItem* news_item_get(int32_t index); diff --git a/src/openrct2/management/Research.cpp b/src/openrct2/management/Research.cpp index 38cdd14404..2406e69d41 100644 --- a/src/openrct2/management/Research.cpp +++ b/src/openrct2/management/Research.cpp @@ -266,7 +266,7 @@ void research_finish_item(ResearchItem* researchItem) { if (gConfigNotifications.ride_researched) { - news_item_add_to_queue(NEWS_ITEM_RESEARCH, availabilityString, researchItem->rawValue); + news_item_add_to_queue(News::ItemType::Research, availabilityString, researchItem->rawValue); } } @@ -289,7 +289,7 @@ void research_finish_item(ResearchItem* researchItem) if (gConfigNotifications.ride_researched) { news_item_add_to_queue( - NEWS_ITEM_RESEARCH, STR_NEWS_ITEM_RESEARCH_NEW_SCENERY_SET_AVAILABLE, researchItem->rawValue); + News::ItemType::Research, STR_NEWS_ITEM_RESEARCH_NEW_SCENERY_SET_AVAILABLE, researchItem->rawValue); } } diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index fe39b40cc1..6e1385b4d3 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -1702,7 +1702,7 @@ loc_69B221: ft.Add(ShopItems[shopItem].Naming.Indefinite); if (gConfigNotifications.guest_bought_item) { - news_item_add_to_queue(2, STR_PEEP_TRACKING_NOTIFICATION_BOUGHT_X, sprite_index); + news_item_add_to_queue(News::ItemType::PeepOnRide, STR_PEEP_TRACKING_NOTIFICATION_BOUGHT_X, sprite_index); } } @@ -3734,7 +3734,7 @@ void Guest::UpdateRideAdvanceThroughEntrance() ride->FormatNameTo(ft); if (gConfigNotifications.ride_warnings) { - news_item_add_to_queue(NEWS_ITEM_RIDE, STR_GUESTS_GETTING_STUCK_ON_RIDE, CurrentRide); + news_item_add_to_queue(News::ItemType::Ride, STR_GUESTS_GETTING_STUCK_ON_RIDE, CurrentRide); } } @@ -3911,7 +3911,7 @@ void Guest::UpdateRideFreeVehicleEnterRide(Ride* ride) if (gConfigNotifications.guest_on_ride) { - news_item_add_to_queue(NEWS_ITEM_PEEP_ON_RIDE, msg_string, sprite_index); + news_item_add_to_queue(News::ItemType::PeepOnRide, msg_string, sprite_index); } } @@ -5012,7 +5012,7 @@ void Guest::UpdateRideLeaveExit() if (gConfigNotifications.guest_left_ride) { - news_item_add_to_queue(NEWS_ITEM_PEEP_ON_RIDE, STR_PEEP_TRACKING_LEFT_RIDE_X, sprite_index); + news_item_add_to_queue(News::ItemType::PeepOnRide, STR_PEEP_TRACKING_LEFT_RIDE_X, sprite_index); } } diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 257fb2ce22..604494ce97 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -816,7 +816,7 @@ void peep_sprite_remove(Peep* peep) bool wasGuest = peep->AssignedPeepType == PeepType::Guest; if (peep->AssignedPeepType == PeepType::Guest) { - news_item_disable_news(NEWS_ITEM_PEEP_ON_RIDE, peep->sprite_index); + news_item_disable_news(News::ItemType::PeepOnRide, peep->sprite_index); } else { @@ -825,7 +825,7 @@ void peep_sprite_remove(Peep* peep) staff_update_greyed_patrol_areas(); peep->AssignedPeepType = PeepType::Staff; - news_item_disable_news(NEWS_ITEM_PEEP, peep->sprite_index); + news_item_disable_news(News::ItemType::Peep, peep->sprite_index); } sprite_remove(peep); @@ -872,7 +872,7 @@ void Peep::UpdateFalling() { auto ft = Formatter::Common(); FormatNameTo(ft); - news_item_add_to_queue(NEWS_ITEM_BLANK, STR_NEWS_ITEM_GUEST_DROWNED, x | (y << 16)); + news_item_add_to_queue(News::ItemType::Blank, STR_NEWS_ITEM_GUEST_DROWNED, x | (y << 16)); } gParkRatingCasualtyPenalty = std::min(gParkRatingCasualtyPenalty + 25, 1000); @@ -1238,7 +1238,7 @@ void peep_problem_warnings_update() warning_throttle[0] = 4; if (gConfigNotifications.guest_warnings) { - news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_ARE_HUNGRY, 20); + news_item_add_to_queue(News::ItemType::Peeps, STR_PEEPS_ARE_HUNGRY, 20); } } @@ -1249,7 +1249,7 @@ void peep_problem_warnings_update() warning_throttle[1] = 4; if (gConfigNotifications.guest_warnings) { - news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_ARE_THIRSTY, 21); + news_item_add_to_queue(News::ItemType::Peeps, STR_PEEPS_ARE_THIRSTY, 21); } } @@ -1260,7 +1260,7 @@ void peep_problem_warnings_update() warning_throttle[2] = 4; if (gConfigNotifications.guest_warnings) { - news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_CANT_FIND_TOILET, 22); + news_item_add_to_queue(News::ItemType::Peeps, STR_PEEPS_CANT_FIND_TOILET, 22); } } @@ -1271,7 +1271,7 @@ void peep_problem_warnings_update() warning_throttle[3] = 4; if (gConfigNotifications.guest_warnings) { - news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_DISLIKE_LITTER, 26); + news_item_add_to_queue(News::ItemType::Peeps, STR_PEEPS_DISLIKE_LITTER, 26); } } @@ -1282,7 +1282,7 @@ void peep_problem_warnings_update() warning_throttle[4] = 4; if (gConfigNotifications.guest_warnings) { - news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_DISGUSTED_BY_PATHS, 31); + news_item_add_to_queue(News::ItemType::Peeps, STR_PEEPS_DISGUSTED_BY_PATHS, 31); } } @@ -1293,7 +1293,7 @@ void peep_problem_warnings_update() warning_throttle[5] = 4; if (gConfigNotifications.guest_warnings) { - news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_DISLIKE_VANDALISM, 33); + news_item_add_to_queue(News::ItemType::Peeps, STR_PEEPS_DISLIKE_VANDALISM, 33); } } @@ -1304,7 +1304,7 @@ void peep_problem_warnings_update() warning_throttle[6] = 4; if (gConfigNotifications.guest_warnings) { - news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_GETTING_LOST_OR_STUCK, 27); + news_item_add_to_queue(News::ItemType::Peeps, STR_PEEPS_GETTING_LOST_OR_STUCK, 27); } } else if (lost_counter >= PEEP_LOST_WARNING_THRESHOLD) @@ -1312,7 +1312,7 @@ void peep_problem_warnings_update() warning_throttle[6] = 4; if (gConfigNotifications.guest_warnings) { - news_item_add_to_queue(NEWS_ITEM_PEEPS, STR_PEEPS_GETTING_LOST_OR_STUCK, 16); + news_item_add_to_queue(News::ItemType::Peeps, STR_PEEPS_GETTING_LOST_OR_STUCK, 16); } } } @@ -2397,7 +2397,8 @@ static void peep_interact_with_entrance(Peep* peep, const CoordsXYE& coords, uin ride->FormatNameTo(ft); if (gConfigNotifications.guest_queuing_for_ride) { - news_item_add_to_queue(NEWS_ITEM_PEEP_ON_RIDE, STR_PEEP_TRACKING_PEEP_JOINED_QUEUE_FOR_X, peep->sprite_index); + news_item_add_to_queue( + News::ItemType::PeepOnRide, STR_PEEP_TRACKING_PEEP_JOINED_QUEUE_FOR_X, peep->sprite_index); } } } @@ -2458,7 +2459,7 @@ static void peep_interact_with_entrance(Peep* peep, const CoordsXYE& coords, uin peep->FormatNameTo(ft); if (gConfigNotifications.guest_left_park) { - news_item_add_to_queue(NEWS_ITEM_PEEP_ON_RIDE, STR_PEEP_TRACKING_LEFT_PARK, peep->sprite_index); + news_item_add_to_queue(News::ItemType::PeepOnRide, STR_PEEP_TRACKING_LEFT_PARK, peep->sprite_index); } } return; @@ -2826,7 +2827,7 @@ static void peep_interact_with_path(Peep* peep, const CoordsXYE& coords) if (gConfigNotifications.guest_queuing_for_ride) { news_item_add_to_queue( - NEWS_ITEM_PEEP_ON_RIDE, STR_PEEP_TRACKING_PEEP_JOINED_QUEUE_FOR_X, peep->sprite_index); + News::ItemType::PeepOnRide, STR_PEEP_TRACKING_PEEP_JOINED_QUEUE_FOR_X, peep->sprite_index); } } @@ -2936,7 +2937,7 @@ static bool peep_interact_with_shop(Peep* peep, const CoordsXYE& coords) : STR_PEEP_TRACKING_PEEP_IS_ON_X; if (gConfigNotifications.guest_used_facility) { - news_item_add_to_queue(NEWS_ITEM_PEEP_ON_RIDE, string_id, peep->sprite_index); + news_item_add_to_queue(News::ItemType::PeepOnRide, string_id, peep->sprite_index); } } } diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index c1ec835373..ad9a0c21fd 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1364,8 +1364,9 @@ private: for (auto i = 0; i < MAX_NEWS_ITEMS; i++) { rct12_news_item* newsItem = &_s4.messages[i]; + News::ItemType type = static_cast(newsItem->Type); - if (newsItem->Type == NEWS_ITEM_PEEP || newsItem->Type == NEWS_ITEM_PEEP_ON_RIDE) + if (type == News::ItemType::Peep || type == News::ItemType::PeepOnRide) { newsItem->Assoc = MapSpriteIndex(newsItem->Assoc, spriteIndexMap); } @@ -2532,14 +2533,14 @@ private: const rct12_news_item* src = &_s4.messages[i]; NewsItem* dst = &gNewsItems[i]; - dst->Type = src->Type; + dst->Type = static_cast(src->Type); dst->Flags = src->Flags; dst->Ticks = src->Ticks; dst->MonthYear = src->MonthYear; dst->Day = src->Day; std::copy(std::begin(src->Text), std::end(src->Text), dst->Text); - if (dst->Type == NEWS_ITEM_RESEARCH) + if (dst->Type == News::ItemType::Research) { uint8_t researchItem = src->Assoc & 0x000000FF; uint8_t researchType = (src->Assoc & 0x00FF0000) >> 16; diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index c3d8376251..42df6b6066 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -400,7 +400,7 @@ void S6Exporter::Export() const NewsItem* src = &gNewsItems[i]; rct12_news_item* dst = &_s6.news_items[i]; - dst->Type = src->Type; + dst->Type = static_cast(src->Type); dst->Flags = src->Flags; dst->Assoc = src->Assoc; dst->Ticks = src->Ticks; diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index a4790a9244..e508b441cf 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -429,7 +429,7 @@ public: NewsItem* dst = &gNewsItems[i]; if (src->Type < std::size(news_type_properties)) { - dst->Type = src->Type; + dst->Type = static_cast(src->Type); dst->Flags = src->Flags; dst->Assoc = src->Assoc; dst->Ticks = src->Ticks; @@ -442,7 +442,7 @@ public: // In case where news item type is broken, consider all remaining news items invalid. log_error("Invalid news type 0x%x for news item %d, ignoring remaining news items", src->Type, i); // Still need to set the correct type to properly terminate the queue - dst->Type = NEWS_ITEM_NULL; + dst->Type = News::ItemType::Null; break; } } diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index a0238c7384..89ad0a6f07 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -2533,7 +2533,7 @@ void ride_breakdown_add_news_item(Ride* ride) ride->FormatNameTo(ft); if (gConfigNotifications.ride_broken_down) { - news_item_add_to_queue(NEWS_ITEM_RIDE, STR_RIDE_IS_BROKEN_DOWN, ride->id); + news_item_add_to_queue(News::ItemType::Ride, STR_RIDE_IS_BROKEN_DOWN, ride->id); } } @@ -2560,7 +2560,7 @@ static void ride_breakdown_status_update(Ride* ride) ride->FormatNameTo(ft); if (gConfigNotifications.ride_warnings) { - news_item_add_to_queue(NEWS_ITEM_RIDE, STR_RIDE_IS_STILL_NOT_FIXED, ride->id); + news_item_add_to_queue(News::ItemType::Ride, STR_RIDE_IS_STILL_NOT_FIXED, ride->id); } } } @@ -3211,7 +3211,7 @@ static void ride_entrance_exit_connected(Ride* ride) ride->FormatNameTo(ft); if (gConfigNotifications.ride_warnings) { - news_item_add_to_queue(1, STR_ENTRANCE_NOT_CONNECTED, ride->id); + news_item_add_to_queue(News::ItemType::Ride, STR_ENTRANCE_NOT_CONNECTED, ride->id); } ride->connected_message_throttle = 3; } @@ -3223,7 +3223,7 @@ static void ride_entrance_exit_connected(Ride* ride) ride->FormatNameTo(ft); if (gConfigNotifications.ride_warnings) { - news_item_add_to_queue(1, STR_EXIT_NOT_CONNECTED, ride->id); + news_item_add_to_queue(News::ItemType::Ride, STR_EXIT_NOT_CONNECTED, ride->id); } ride->connected_message_throttle = 3; } @@ -3299,7 +3299,7 @@ static void ride_shop_connected(Ride* ride) ride->FormatNameTo(ft); if (gConfigNotifications.ride_warnings) { - news_item_add_to_queue(1, STR_ENTRANCE_NOT_CONNECTED, ride->id); + news_item_add_to_queue(News::ItemType::Ride, STR_ENTRANCE_NOT_CONNECTED, ride->id); } ride->connected_message_throttle = 3; @@ -7099,7 +7099,7 @@ void Ride::Crash(uint8_t vehicleIndex) FormatNameTo(ft); if (gConfigNotifications.ride_crashed) { - news_item_add_to_queue(NEWS_ITEM_RIDE, STR_RIDE_HAS_CRASHED, id); + news_item_add_to_queue(News::ItemType::Ride, STR_RIDE_HAS_CRASHED, id); } } diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index ccbdda0818..c2e21710ad 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -3483,7 +3483,7 @@ void Vehicle::CheckIfMissing() curRide->FormatNameTo(ft); ft.Add(RideComponentNames[RideTypeDescriptors[curRide->type].NameConvention.station].singular); - news_item_add_to_queue(NEWS_ITEM_RIDE, STR_NEWS_VEHICLE_HAS_STALLED, ride); + news_item_add_to_queue(News::ItemType::Ride, STR_NEWS_VEHICLE_HAS_STALLED, ride); } } @@ -5172,7 +5172,7 @@ static void ride_train_crash(Ride* ride, uint16_t numFatalities) { ride->FormatNameTo(ft); news_item_add_to_queue( - NEWS_ITEM_RIDE, numFatalities == 1 ? STR_X_PERSON_DIED_ON_X : STR_X_PEOPLE_DIED_ON_X, ride->id); + News::ItemType::Ride, numFatalities == 1 ? STR_X_PERSON_DIED_ON_X : STR_X_PEOPLE_DIED_ON_X, ride->id); } if (gParkRatingCasualtyPenalty < 500) diff --git a/src/openrct2/scenario/Scenario.cpp b/src/openrct2/scenario/Scenario.cpp index 82cf596000..183677d95d 100644 --- a/src/openrct2/scenario/Scenario.cpp +++ b/src/openrct2/scenario/Scenario.cpp @@ -246,7 +246,7 @@ static void scenario_entrance_fee_too_high_check() uint32_t packed_xy = (y << 16) | x; if (gConfigNotifications.park_warnings) { - news_item_add_to_queue(NEWS_ITEM_BLANK, STR_ENTRANCE_FEE_TOO_HI, packed_xy); + news_item_add_to_queue(News::ItemType::Blank, STR_ENTRANCE_FEE_TOO_HI, packed_xy); } } } @@ -793,33 +793,33 @@ static void scenario_objective_check_guests_and_rating() { if (gConfigNotifications.park_rating_warnings) { - news_item_add_to_queue(NEWS_ITEM_GRAPH, STR_PARK_RATING_WARNING_4_WEEKS_REMAINING, 0); + news_item_add_to_queue(News::ItemType::Graph, STR_PARK_RATING_WARNING_4_WEEKS_REMAINING, 0); } } else if (gScenarioParkRatingWarningDays == 8) { if (gConfigNotifications.park_rating_warnings) { - news_item_add_to_queue(NEWS_ITEM_GRAPH, STR_PARK_RATING_WARNING_3_WEEKS_REMAINING, 0); + news_item_add_to_queue(News::ItemType::Graph, STR_PARK_RATING_WARNING_3_WEEKS_REMAINING, 0); } } else if (gScenarioParkRatingWarningDays == 15) { if (gConfigNotifications.park_rating_warnings) { - news_item_add_to_queue(NEWS_ITEM_GRAPH, STR_PARK_RATING_WARNING_2_WEEKS_REMAINING, 0); + news_item_add_to_queue(News::ItemType::Graph, STR_PARK_RATING_WARNING_2_WEEKS_REMAINING, 0); } } else if (gScenarioParkRatingWarningDays == 22) { if (gConfigNotifications.park_rating_warnings) { - news_item_add_to_queue(NEWS_ITEM_GRAPH, STR_PARK_RATING_WARNING_1_WEEK_REMAINING, 0); + news_item_add_to_queue(News::ItemType::Graph, STR_PARK_RATING_WARNING_1_WEEK_REMAINING, 0); } } else if (gScenarioParkRatingWarningDays == 29) { - news_item_add_to_queue(NEWS_ITEM_GRAPH, STR_PARK_HAS_BEEN_CLOSED_DOWN, 0); + news_item_add_to_queue(News::ItemType::Graph, STR_PARK_HAS_BEEN_CLOSED_DOWN, 0); gParkFlags &= ~PARK_FLAGS_PARK_OPEN; scenario_failure(); gGuestInitialHappiness = 50; diff --git a/src/openrct2/scripting/ScPark.hpp b/src/openrct2/scripting/ScPark.hpp index 86c000da29..a937b7a7b1 100644 --- a/src/openrct2/scripting/ScPark.hpp +++ b/src/openrct2/scripting/ScPark.hpp @@ -30,21 +30,26 @@ namespace OpenRCT2::Scripting "attraction", "peep_on_attraction", "peep", "money", "blank", "research", "guests", "award", "chart", }; - inline uint8_t GetParkMessageType(const std::string& key) + inline News::ItemType GetParkMessageType(const std::string& key) { - auto it = std::find(std::begin(ParkMessageTypeStrings), std::end(ParkMessageTypeStrings), key); - return it != std::end(ParkMessageTypeStrings) - ? static_cast(NEWS_ITEM_RIDE + std::distance(std::begin(ParkMessageTypeStrings), it)) - : static_cast(NEWS_ITEM_BLANK); + // Get the first ItemType that appears in ParkMessageTypeStrings that isn't Null + auto firstType = static_cast(News::ItemType::Ride); + + auto begin = std::begin(ParkMessageTypeStrings); + auto end = std::end(ParkMessageTypeStrings); + + auto it = std::find(begin, end, key); + return it != end ? static_cast(firstType + std::distance(begin, it)) : News::ItemType::Blank; } - inline std::string GetParkMessageType(uint8_t type) + inline std::string GetParkMessageType(News::ItemType type) { // Decrement 1 as ParkMessageTypeStrings doesn't contain the null type - type--; - if (type < std::size(ParkMessageTypeStrings)) + auto scriptType = static_cast(type) - 1; + + if (scriptType < std::size(ParkMessageTypeStrings)) { - return ParkMessageTypeStrings[type]; + return ParkMessageTypeStrings[scriptType]; } return {}; } @@ -329,11 +334,11 @@ namespace OpenRCT2::Scripting // End the lists by setting next item to null if (index < NEWS_ITEM_HISTORY_START) { - gNewsItems[index].Type = NEWS_ITEM_NULL; + gNewsItems[index].Type = News::ItemType::Null; } if (archiveIndex < MAX_NEWS_ITEMS) { - gNewsItems[archiveIndex].Type = NEWS_ITEM_NULL; + gNewsItems[archiveIndex].Type = News::ItemType::Null; } } @@ -343,7 +348,7 @@ namespace OpenRCT2::Scripting try { uint32_t assoc = std::numeric_limits::max(); - uint8_t type = NEWS_ITEM_BLANK; + auto type = News::ItemType::Blank; std::string text; if (message.type() == DukValue::Type::STRING) { @@ -353,7 +358,7 @@ namespace OpenRCT2::Scripting { type = GetParkMessageType(message["type"].as_string()); text = language_convert_string(message["text"].as_string()); - if (type == NEWS_ITEM_BLANK) + if (type == News::ItemType::Blank) { assoc = static_cast(((COORDS_NULL & 0xFFFF) << 16) | (COORDS_NULL & 0xFFFF)); }