From fa2bd4cad68312ae9a90540ff8a21626c88ecfa6 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 25 Jul 2020 11:46:06 +0200 Subject: [PATCH] Refactor PeepType to use strong enum --- src/openrct2-ui/windows/GameBottomToolbar.cpp | 2 +- src/openrct2-ui/windows/Guest.cpp | 4 +- src/openrct2-ui/windows/Map.cpp | 2 +- src/openrct2-ui/windows/News.cpp | 2 +- src/openrct2-ui/windows/Staff.cpp | 2 +- src/openrct2/actions/GuestSetNameAction.hpp | 4 +- src/openrct2/actions/SetCheatAction.hpp | 2 +- src/openrct2/actions/StaffFireAction.hpp | 4 +- src/openrct2/actions/StaffHireNewAction.hpp | 2 +- .../actions/StaffSetCostumeAction.hpp | 2 +- src/openrct2/actions/StaffSetNameAction.hpp | 4 +- src/openrct2/actions/StaffSetOrdersAction.hpp | 2 +- .../actions/StaffSetPatrolAreaAction.hpp | 4 +- src/openrct2/interface/InteractiveConsole.cpp | 2 +- src/openrct2/interface/Viewport.cpp | 4 +- src/openrct2/management/Award.cpp | 2 +- src/openrct2/paint/sprite/Paint.Peep.cpp | 2 +- src/openrct2/paint/sprite/Paint.Sprite.cpp | 2 +- src/openrct2/peep/Guest.cpp | 2 +- src/openrct2/peep/GuestPathfinding.cpp | 10 ++--- src/openrct2/peep/Peep.cpp | 38 +++++++++---------- src/openrct2/peep/Peep.h | 8 ++-- src/openrct2/peep/Staff.cpp | 6 +-- src/openrct2/rct1/S4Importer.cpp | 2 +- src/openrct2/rct2/S6Exporter.cpp | 2 +- src/openrct2/scripting/ScEntity.hpp | 2 +- src/openrct2/scripting/ScMap.hpp | 2 +- 27 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/openrct2-ui/windows/GameBottomToolbar.cpp b/src/openrct2-ui/windows/GameBottomToolbar.cpp index 508da1e0b9..df1119380b 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 == PEEP_TYPE_STAFF && peep->StaffType == STAFF_TYPE_ENTERTAINER) + if (peep->AssignedPeepType == PeepType::Staff && peep->StaffType == STAFF_TYPE_ENTERTAINER) { clipCoords.y += 3; } diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 3acb5488e7..6df6da5262 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -501,7 +501,7 @@ static constexpr const rct_size16 window_guest_page_sizes[][2] = { */ rct_window* window_guest_open(Peep* peep) { - if (peep->AssignedPeepType == PEEP_TYPE_STAFF) + if (peep->AssignedPeepType == PeepType::Staff) { return window_staff_open(peep); } @@ -874,7 +874,7 @@ static void window_guest_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dp Peep* peep = GET_PEEP(w->number); - if (peep->AssignedPeepType == PEEP_TYPE_STAFF && peep->StaffType == STAFF_TYPE_ENTERTAINER) + if (peep->AssignedPeepType == PeepType::Staff && peep->StaffType == STAFF_TYPE_ENTERTAINER) screenCoords.y++; int32_t animationFrame = g_peep_animation_entries[peep->SpriteType].sprite_animation->base_image + 1; diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 6695671bd5..d8da3f4f0d 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -1060,7 +1060,7 @@ static void window_map_paint_peep_overlay(rct_drawpixelinfo* dpi) if (sprite_get_flashing(peep)) { - if (peep->AssignedPeepType == PEEP_TYPE_STAFF) + if (peep->AssignedPeepType == PeepType::Staff) { if ((gWindowMapFlashingFlags & (1 << 3)) != 0) { diff --git a/src/openrct2-ui/windows/News.cpp b/src/openrct2-ui/windows/News.cpp index 8710120b99..0035e00208 100644 --- a/src/openrct2-ui/windows/News.cpp +++ b/src/openrct2-ui/windows/News.cpp @@ -306,7 +306,7 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32 // If normal peep set sprite to normal (no food) // If staff set sprite to staff sprite int32_t sprite_type = 0; - if (peep->AssignedPeepType == PEEP_TYPE_STAFF) + if (peep->AssignedPeepType == PeepType::Staff) { sprite_type = peep->SpriteType; if (peep->StaffType == STAFF_TYPE_ENTERTAINER) diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index 1530185b6a..44bb7f6298 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -1026,7 +1026,7 @@ void window_staff_overview_tab_paint(rct_window* w, rct_drawpixelinfo* dpi) Peep* peep = GET_PEEP(w->number); - if (peep->AssignedPeepType == PEEP_TYPE_STAFF && peep->StaffType == STAFF_TYPE_ENTERTAINER) + if (peep->AssignedPeepType == PeepType::Staff && peep->StaffType == STAFF_TYPE_ENTERTAINER) screenCoords.y++; int32_t ebx = g_peep_animation_entries[peep->SpriteType].sprite_animation->base_image + 1; diff --git a/src/openrct2/actions/GuestSetNameAction.hpp b/src/openrct2/actions/GuestSetNameAction.hpp index 4b1ab31521..fcfe53b717 100644 --- a/src/openrct2/actions/GuestSetNameAction.hpp +++ b/src/openrct2/actions/GuestSetNameAction.hpp @@ -73,7 +73,7 @@ public: } auto peep = GET_PEEP(_spriteIndex); - if (peep->AssignedPeepType != PEEP_TYPE_GUEST) + if (peep->AssignedPeepType != PeepType::Guest) { log_warning("Invalid game command for sprite %u", _spriteIndex); return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_NAME_GUEST, STR_NONE); @@ -85,7 +85,7 @@ public: GameActionResult::Ptr Execute() const override { auto peep = GET_PEEP(_spriteIndex); - if (peep->AssignedPeepType != PEEP_TYPE_GUEST) + if (peep->AssignedPeepType != PeepType::Guest) { log_warning("Invalid game command for sprite %u", _spriteIndex); return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_CANT_NAME_GUEST, STR_NONE); diff --git a/src/openrct2/actions/SetCheatAction.hpp b/src/openrct2/actions/SetCheatAction.hpp index 63c0b31df6..bb9c758703 100644 --- a/src/openrct2/actions/SetCheatAction.hpp +++ b/src/openrct2/actions/SetCheatAction.hpp @@ -688,7 +688,7 @@ private: // will be fetched on a deleted peep. for (auto peep : EntityList(EntityListId::Peep)) { - if (peep->AssignedPeepType == PEEP_TYPE_GUEST) + if (peep->AssignedPeepType == PeepType::Guest) { peep->Remove(); } diff --git a/src/openrct2/actions/StaffFireAction.hpp b/src/openrct2/actions/StaffFireAction.hpp index 133c2926bc..99ca31481f 100644 --- a/src/openrct2/actions/StaffFireAction.hpp +++ b/src/openrct2/actions/StaffFireAction.hpp @@ -48,7 +48,7 @@ public: } auto peep = GET_PEEP(_spriteId); - if (peep == nullptr || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->AssignedPeepType != PEEP_TYPE_STAFF) + if (peep == nullptr || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->AssignedPeepType != PeepType::Staff) { log_error("Invalid spriteId. spriteId = %u", _spriteId); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); @@ -60,7 +60,7 @@ public: GameActionResult::Ptr Execute() const override { auto peep = GET_PEEP(_spriteId); - if (peep == nullptr || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->AssignedPeepType != PEEP_TYPE_STAFF) + if (peep == nullptr || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->AssignedPeepType != PeepType::Staff) { log_error("Invalid spriteId. spriteId = %u", _spriteId); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); diff --git a/src/openrct2/actions/StaffHireNewAction.hpp b/src/openrct2/actions/StaffHireNewAction.hpp index ff8536258f..ace7a49ccf 100644 --- a/src/openrct2/actions/StaffHireNewAction.hpp +++ b/src/openrct2/actions/StaffHireNewAction.hpp @@ -166,7 +166,7 @@ private: newPeep->WalkingFrameNum = 0; newPeep->ActionSpriteType = PEEP_ACTION_SPRITE_TYPE_NONE; newPeep->PathCheckOptimisation = 0; - newPeep->AssignedPeepType = PEEP_TYPE_STAFF; + newPeep->AssignedPeepType = PeepType::Staff; newPeep->OutsideOfPark = false; newPeep->PeepFlags = 0; newPeep->PaidToEnter = 0; diff --git a/src/openrct2/actions/StaffSetCostumeAction.hpp b/src/openrct2/actions/StaffSetCostumeAction.hpp index c3e0804be3..cc33042a77 100644 --- a/src/openrct2/actions/StaffSetCostumeAction.hpp +++ b/src/openrct2/actions/StaffSetCostumeAction.hpp @@ -74,7 +74,7 @@ public: } Peep* peep = GET_PEEP(_spriteIndex); - if (peep->AssignedPeepType != PEEP_TYPE_STAFF || peep->StaffType != STAFF_TYPE_ENTERTAINER) + if (peep->AssignedPeepType != PeepType::Staff || peep->StaffType != STAFF_TYPE_ENTERTAINER) { log_warning("Invalid game command for sprite %u", _spriteIndex); return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_NONE); diff --git a/src/openrct2/actions/StaffSetNameAction.hpp b/src/openrct2/actions/StaffSetNameAction.hpp index be0882e13b..7d95532592 100644 --- a/src/openrct2/actions/StaffSetNameAction.hpp +++ b/src/openrct2/actions/StaffSetNameAction.hpp @@ -59,7 +59,7 @@ public: } auto peep = GET_PEEP(_spriteIndex); - if (peep->AssignedPeepType != PEEP_TYPE_STAFF) + if (peep->AssignedPeepType != PeepType::Staff) { log_warning("Invalid game command for sprite %u", _spriteIndex); return std::make_unique( @@ -72,7 +72,7 @@ public: GameActionResult::Ptr Execute() const override { auto peep = GET_PEEP(_spriteIndex); - if (peep->AssignedPeepType != PEEP_TYPE_STAFF) + if (peep->AssignedPeepType != PeepType::Staff) { log_warning("Invalid game command for sprite %u", _spriteIndex); return std::make_unique( diff --git a/src/openrct2/actions/StaffSetOrdersAction.hpp b/src/openrct2/actions/StaffSetOrdersAction.hpp index aae346f9a0..1c9405e979 100644 --- a/src/openrct2/actions/StaffSetOrdersAction.hpp +++ b/src/openrct2/actions/StaffSetOrdersAction.hpp @@ -54,7 +54,7 @@ public: } Peep* peep = GET_PEEP(_spriteIndex); - if (peep->AssignedPeepType != PEEP_TYPE_STAFF + if (peep->AssignedPeepType != PeepType::Staff || (peep->StaffType != STAFF_TYPE_HANDYMAN && peep->StaffType != STAFF_TYPE_MECHANIC)) { log_warning("Invalid game command for sprite %u", _spriteIndex); diff --git a/src/openrct2/actions/StaffSetPatrolAreaAction.hpp b/src/openrct2/actions/StaffSetPatrolAreaAction.hpp index f9f67c0225..547ae106e7 100644 --- a/src/openrct2/actions/StaffSetPatrolAreaAction.hpp +++ b/src/openrct2/actions/StaffSetPatrolAreaAction.hpp @@ -56,7 +56,7 @@ public: } auto peep = GET_PEEP(_spriteId); - if (peep == nullptr || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->AssignedPeepType != PEEP_TYPE_STAFF) + if (peep == nullptr || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->AssignedPeepType != PeepType::Staff) { log_error("Invalid spriteId. spriteId = %u", _spriteId); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); @@ -68,7 +68,7 @@ public: GameActionResult::Ptr Execute() const override { auto peep = GET_PEEP(_spriteId); - if (peep == nullptr || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->AssignedPeepType != PEEP_TYPE_STAFF) + if (peep == nullptr || peep->sprite_identifier != SPRITE_IDENTIFIER_PEEP || peep->AssignedPeepType != PeepType::Staff) { log_error("Invalid spriteId. spriteId = %u", _spriteId); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_NONE); diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index 29f9259d0e..73c7006042 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -490,7 +490,7 @@ static int32_t cc_staff(InteractiveConsole& console, const arguments_t& argv) return 1; } peep = GET_PEEP(int_val[0]); - bool is_entertainer = peep != nullptr && peep->AssignedPeepType == PEEP_TYPE_STAFF + bool is_entertainer = peep != nullptr && peep->AssignedPeepType == PeepType::Staff && peep->StaffType == STAFF_TYPE_ENTERTAINER; if (!is_entertainer) { diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 9e52108d79..8db9c7c8e7 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -657,9 +657,9 @@ void viewport_update_smart_sprite_follow(rct_window* window) { Peep* peep = GET_PEEP(window->viewport_smart_follow_sprite); - if (peep->AssignedPeepType == PEEP_TYPE_GUEST) + if (peep->AssignedPeepType == PeepType::Guest) viewport_update_smart_guest_follow(window, peep); - else if (peep->AssignedPeepType == PEEP_TYPE_STAFF) + else if (peep->AssignedPeepType == PeepType::Staff) viewport_update_smart_staff_follow(window, peep); } else if (entity->sprite_identifier == SPRITE_IDENTIFIER_VEHICLE) diff --git a/src/openrct2/management/Award.cpp b/src/openrct2/management/Award.cpp index 5f0bdfc323..a6a78c57cd 100644 --- a/src/openrct2/management/Award.cpp +++ b/src/openrct2/management/Award.cpp @@ -270,7 +270,7 @@ static bool award_is_deserved_best_staff(int32_t activeAwardTypes) auto staffTypeFlags = 0; for (auto peep : EntityList(EntityListId::Peep)) { - if (peep->AssignedPeepType == PEEP_TYPE_STAFF) + if (peep->AssignedPeepType == PeepType::Staff) { staffCount++; staffTypeFlags |= (1 << peep->StaffType); diff --git a/src/openrct2/paint/sprite/Paint.Peep.cpp b/src/openrct2/paint/sprite/Paint.Peep.cpp index d02c96ff95..703fd0abfb 100644 --- a/src/openrct2/paint/sprite/Paint.Peep.cpp +++ b/src/openrct2/paint/sprite/Paint.Peep.cpp @@ -24,7 +24,7 @@ void peep_paint(paint_session* session, const Peep* peep, int32_t imageDirection #ifdef __ENABLE_LIGHTFX__ if (lightfx_is_available()) { - if (peep->AssignedPeepType == PEEP_TYPE_STAFF) + if (peep->AssignedPeepType == PeepType::Staff) { int16_t peep_x, peep_y, peep_z; diff --git a/src/openrct2/paint/sprite/Paint.Sprite.cpp b/src/openrct2/paint/sprite/Paint.Sprite.cpp index ed80502214..28555633dd 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 == PEEP_TYPE_STAFF && peep->StaffType == STAFF_TYPE_HANDYMAN)) + if (!(peep->AssignedPeepType == PeepType::Staff && peep->StaffType == STAFF_TYPE_HANDYMAN)) { continue; } diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 11db3bf5bb..fe39b40cc1 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -403,7 +403,7 @@ bool loc_690FD0(Peep* peep, uint8_t* rideToView, uint8_t* rideSeatToView, TileEl template<> bool SpriteBase::Is() const { auto peep = As(); - return peep && peep->AssignedPeepType == PEEP_TYPE_GUEST; + return peep && peep->AssignedPeepType == PeepType::Guest; } bool Guest::GuestHasValidXY() const diff --git a/src/openrct2/peep/GuestPathfinding.cpp b/src/openrct2/peep/GuestPathfinding.cpp index 2c0e1ebfc3..803bbeba41 100644 --- a/src/openrct2/peep/GuestPathfinding.cpp +++ b/src/openrct2/peep/GuestPathfinding.cpp @@ -438,7 +438,7 @@ static int32_t guest_path_find_aimless(Peep* peep, uint8_t edges) */ static uint8_t peep_pathfind_get_max_number_junctions(Peep* peep) { - if (peep->AssignedPeepType == PEEP_TYPE_STAFF) + if (peep->AssignedPeepType == PeepType::Staff) return 8; // PEEP_FLAGS_2? It's cleared here but not set anywhere! @@ -625,7 +625,7 @@ static void peep_pathfind_heuristic_search( } bool nextInPatrolArea = inPatrolArea; - if (peep->AssignedPeepType == PEEP_TYPE_STAFF && peep->StaffType == STAFF_TYPE_MECHANIC) + if (peep->AssignedPeepType == PeepType::Staff && peep->StaffType == STAFF_TYPE_MECHANIC) { nextInPatrolArea = peep->AsStaff()->IsLocationInPatrol(loc.ToCoordsXY()); if (inPatrolArea && !nextInPatrolArea) @@ -1168,9 +1168,9 @@ Direction peep_pathfind_choose_direction(const TileCoordsXYZ& loc, Peep* peep) /* The max number of tiles to check - a whole-search limit. * Mainly to limit the performance impact of the path finding. */ - int32_t maxTilesChecked = (peep->AssignedPeepType == PEEP_TYPE_STAFF) ? 50000 : 15000; + int32_t maxTilesChecked = (peep->AssignedPeepType == PeepType::Staff) ? 50000 : 15000; // Used to allow walking through no entry banners - _peepPathFindIsStaff = (peep->AssignedPeepType == PEEP_TYPE_STAFF); + _peepPathFindIsStaff = (peep->AssignedPeepType == PeepType::Staff); TileCoordsXYZ goal = gPeepPathFindGoalPosition; @@ -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 == PEEP_TYPE_STAFF && peep->StaffType == STAFF_TYPE_MECHANIC) + if (peep->AssignedPeepType == PeepType::Staff && peep->StaffType == STAFF_TYPE_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 eb5331634c..257fb2ce22 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -331,12 +331,12 @@ template<> bool SpriteBase::Is() const Guest* Peep::AsGuest() { - return AssignedPeepType == PEEP_TYPE_GUEST ? static_cast(this) : nullptr; + return AssignedPeepType == PeepType::Guest ? static_cast(this) : nullptr; } Staff* Peep::AsStaff() { - return AssignedPeepType == PEEP_TYPE_STAFF ? static_cast(this) : nullptr; + return AssignedPeepType == PeepType::Staff ? static_cast(this) : nullptr; } void Peep::Invalidate() @@ -683,7 +683,7 @@ void peep_window_state_update(Peep* peep) if (w != nullptr) window_event_invalidate_call(w); - if (peep->AssignedPeepType == PEEP_TYPE_GUEST) + if (peep->AssignedPeepType == PeepType::Guest) { if (peep->State == PEEP_STATE_ON_RIDE || peep->State == PEEP_STATE_ENTERING_RIDE) { @@ -784,7 +784,7 @@ std::unique_ptr Peep::Place(const TileCoordsXYZ& location, boo PathCheckOptimisation = 0; sprite_position_tween_reset(); - if (AssignedPeepType == PEEP_TYPE_GUEST) + if (AssignedPeepType == PeepType::Guest) { ActionSpriteType = PEEP_ACTION_SPRITE_TYPE_INVALID; HappinessTarget = std::max(HappinessTarget - 10, 0); @@ -813,17 +813,17 @@ void peep_sprite_remove(Peep* peep) window_close_by_number(WC_FIRE_PROMPT, peep->sprite_identifier); // Needed for invalidations after sprite removal - bool wasGuest = peep->AssignedPeepType == PEEP_TYPE_GUEST; - if (peep->AssignedPeepType == PEEP_TYPE_GUEST) + bool wasGuest = peep->AssignedPeepType == PeepType::Guest; + if (peep->AssignedPeepType == PeepType::Guest) { news_item_disable_news(NEWS_ITEM_PEEP_ON_RIDE, peep->sprite_index); } else { gStaffModes[peep->StaffId] = 0; - peep->AssignedPeepType = PEEP_TYPE_INVALID; + peep->AssignedPeepType = PeepType::Invalid; staff_update_greyed_patrol_areas(); - peep->AssignedPeepType = PEEP_TYPE_STAFF; + peep->AssignedPeepType = PeepType::Staff; news_item_disable_news(NEWS_ITEM_PEEP, peep->sprite_index); } @@ -838,7 +838,7 @@ void peep_sprite_remove(Peep* peep) */ void Peep::Remove() { - if (AssignedPeepType == PEEP_TYPE_GUEST) + if (AssignedPeepType == PeepType::Guest) { if (!OutsideOfPark) { @@ -981,7 +981,7 @@ void Peep::Update1() if (!CheckForPath()) return; - if (AssignedPeepType == PEEP_TYPE_GUEST) + if (AssignedPeepType == PeepType::Guest) { SetState(PEEP_STATE_WALKING); } @@ -1085,7 +1085,7 @@ static void peep_update_thoughts(Peep* peep) */ void Peep::Update() { - if (AssignedPeepType == PEEP_TYPE_GUEST) + if (AssignedPeepType == PeepType::Guest) { if (PreviousRide != RIDE_ID_NULL) if (++PreviousRideTimeOut >= 720) @@ -1608,7 +1608,7 @@ Peep* Peep::Generate(const CoordsXYZ& coords) peep->Mass = (scenario_rand() & 0x1F) + 45; peep->PathCheckOptimisation = 0; peep->InteractionRideIndex = RIDE_ID_NULL; - peep->AssignedPeepType = PEEP_TYPE_GUEST; + peep->AssignedPeepType = PeepType::Guest; peep->PreviousRide = RIDE_ID_NULL; peep->Thoughts->type = PEEP_THOUGHT_TYPE_NONE; peep->WindowInvalidateFlags = 0; @@ -1931,7 +1931,7 @@ void Peep::FormatNameTo(Formatter& ft) const { if (Name == nullptr) { - if (AssignedPeepType == PeepType::PEEP_TYPE_STAFF) + if (AssignedPeepType == PeepType::Staff) { static constexpr const rct_string_id staffNames[] = { STR_HANDYMAN_X, @@ -2176,7 +2176,7 @@ int32_t get_peep_face_sprite_large(Peep* peep) void peep_set_map_tooltip(Peep* peep) { auto ft = Formatter::MapTooltip(); - if (peep->AssignedPeepType == PEEP_TYPE_GUEST) + if (peep->AssignedPeepType == PeepType::Guest) { ft.Add((peep->PeepFlags & PEEP_FLAGS_TRACKING) ? STR_TRACKED_GUEST_MAP_TIP : STR_GUEST_MAP_TIP); ft.Add(get_peep_face_sprite_small(peep)); @@ -2602,7 +2602,7 @@ static void peep_footpath_move_forward(Peep* peep, const CoordsXYE& coords, bool int16_t z = peep->GetZOnSlope(coords.x, coords.y); - if (peep->AssignedPeepType == PEEP_TYPE_STAFF) + if (peep->AssignedPeepType == PeepType::Staff) { peep->MoveTo({ coords, z }); return; @@ -3084,10 +3084,10 @@ void Peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result) } } while (!(tileElement++)->IsLastForTile()); - if (AssignedPeepType == PEEP_TYPE_STAFF || (GetNextIsSurface())) + if (AssignedPeepType == PeepType::Staff || (GetNextIsSurface())) { int16_t height = abs(tile_element_height(newLoc) - z); - if (height <= 3 || (AssignedPeepType == PEEP_TYPE_STAFF && height <= 32)) + if (height <= 3 || (AssignedPeepType == PeepType::Staff && height <= 32)) { InteractionRideIndex = 0xFF; if (State == PEEP_STATE_QUEUING) @@ -3116,7 +3116,7 @@ void Peep::PerformNextAction(uint8_t& pathing_result, TileElement*& tile_result) return; } - if (AssignedPeepType == PEEP_TYPE_STAFF && !GetNextIsSurface()) + if (AssignedPeepType == PeepType::Staff && !GetNextIsSurface()) { // Prevent staff from leaving the path on their own unless they're allowed to mow. if (!((this->StaffOrders & STAFF_ORDERS_MOWING) && this->StaffMowingTimeout >= 12)) @@ -3208,7 +3208,7 @@ int32_t peep_compare(const uint16_t sprite_index_a, const uint16_t sprite_index_ // Compare types if (peep_a->AssignedPeepType != peep_b->AssignedPeepType) { - return peep_a->AssignedPeepType - peep_b->AssignedPeepType; + return static_cast(peep_a->AssignedPeepType) - static_cast(peep_b->AssignedPeepType); } if (peep_a->Name == nullptr && peep_b->Name == nullptr) diff --git a/src/openrct2/peep/Peep.h b/src/openrct2/peep/Peep.h index 6728f91a05..06deb41371 100644 --- a/src/openrct2/peep/Peep.h +++ b/src/openrct2/peep/Peep.h @@ -52,12 +52,12 @@ struct Ride; class GameActionResult; using ParkEntranceIndex = uint8_t; -enum PeepType : uint8_t +enum class PeepType : uint8_t { - PEEP_TYPE_GUEST, - PEEP_TYPE_STAFF, + Guest, + Staff, - PEEP_TYPE_INVALID = 0xFF + Invalid = 0xFF }; enum PeepThoughtType : uint8_t diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index daef7e8b2c..9e8e2b420a 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -82,7 +82,7 @@ colour_t gStaffSecurityColour; template<> bool SpriteBase::Is() const { auto peep = As(); - return peep && peep->AssignedPeepType == PEEP_TYPE_STAFF; + return peep && peep->AssignedPeepType == PeepType::Staff; } /** @@ -225,7 +225,7 @@ bool staff_can_ignore_wide_flag(Peep* staff, const CoordsXYZ& staffPos, TileElem * both of these tiles are connected wide paths, the wide flag can be * ignored. */ - if (staff->AssignedPeepType != PEEP_TYPE_STAFF) + if (staff->AssignedPeepType != PeepType::Staff) return false; if (!staff_is_location_on_patrol_edge(staff, staffPos)) @@ -1857,7 +1857,7 @@ void Staff::Tick128UpdateStaff() bool Staff::IsMechanic() const { return ( - sprite_identifier == SPRITE_IDENTIFIER_PEEP && AssignedPeepType == PEEP_TYPE_STAFF && StaffType == STAFF_TYPE_MECHANIC); + sprite_identifier == SPRITE_IDENTIFIER_PEEP && AssignedPeepType == PeepType::Staff && StaffType == STAFF_TYPE_MECHANIC); } void Staff::UpdateStaff(uint32_t stepsToTake) diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index d6609801c2..c1ec835373 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1552,7 +1552,7 @@ private: dst->ItemStandardFlags = src->item_standard_flags; - if (dst->AssignedPeepType == PEEP_TYPE_GUEST) + if (dst->AssignedPeepType == PeepType::Guest) { if (dst->OutsideOfPark && dst->State != PEEP_STATE_LEAVING_PARK) { diff --git a/src/openrct2/rct2/S6Exporter.cpp b/src/openrct2/rct2/S6Exporter.cpp index bde06636a5..c3d8376251 100644 --- a/src/openrct2/rct2/S6Exporter.cpp +++ b/src/openrct2/rct2/S6Exporter.cpp @@ -1111,7 +1111,7 @@ void S6Exporter::ExportSpritePeep(RCT2SpritePeep* dst, const Peep* src) } if (generateName) { - if (src->AssignedPeepType == PeepType::PEEP_TYPE_STAFF) + if (src->AssignedPeepType == PeepType::Staff) { static constexpr const rct_string_id staffNames[] = { STR_HANDYMAN_X, diff --git a/src/openrct2/scripting/ScEntity.hpp b/src/openrct2/scripting/ScEntity.hpp index ee4836ecdc..e331ff4bd7 100644 --- a/src/openrct2/scripting/ScEntity.hpp +++ b/src/openrct2/scripting/ScEntity.hpp @@ -643,7 +643,7 @@ namespace OpenRCT2::Scripting auto peep = GetPeep(); if (peep != nullptr) { - return peep->AssignedPeepType == PEEP_TYPE_STAFF ? "staff" : "guest"; + return peep->AssignedPeepType == PeepType::Staff ? "staff" : "guest"; } return ""; } diff --git a/src/openrct2/scripting/ScMap.hpp b/src/openrct2/scripting/ScMap.hpp index 6c57df5e55..64f493158e 100644 --- a/src/openrct2/scripting/ScMap.hpp +++ b/src/openrct2/scripting/ScMap.hpp @@ -182,7 +182,7 @@ namespace OpenRCT2::Scripting case SPRITE_IDENTIFIER_VEHICLE: return GetObjectAsDukValue(_context, std::make_shared(spriteId)); case SPRITE_IDENTIFIER_PEEP: - if (sprite->peep.AssignedPeepType == PEEP_TYPE_STAFF) + if (sprite->peep.AssignedPeepType == PeepType::Staff) return GetObjectAsDukValue(_context, std::make_shared(spriteId)); else return GetObjectAsDukValue(_context, std::make_shared(spriteId));