From cc2bb33892f9a4ad09afac3c422317b3bfbff6ee Mon Sep 17 00:00:00 2001 From: ryan-bello Date: Sun, 16 Aug 2020 18:25:32 -0400 Subject: [PATCH] changed enum STAFF_TYPE to strong enum StaffType, moved it to Peep.h --- src/openrct2-ui/windows/GameBottomToolbar.cpp | 2 +- src/openrct2-ui/windows/Guest.cpp | 2 +- src/openrct2-ui/windows/News.cpp | 2 +- src/openrct2-ui/windows/Ride.cpp | 2 +- src/openrct2-ui/windows/Staff.cpp | 24 +++++--- src/openrct2-ui/windows/StaffList.cpp | 22 ++++---- src/openrct2/actions/StaffHireNewAction.hpp | 18 +++--- src/openrct2/actions/StaffSetColourAction.hpp | 11 ++-- src/openrct2/actions/StaffSetOrdersAction.hpp | 3 +- src/openrct2/interface/InteractiveConsole.cpp | 2 +- src/openrct2/management/Award.cpp | 2 +- src/openrct2/management/Finance.cpp | 4 +- src/openrct2/paint/sprite/Paint.Sprite.cpp | 2 +- .../paint/tile_element/Paint.Path.cpp | 4 +- .../paint/tile_element/Paint.Surface.cpp | 4 +- src/openrct2/peep/Guest.cpp | 2 +- src/openrct2/peep/GuestPathfinding.cpp | 4 +- src/openrct2/peep/Peep.cpp | 2 +- src/openrct2/peep/Peep.h | 12 +++- src/openrct2/peep/Staff.cpp | 55 ++++++++++--------- src/openrct2/peep/Staff.h | 24 +++----- src/openrct2/rct2/S6Exporter.cpp | 2 +- src/openrct2/ride/Ride.cpp | 2 +- src/openrct2/scripting/ScEntity.hpp | 28 +++++----- 24 files changed, 124 insertions(+), 111 deletions(-) diff --git a/src/openrct2-ui/windows/GameBottomToolbar.cpp b/src/openrct2-ui/windows/GameBottomToolbar.cpp index 5c7cad660e..67c26d8792 100644 --- a/src/openrct2-ui/windows/GameBottomToolbar.cpp +++ b/src/openrct2-ui/windows/GameBottomToolbar.cpp @@ -613,7 +613,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo* dpi, rc auto clipCoords = ScreenCoordsXY{ 10, 19 }; - if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == STAFF_TYPE_ENTERTAINER) + if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == StaffType::Entertainer) { clipCoords.y += 3; } diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 7ce43f46e1..26db86f8c6 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -908,7 +908,7 @@ static void window_guest_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dp return; } - if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == STAFF_TYPE_ENTERTAINER) + if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == StaffType::Entertainer) screenCoords.y++; int32_t animationFrame = g_peep_animation_entries[peep->SpriteType].sprite_animation->base_image + 1; diff --git a/src/openrct2-ui/windows/News.cpp b/src/openrct2-ui/windows/News.cpp index 6de4eab4a1..e3dfdcee71 100644 --- a/src/openrct2-ui/windows/News.cpp +++ b/src/openrct2-ui/windows/News.cpp @@ -309,7 +309,7 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32 if (peep->AssignedPeepType == PeepType::Staff) { sprite_type = peep->SpriteType; - if (peep->AssignedStaffType == STAFF_TYPE_ENTERTAINER) + if (peep->AssignedStaffType == StaffType::Entertainer) { clipCoords.y += 3; } diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 1da96edca8..ffdf94a576 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -4264,7 +4264,7 @@ static void window_ride_maintenance_paint(rct_window* w, rct_drawpixelinfo* dpi) for (auto peep : EntityList(EntityListId::Peep)) { - if (peep->AssignedStaffType == STAFF_TYPE_MECHANIC) + if (peep->AssignedStaffType == StaffType::Mechanic) { stringId = STR_CALLING_MECHANIC; break; diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index bf58e10b91..70845380ce 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -359,7 +359,7 @@ void window_staff_disable_widgets(rct_window* w) } uint64_t disabled_widgets = 0; - if (peep != nullptr && peep->AssignedStaffType == STAFF_TYPE_SECURITY) + if (peep != nullptr && peep->AssignedStaffType == StaffType::Security) { disabled_widgets |= (1 << WIDX_TAB_2); } @@ -850,7 +850,7 @@ void window_staff_options_invalidate(rct_window* w) switch (peep->AssignedStaffType) { - case STAFF_TYPE_ENTERTAINER: + case StaffType::Entertainer: window_staff_options_widgets[WIDX_CHECKBOX_1].type = WWT_EMPTY; window_staff_options_widgets[WIDX_CHECKBOX_2].type = WWT_EMPTY; window_staff_options_widgets[WIDX_CHECKBOX_3].type = WWT_EMPTY; @@ -859,7 +859,7 @@ void window_staff_options_invalidate(rct_window* w) window_staff_options_widgets[WIDX_COSTUME_BTN].type = WWT_BUTTON; window_staff_options_widgets[WIDX_COSTUME_BOX].text = StaffCostumeNames[peep->SpriteType - 4]; break; - case STAFF_TYPE_HANDYMAN: + case StaffType::Handyman: window_staff_options_widgets[WIDX_CHECKBOX_1].type = WWT_CHECKBOX; window_staff_options_widgets[WIDX_CHECKBOX_1].text = STR_STAFF_OPTION_SWEEP_FOOTPATHS; window_staff_options_widgets[WIDX_CHECKBOX_2].type = WWT_CHECKBOX; @@ -874,7 +874,7 @@ void window_staff_options_invalidate(rct_window* w) (1 << WIDX_CHECKBOX_1) | (1 << WIDX_CHECKBOX_2) | (1 << WIDX_CHECKBOX_3) | (1 << WIDX_CHECKBOX_4)); w->pressed_widgets |= peep->StaffOrders << WIDX_CHECKBOX_1; break; - case STAFF_TYPE_MECHANIC: + case StaffType::Mechanic: window_staff_options_widgets[WIDX_CHECKBOX_1].type = WWT_CHECKBOX; window_staff_options_widgets[WIDX_CHECKBOX_1].text = STR_INSPECT_RIDES; window_staff_options_widgets[WIDX_CHECKBOX_2].type = WWT_CHECKBOX; @@ -886,9 +886,11 @@ void window_staff_options_invalidate(rct_window* w) w->pressed_widgets &= ~((1 << WIDX_CHECKBOX_1) | (1 << WIDX_CHECKBOX_2)); w->pressed_widgets |= peep->StaffOrders << WIDX_CHECKBOX_1; break; - case STAFF_TYPE_SECURITY: + case StaffType::Security: // Security guards don't have an options screen. break; + case StaffType::Count: + break; } window_staff_options_widgets[WIDX_BACKGROUND].right = w->width - 1; @@ -1073,7 +1075,7 @@ void window_staff_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dpi) return; } - if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == STAFF_TYPE_ENTERTAINER) + if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == StaffType::Entertainer) screenCoords.y++; int32_t ebx = g_peep_animation_entries[peep->SpriteType].sprite_animation->base_image + 1; @@ -1149,7 +1151,7 @@ void window_staff_stats_paint(rct_window* w, rct_drawpixelinfo* dpi) if (!(gParkFlags & PARK_FLAGS_NO_MONEY)) { - Formatter::Common().Add(gStaffWageTable[peep->AssignedStaffType]); + Formatter::Common().Add(gStaffWageTable[static_cast(peep->AssignedStaffType)]); gfx_draw_string_left(dpi, STR_STAFF_STAT_WAGES, gCommonFormatArgs, COLOUR_BLACK, screenCoords); screenCoords.y += LIST_ROW_HEIGHT; } @@ -1159,7 +1161,7 @@ void window_staff_stats_paint(rct_window* w, rct_drawpixelinfo* dpi) switch (peep->AssignedStaffType) { - case STAFF_TYPE_HANDYMAN: + case StaffType::Handyman: gfx_draw_string_left( dpi, STR_STAFF_STAT_LAWNS_MOWN, static_cast(&peep->StaffLawnsMown), COLOUR_BLACK, screenCoords); screenCoords.y += LIST_ROW_HEIGHT; @@ -1173,7 +1175,7 @@ void window_staff_stats_paint(rct_window* w, rct_drawpixelinfo* dpi) gfx_draw_string_left( dpi, STR_STAFF_STAT_BINS_EMPTIED, static_cast(&peep->StaffBinsEmptied), COLOUR_BLACK, screenCoords); break; - case STAFF_TYPE_MECHANIC: + case StaffType::Mechanic: gfx_draw_string_left( dpi, STR_STAFF_STAT_RIDES_INSPECTED, static_cast(&peep->StaffRidesInspected), COLOUR_BLACK, screenCoords); @@ -1181,6 +1183,10 @@ void window_staff_stats_paint(rct_window* w, rct_drawpixelinfo* dpi) gfx_draw_string_left( dpi, STR_STAFF_STAT_RIDES_FIXED, static_cast(&peep->StaffRidesFixed), COLOUR_BLACK, screenCoords); break; + case StaffType::Security: + case StaffType::Entertainer: + case StaffType::Count: + break; } } diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index dbd568e486..70404d5393 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -192,7 +192,7 @@ void WindowStaffListRefresh() for (auto peep : EntityList(EntityListId::Peep)) { sprite_set_flashing(peep, false); - if (peep->AssignedStaffType != _windowStaffListSelectedTab) + if (static_cast(peep->AssignedStaffType) != _windowStaffListSelectedTab) continue; sprite_set_flashing(peep, true); @@ -230,9 +230,9 @@ static void window_staff_list_mouseup(rct_window* w, rct_widgetindex widgetIndex break; case WIDX_STAFF_LIST_HIRE_BUTTON: { - STAFF_TYPE staffType = static_cast(_windowStaffListSelectedTab); + StaffType staffType = static_cast(_windowStaffListSelectedTab); ENTERTAINER_COSTUME costume = ENTERTAINER_COSTUME_COUNT; - if (staffType == STAFF_TYPE_ENTERTAINER) + if (staffType == StaffType::Entertainer) { costume = static_cast(window_staff_list_get_random_entertainer_costume()); } @@ -301,7 +301,8 @@ static void window_staff_list_mousedown(rct_window* w, rct_widgetindex widgetInd window_staff_list_cancel_tools(w); break; case WIDX_STAFF_LIST_UNIFORM_COLOUR_PICKER: - window_dropdown_show_colour(w, widget, w->colours[1], staff_get_colour(_windowStaffListSelectedTab)); + window_dropdown_show_colour( + w, widget, w->colours[1], staff_get_colour(static_cast(_windowStaffListSelectedTab))); break; } } @@ -314,7 +315,7 @@ static void window_staff_list_dropdown(rct_window* w, rct_widgetindex widgetInde { if (widgetIndex == WIDX_STAFF_LIST_UNIFORM_COLOUR_PICKER && dropdownIndex != -1) { - auto action = StaffSetColourAction(_windowStaffListSelectedTab, dropdownIndex); + auto action = StaffSetColourAction(static_cast(_windowStaffListSelectedTab), dropdownIndex); GameActions::Execute(&action); } } @@ -342,7 +343,7 @@ void window_staff_list_update(rct_window* w) { sprite_set_flashing(peep, false); - if (peep->AssignedStaffType == _windowStaffListSelectedTab) + if (static_cast(peep->AssignedStaffType) == _windowStaffListSelectedTab) { sprite_set_flashing(peep, true); } @@ -371,14 +372,14 @@ static void window_staff_list_tooldown(rct_window* w, rct_widgetindex widgetInde if (footpathCoords.isNull()) return; - bool isPatrolAreaSet = staff_is_patrol_area_set_for_type(static_cast(selectedPeepType), footpathCoords); + bool isPatrolAreaSet = staff_is_patrol_area_set_for_type(static_cast(selectedPeepType), footpathCoords); Peep* closestPeep = nullptr; int32_t closestPeepDistance = std::numeric_limits::max(); for (auto peep : EntityList(EntityListId::Peep)) { - if (peep->AssignedStaffType != selectedPeepType) + if (static_cast(peep->AssignedStaffType) != selectedPeepType) continue; if (isPatrolAreaSet) @@ -529,7 +530,8 @@ void window_staff_list_invalidate(rct_window* w) if (tabIndex < 3) { window_staff_list_widgets[WIDX_STAFF_LIST_UNIFORM_COLOUR_PICKER].type = WWT_COLOURBTN; - auto spriteIdPalette = SPRITE_ID_PALETTE_COLOUR_1(static_cast(staff_get_colour(tabIndex))); + auto spriteIdPalette = SPRITE_ID_PALETTE_COLOUR_1( + static_cast(staff_get_colour(static_cast(tabIndex)))); window_staff_list_widgets[WIDX_STAFF_LIST_UNIFORM_COLOUR_PICKER].image = spriteIdPalette | IMAGE_TYPE_TRANSPARENT | SPR_PALETTE_BTN; } @@ -726,7 +728,7 @@ void window_staff_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_ } auto staffOrderIcon_x = nameColumnSize + 20; - if (peep->AssignedStaffType != 3) + if (peep->AssignedStaffType != StaffType::Entertainer) { auto staffOrders = peep->StaffOrders; auto staffOrderSprite = staffOrderBaseSprites[_windowStaffListSelectedTab]; diff --git a/src/openrct2/actions/StaffHireNewAction.hpp b/src/openrct2/actions/StaffHireNewAction.hpp index dc6967c9ac..148abb1b59 100644 --- a/src/openrct2/actions/StaffHireNewAction.hpp +++ b/src/openrct2/actions/StaffHireNewAction.hpp @@ -54,15 +54,15 @@ DEFINE_GAME_ACTION(StaffHireNewAction, GAME_COMMAND_HIRE_NEW_STAFF_MEMBER, Staff { private: bool _autoPosition = false; - uint8_t _staffType = STAFF_TYPE::STAFF_TYPE_COUNT; + uint8_t _staffType = static_cast(StaffType::Count); uint8_t _entertainerType = ENTERTAINER_COSTUME::ENTERTAINER_COSTUME_COUNT; uint32_t _staffOrders = 0; public: StaffHireNewAction() = default; - StaffHireNewAction(bool autoPosition, STAFF_TYPE staffType, ENTERTAINER_COSTUME entertainerType, uint32_t staffOrders) + StaffHireNewAction(bool autoPosition, StaffType staffType, ENTERTAINER_COSTUME entertainerType, uint32_t staffOrders) : _autoPosition(autoPosition) - , _staffType(staffType) + , _staffType(static_cast(staffType)) , _entertainerType(entertainerType) , _staffOrders(staffOrders) { @@ -97,7 +97,7 @@ private: res->Expenditure = ExpenditureType::Wages; - if (_staffType >= STAFF_TYPE_COUNT) + if (_staffType >= static_cast(StaffType::Count)) { // Invalid staff type. log_error("Tried to use invalid staff type: %u", static_cast(_staffType)); @@ -110,7 +110,7 @@ private: return MakeResult(GA_ERROR::NO_FREE_ELEMENTS, STR_TOO_MANY_PEOPLE_IN_GAME); } - if (_staffType == STAFF_TYPE_ENTERTAINER) + if (_staffType == static_cast(StaffType::Entertainer)) { if (_entertainerType >= ENTERTAINER_COSTUME_COUNT) { @@ -184,7 +184,7 @@ private: ++newStaffId; for (auto searchPeep : EntityList(EntityListId::Peep)) { - if (searchPeep->AssignedStaffType != _staffType) + if (static_cast(searchPeep->AssignedStaffType) != _staffType) continue; if (searchPeep->Id == newStaffId) @@ -199,10 +199,10 @@ private: } newPeep->Id = newStaffId; - newPeep->AssignedStaffType = _staffType; + newPeep->AssignedStaffType = static_cast(_staffType); PeepSpriteType spriteType = spriteTypes[_staffType]; - if (_staffType == STAFF_TYPE_ENTERTAINER) + if (_staffType == static_cast(StaffType::Entertainer)) { spriteType = static_cast(PEEP_SPRITE_TYPE_ENTERTAINER_PANDA + _entertainerType); } @@ -233,7 +233,7 @@ private: newPeep->PathfindGoal.z = 0xFF; newPeep->PathfindGoal.direction = INVALID_DIRECTION; - uint8_t colour = staff_get_colour(_staffType); + uint8_t colour = staff_get_colour(static_cast(_staffType)); newPeep->TshirtColour = colour; newPeep->TrousersColour = colour; diff --git a/src/openrct2/actions/StaffSetColourAction.hpp b/src/openrct2/actions/StaffSetColourAction.hpp index 8f5fee5e01..842229e94e 100644 --- a/src/openrct2/actions/StaffSetColourAction.hpp +++ b/src/openrct2/actions/StaffSetColourAction.hpp @@ -30,8 +30,8 @@ public: StaffSetColourAction() { } - StaffSetColourAction(uint8_t staffType, uint8_t colour) - : _staffType(staffType) + StaffSetColourAction(StaffType staffType, uint8_t colour) + : _staffType(static_cast(staffType)) , _colour(colour) { } @@ -49,7 +49,8 @@ public: GameActionResult::Ptr Query() const override { - if (_staffType != STAFF_TYPE_HANDYMAN && _staffType != STAFF_TYPE_MECHANIC && _staffType != STAFF_TYPE_SECURITY) + auto staffType = static_cast(_staffType); + if (staffType != StaffType::Handyman && staffType != StaffType::Mechanic && staffType != StaffType::Security) { return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); } @@ -59,7 +60,7 @@ public: GameActionResult::Ptr Execute() const override { // Update global uniform colour property - if (!staff_set_colour(_staffType, _colour)) + if (!staff_set_colour(static_cast(_staffType), _colour)) { return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); } @@ -67,7 +68,7 @@ public: // Update each staff member's uniform for (auto peep : EntityList(EntityListId::Peep)) { - if (peep->AssignedStaffType == _staffType) + if (peep->AssignedStaffType == static_cast(_staffType)) { peep->TshirtColour = _colour; peep->TrousersColour = _colour; diff --git a/src/openrct2/actions/StaffSetOrdersAction.hpp b/src/openrct2/actions/StaffSetOrdersAction.hpp index e025682f6a..4070e6509a 100644 --- a/src/openrct2/actions/StaffSetOrdersAction.hpp +++ b/src/openrct2/actions/StaffSetOrdersAction.hpp @@ -54,7 +54,8 @@ public: } auto* staff = TryGetEntity(_spriteIndex); - if (staff == nullptr || (staff->AssignedStaffType != STAFF_TYPE_HANDYMAN && staff->AssignedStaffType != STAFF_TYPE_MECHANIC)) + if (staff == nullptr + || (staff->AssignedStaffType != StaffType::Handyman && staff->AssignedStaffType != StaffType::Mechanic)) { log_warning("Invalid game command for sprite %u", _spriteIndex); return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index f2e4ef11ca..ec75a601d2 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -494,7 +494,7 @@ static int32_t cc_staff(InteractiveConsole& console, const arguments_t& argv) console.WriteLineError("Invalid staff ID"); return 1; } - if (staff->AssignedStaffType != STAFF_TYPE_ENTERTAINER) + if (staff->AssignedStaffType != StaffType::Entertainer) { console.WriteLineError("Specified staff is not entertainer"); return 1; diff --git a/src/openrct2/management/Award.cpp b/src/openrct2/management/Award.cpp index d6ae94aae8..c59180da4a 100644 --- a/src/openrct2/management/Award.cpp +++ b/src/openrct2/management/Award.cpp @@ -273,7 +273,7 @@ static bool award_is_deserved_best_staff(int32_t activeAwardTypes) if (peep->AssignedPeepType == PeepType::Staff) { staffCount++; - staffTypeFlags |= (1 << peep->AssignedStaffType); + staffTypeFlags |= (1 << static_cast(peep->AssignedStaffType)); } else { diff --git a/src/openrct2/management/Finance.cpp b/src/openrct2/management/Finance.cpp index e20523914f..26d8e26cef 100644 --- a/src/openrct2/management/Finance.cpp +++ b/src/openrct2/management/Finance.cpp @@ -113,7 +113,7 @@ void finance_pay_wages() for (auto peep : EntityList(EntityListId::Peep)) { - finance_payment(gStaffWageTable[peep->AssignedStaffType] / 4, ExpenditureType::Wages); + finance_payment(gStaffWageTable[static_cast(peep->AssignedStaffType)] / 4, ExpenditureType::Wages); } } @@ -248,7 +248,7 @@ void finance_update_daily_profit() // Staff costs for (auto peep : EntityList(EntityListId::Peep)) { - current_profit -= gStaffWageTable[peep->AssignedStaffType]; + current_profit -= gStaffWageTable[static_cast(peep->AssignedStaffType)]; } // Research costs diff --git a/src/openrct2/paint/sprite/Paint.Sprite.cpp b/src/openrct2/paint/sprite/Paint.Sprite.cpp index fa5d967f88..e43799c26e 100644 --- a/src/openrct2/paint/sprite/Paint.Sprite.cpp +++ b/src/openrct2/paint/sprite/Paint.Sprite.cpp @@ -50,7 +50,7 @@ void sprite_paint_setup(paint_session* session, const uint16_t x, const uint16_t const auto peep = spr->As(); if (peep != nullptr) { - if (!(peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == STAFF_TYPE_HANDYMAN)) + if (!(peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == StaffType::Handyman)) { continue; } diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index fef8b478b4..d0a074f263 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -912,11 +912,11 @@ void path_paint(paint_session* session, uint16_t height, const TileElement* tile { patrolColour = COLOUR_GREY; } - staffType = staff->AssignedStaffType; + staffType = static_cast(staff->AssignedStaffType); } } - if (staff_is_patrol_area_set_for_type(static_cast(staffType), session->MapPosition)) + if (staff_is_patrol_area_set_for_type(static_cast(staffType), session->MapPosition)) { uint32_t imageId = 2618; int32_t patrolAreaBaseZ = tile_element->GetBaseZ(); diff --git a/src/openrct2/paint/tile_element/Paint.Surface.cpp b/src/openrct2/paint/tile_element/Paint.Surface.cpp index 5635ffc15f..20a4427300 100644 --- a/src/openrct2/paint/tile_element/Paint.Surface.cpp +++ b/src/openrct2/paint/tile_element/Paint.Surface.cpp @@ -1095,11 +1095,11 @@ void surface_paint(paint_session* session, uint8_t direction, uint16_t height, c { patrolColour = COLOUR_GREY; } - staffType = staff->AssignedStaffType; + staffType = static_cast(staff->AssignedStaffType); } } - if (staff_is_patrol_area_set_for_type(static_cast(staffType), session->MapPosition)) + if (staff_is_patrol_area_set_for_type(static_cast(staffType), session->MapPosition)) { assert(surfaceShape < std::size(byte_97B444)); diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 4d16759557..b078aa4aeb 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -6277,7 +6277,7 @@ static void peep_update_walking_break_scenery(Peep* peep) for (auto inner_peep : EntityList(EntityListId::Peep)) { - if (inner_peep->AssignedStaffType != STAFF_TYPE_SECURITY) + if (inner_peep->AssignedStaffType != StaffType::Security) continue; if (inner_peep->x == LOCATION_NULL) diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index f479dccbb9..197d20521f 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -625,7 +625,7 @@ static void peep_pathfind_heuristic_search( } bool nextInPatrolArea = inPatrolArea; - if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == STAFF_TYPE_MECHANIC) + if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == StaffType::Mechanic) { nextInPatrolArea = peep->AsStaff()->IsLocationInPatrol(loc.ToCoordsXY()); if (inPatrolArea && !nextInPatrolArea) @@ -1400,7 +1400,7 @@ Direction peep_pathfind_choose_direction(const TileCoordsXYZ& loc, Peep* peep) uint8_t endDirectionList[16] = { 0 }; bool inPatrolArea = false; - if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == STAFF_TYPE_MECHANIC) + if (peep->AssignedPeepType == PeepType::Staff && peep->AssignedStaffType == StaffType::Mechanic) { /* Mechanics are the only staff type that * pathfind to a destination. Determine if the diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index 41f6b7b841..b4e8ad63ec 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -1940,7 +1940,7 @@ void Peep::FormatNameTo(Formatter& ft) const STR_ENTERTAINER_X, }; - auto staffNameIndex = AssignedStaffType; + auto staffNameIndex = static_cast(AssignedStaffType); if (staffNameIndex > sizeof(staffNames)) { staffNameIndex = 0; diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index 934b221ece..aeb77a65e7 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -60,6 +60,16 @@ enum class PeepType : uint8_t Invalid = 0xFF }; +enum class StaffType : uint8_t +{ + Handyman, + Mechanic, + Security, + Entertainer, + + Count +}; + enum PeepThoughtType : uint8_t { PEEP_THOUGHT_TYPE_CANT_AFFORD_0 = 0, // "I can't afford" @@ -609,7 +619,7 @@ struct Peep : SpriteBase PeepType AssignedPeepType; union { - uint8_t AssignedStaffType; + StaffType AssignedStaffType; uint8_t GuestNumRides; }; uint8_t TshirtColour; diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index 56d4ef0f84..454f3013d1 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -47,7 +47,7 @@ * * rct2: 0x00992A00 */ -const money32 gStaffWageTable[STAFF_TYPE_COUNT] = { +const money32 gStaffWageTable[static_cast(StaffType::Count)] = { MONEY(50, 00), // Handyman MONEY(80, 00), // Mechanic MONEY(60, 00), // Security guard @@ -72,8 +72,8 @@ const rct_string_id StaffCostumeNames[] = { // Every staff member has STAFF_PATROL_AREA_SIZE elements assigned to in this array, indexed by their StaffId // Additionally there is a patrol area for each staff type, which is the union of the patrols of all staff members of that type -uint32_t gStaffPatrolAreas[(STAFF_MAX_COUNT + STAFF_TYPE_COUNT) * STAFF_PATROL_AREA_SIZE]; -uint8_t gStaffModes[STAFF_MAX_COUNT + STAFF_TYPE_COUNT]; +uint32_t gStaffPatrolAreas[(STAFF_MAX_COUNT + static_cast(StaffType::Count)) * STAFF_PATROL_AREA_SIZE]; +uint8_t gStaffModes[STAFF_MAX_COUNT + static_cast(StaffType::Count)]; uint16_t gStaffDrawPatrolAreas; colour_t gStaffHandymanColour; colour_t gStaffMechanicColour; @@ -94,7 +94,7 @@ void staff_reset_modes() for (int32_t i = 0; i < STAFF_MAX_COUNT; i++) gStaffModes[i] = STAFF_MODE_NONE; - for (int32_t i = STAFF_MAX_COUNT; i < (STAFF_MAX_COUNT + STAFF_TYPE_COUNT); i++) + for (int32_t i = STAFF_MAX_COUNT; i < (STAFF_MAX_COUNT + static_cast(StaffType::Count)); i++) gStaffModes[i] = STAFF_MODE_WALK; staff_update_greyed_patrol_areas(); @@ -103,7 +103,7 @@ void staff_reset_modes() /** * Hires a new staff member of the given type. */ -bool staff_hire_new_member(STAFF_TYPE staffType, ENTERTAINER_COSTUME entertainerType) +bool staff_hire_new_member(StaffType staffType, ENTERTAINER_COSTUME entertainerType) { bool autoPosition = gConfigGeneral.auto_staff_placement; if (gInputPlaceObjectModifier & PLACE_OBJECT_MODIFIER_SHIFT_Z) @@ -113,7 +113,7 @@ bool staff_hire_new_member(STAFF_TYPE staffType, ENTERTAINER_COSTUME entertainer uint32_t staffOrders = 0; - if (staffType == STAFF_TYPE_HANDYMAN) + if (staffType == StaffType::Handyman) { staffOrders = STAFF_ORDERS_SWEEPING | STAFF_ORDERS_WATER_FLOWERS | STAFF_ORDERS_EMPTY_BINS; if (gConfigGeneral.handymen_mow_default) @@ -121,7 +121,7 @@ bool staff_hire_new_member(STAFF_TYPE staffType, ENTERTAINER_COSTUME entertainer staffOrders |= STAFF_ORDERS_MOWING; } } - else if (staffType == STAFF_TYPE_MECHANIC) + else if (staffType == StaffType::Mechanic) { staffOrders = STAFF_ORDERS_INSPECT_RIDES | STAFF_ORDERS_FIX_RIDES; } @@ -148,7 +148,7 @@ bool staff_hire_new_member(STAFF_TYPE staffType, ENTERTAINER_COSTUME entertainer */ void staff_update_greyed_patrol_areas() { - for (int32_t staff_type = 0; staff_type < STAFF_TYPE_COUNT; ++staff_type) + for (int32_t staff_type = 0; staff_type < static_cast(StaffType::Count); ++staff_type) { int32_t staffPatrolOffset = (staff_type + STAFF_MAX_COUNT) * STAFF_PATROL_AREA_SIZE; for (int32_t i = 0; i < STAFF_PATROL_AREA_SIZE; i++) @@ -158,7 +158,7 @@ void staff_update_greyed_patrol_areas() for (auto peep : EntityList(EntityListId::Peep)) { - if (peep->AssignedStaffType == staff_type) + if (static_cast(peep->AssignedStaffType) == staff_type) { int32_t peepPatrolOffset = peep->StaffId * STAFF_PATROL_AREA_SIZE; for (int32_t i = 0; i < STAFF_PATROL_AREA_SIZE; i++) @@ -398,9 +398,9 @@ bool Staff::IsPatrolAreaSet(const CoordsXY& coords) const return staff_is_patrol_area_set(StaffId, coords); } -bool staff_is_patrol_area_set_for_type(STAFF_TYPE type, const CoordsXY& coords) +bool staff_is_patrol_area_set_for_type(StaffType type, const CoordsXY& coords) { - return staff_is_patrol_area_set(STAFF_MAX_COUNT + type, coords); + return staff_is_patrol_area_set(STAFF_MAX_COUNT + static_cast(type), coords); } void staff_set_patrol_area(int32_t staffIndex, const CoordsXY& coords, bool value) @@ -1075,13 +1075,13 @@ bool Staff::DoPathFinding() { switch (AssignedStaffType) { - case STAFF_TYPE_HANDYMAN: + case StaffType::Handyman: return DoHandymanPathFinding(); - case STAFF_TYPE_MECHANIC: + case StaffType::Mechanic: return DoMechanicPathFinding(); - case STAFF_TYPE_SECURITY: + case StaffType::Security: return DoMiscPathFinding(); - case STAFF_TYPE_ENTERTAINER: + case StaffType::Entertainer: return DoEntertainerPathFinding(); default: @@ -1100,17 +1100,17 @@ void Staff::SetCostume(uint8_t value) SpriteType = static_cast(value + PEEP_SPRITE_TYPE_ENTERTAINER_PANDA); } -colour_t staff_get_colour(uint8_t staffType) +colour_t staff_get_colour(StaffType staffType) { switch (staffType) { - case STAFF_TYPE_HANDYMAN: + case StaffType::Handyman: return gStaffHandymanColour; - case STAFF_TYPE_MECHANIC: + case StaffType::Mechanic: return gStaffMechanicColour; - case STAFF_TYPE_SECURITY: + case StaffType::Security: return gStaffSecurityColour; - case STAFF_TYPE_ENTERTAINER: + case StaffType::Entertainer: return 0; default: assert(false); @@ -1118,17 +1118,17 @@ colour_t staff_get_colour(uint8_t staffType) } } -bool staff_set_colour(uint8_t staffType, colour_t value) +bool staff_set_colour(StaffType staffType, colour_t value) { switch (staffType) { - case STAFF_TYPE_HANDYMAN: + case StaffType::Handyman: gStaffHandymanColour = value; break; - case STAFF_TYPE_MECHANIC: + case StaffType::Mechanic: gStaffMechanicColour = value; break; - case STAFF_TYPE_SECURITY: + case StaffType::Security: gStaffSecurityColour = value; break; default: @@ -1828,7 +1828,7 @@ static int32_t peep_update_patrolling_find_sweeping(Peep* peep) void Staff::Tick128UpdateStaff() { - if (AssignedStaffType != STAFF_TYPE_SECURITY) + if (AssignedStaffType != StaffType::Security) return; PeepSpriteType newSpriteType = PEEP_SPRITE_TYPE_SECURITY_ALT; @@ -1857,7 +1857,8 @@ void Staff::Tick128UpdateStaff() bool Staff::IsMechanic() const { return ( - sprite_identifier == SPRITE_IDENTIFIER_PEEP && AssignedPeepType == PeepType::Staff && AssignedStaffType == STAFF_TYPE_MECHANIC); + sprite_identifier == SPRITE_IDENTIFIER_PEEP && AssignedPeepType == PeepType::Staff + && AssignedStaffType == StaffType::Mechanic); } void Staff::UpdateStaff(uint32_t stepsToTake) @@ -1928,7 +1929,7 @@ void Staff::UpdatePatrolling() } } - if (AssignedStaffType != STAFF_TYPE_HANDYMAN) + if (AssignedStaffType != StaffType::Handyman) return; if (peep_update_patrolling_find_sweeping(this)) diff --git a/src/openrct2/peep/Staff.h b/src/openrct2/peep/Staff.h index 478f65a9c4..3dc45181d7 100644 --- a/src/openrct2/peep/Staff.h +++ b/src/openrct2/peep/Staff.h @@ -25,16 +25,6 @@ enum STAFF_MODE STAFF_MODE_PATROL = 3 }; -enum STAFF_TYPE : uint8_t -{ - STAFF_TYPE_HANDYMAN, - STAFF_TYPE_MECHANIC, - STAFF_TYPE_SECURITY, - STAFF_TYPE_ENTERTAINER, - - STAFF_TYPE_COUNT -}; - enum STAFF_ORDERS { STAFF_ORDERS_SWEEPING = (1 << 0), @@ -62,12 +52,12 @@ enum ENTERTAINER_COSTUME : uint8_t ENTERTAINER_COSTUME_COUNT }; -extern const money32 gStaffWageTable[STAFF_TYPE_COUNT]; +extern const money32 gStaffWageTable[static_cast(StaffType::Count)]; extern const rct_string_id StaffCostumeNames[ENTERTAINER_COSTUME_COUNT]; -extern uint32_t gStaffPatrolAreas[(STAFF_MAX_COUNT + STAFF_TYPE_COUNT) * STAFF_PATROL_AREA_SIZE]; -extern uint8_t gStaffModes[STAFF_MAX_COUNT + STAFF_TYPE_COUNT]; +extern uint32_t gStaffPatrolAreas[(STAFF_MAX_COUNT + static_cast(StaffType::Count)) * STAFF_PATROL_AREA_SIZE]; +extern uint8_t gStaffModes[STAFF_MAX_COUNT + static_cast(StaffType::Count)]; extern uint16_t gStaffDrawPatrolAreas; extern colour_t gStaffHandymanColour; extern colour_t gStaffMechanicColour; @@ -75,16 +65,16 @@ extern colour_t gStaffSecurityColour; void staff_reset_modes(); void staff_set_name(uint16_t spriteIndex, const char* name); -bool staff_hire_new_member(STAFF_TYPE staffType, ENTERTAINER_COSTUME entertainerType); +bool staff_hire_new_member(StaffType staffType, ENTERTAINER_COSTUME entertainerType); void staff_update_greyed_patrol_areas(); bool staff_is_location_on_patrol_edge(Peep* mechanic, const CoordsXY& loc); bool staff_can_ignore_wide_flag(Peep* mechanic, const CoordsXYZ& staffPos, TileElement* path); void staff_reset_stats(); -bool staff_is_patrol_area_set_for_type(STAFF_TYPE type, const CoordsXY& coords); +bool staff_is_patrol_area_set_for_type(StaffType type, const CoordsXY& coords); void staff_set_patrol_area(int32_t staffIndex, const CoordsXY& coords, bool value); void staff_toggle_patrol_area(int32_t staffIndex, const CoordsXY& coords); -colour_t staff_get_colour(uint8_t staffType); -bool staff_set_colour(uint8_t staffType, colour_t value); +colour_t staff_get_colour(StaffType staffType); +bool staff_set_colour(StaffType staffType, colour_t value); uint32_t staff_get_available_entertainer_costumes(); int32_t staff_get_available_entertainer_costume_list(uint8_t* costumeList); diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index 02553896a4..f3ae087249 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -1124,7 +1124,7 @@ void S6Exporter::ExportSpritePeep(RCT2SpritePeep* dst, const Peep* src) STR_SECURITY_GUARD_X, STR_ENTERTAINER_X, }; - dst->name_string_idx = staffNames[src->AssignedStaffType % sizeof(staffNames)]; + dst->name_string_idx = staffNames[static_cast(src->AssignedStaffType) % sizeof(staffNames)]; } else if (gParkFlags & PARK_FLAGS_SHOW_REAL_GUEST_NAMES) { diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index 1eaef1b471..1e9bce0ee0 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -2700,7 +2700,7 @@ Peep* find_closest_mechanic(const CoordsXY& entrancePosition, int32_t forInspect for (auto peep : EntityList(EntityListId::Peep)) { - if (peep->AssignedStaffType != STAFF_TYPE_MECHANIC) + if (peep->AssignedStaffType != StaffType::Mechanic) continue; if (!forInspection) diff --git a/src/openrct2/scripting/ScEntity.hpp b/src/openrct2/scripting/ScEntity.hpp index ab1f46ff69..63b1967110 100644 --- a/src/openrct2/scripting/ScEntity.hpp +++ b/src/openrct2/scripting/ScEntity.hpp @@ -1087,14 +1087,16 @@ namespace OpenRCT2::Scripting { switch (peep->AssignedStaffType) { - case STAFF_TYPE_HANDYMAN: + case StaffType::Handyman: return "handyman"; - case STAFF_TYPE_MECHANIC: + case StaffType::Mechanic: return "mechanic"; - case STAFF_TYPE_SECURITY: + case StaffType::Security: return "security"; - case STAFF_TYPE_ENTERTAINER: + case StaffType::Entertainer: return "entertainer"; + case StaffType::Count: + break; } } return ""; @@ -1106,24 +1108,24 @@ namespace OpenRCT2::Scripting auto peep = GetStaff(); if (peep != nullptr) { - if (value == "handyman" && peep->AssignedStaffType != STAFF_TYPE_HANDYMAN) + if (value == "handyman" && peep->AssignedStaffType != StaffType::Handyman) { - peep->AssignedStaffType = STAFF_TYPE_HANDYMAN; + peep->AssignedStaffType = StaffType::Handyman; peep->SpriteType = PeepSpriteType::PEEP_SPRITE_TYPE_HANDYMAN; } - else if (value == "mechanic" && peep->AssignedStaffType != STAFF_TYPE_MECHANIC) + else if (value == "mechanic" && peep->AssignedStaffType != StaffType::Mechanic) { - peep->AssignedStaffType = STAFF_TYPE_MECHANIC; + peep->AssignedStaffType = StaffType::Mechanic; peep->SpriteType = PeepSpriteType::PEEP_SPRITE_TYPE_MECHANIC; } - else if (value == "security" && peep->AssignedStaffType != STAFF_TYPE_SECURITY) + else if (value == "security" && peep->AssignedStaffType != StaffType::Security) { - peep->AssignedStaffType = STAFF_TYPE_SECURITY; + peep->AssignedStaffType = StaffType::Security; peep->SpriteType = PeepSpriteType::PEEP_SPRITE_TYPE_SECURITY; } - else if (value == "entertainer" && peep->AssignedStaffType != STAFF_TYPE_ENTERTAINER) + else if (value == "entertainer" && peep->AssignedStaffType != StaffType::Entertainer) { - peep->AssignedStaffType = STAFF_TYPE_ENTERTAINER; + peep->AssignedStaffType = StaffType::Entertainer; peep->SpriteType = PeepSpriteType::PEEP_SPRITE_TYPE_ENTERTAINER_PANDA; } } @@ -1149,7 +1151,7 @@ namespace OpenRCT2::Scripting uint8_t costume_get() const { auto peep = GetStaff(); - if (peep != nullptr && peep->AssignedStaffType == STAFF_TYPE_ENTERTAINER) + if (peep != nullptr && peep->AssignedStaffType == StaffType::Entertainer) { return peep->GetCostume(); }