diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index b03501a804..cf0939a878 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -587,7 +587,7 @@ void window_staff_overview_mousedown(rct_window* w, rct_widgetindex widgetIndex, } // Disable clear patrol area if no area is set. - if (!(gStaffModes[peep->StaffId] & 2)) + if (gStaffModes[peep->StaffId] != StaffMode::Patrol) { dropdown_set_disabled(1, true); } @@ -616,7 +616,8 @@ void window_staff_overview_dropdown(rct_window* w, rct_widgetindex widgetIndex, { gStaffPatrolAreas[peep->StaffId * STAFF_PATROL_AREA_SIZE + i] = 0; } - gStaffModes[peep->StaffId] &= ~2; + assert(gStaffModes[peep->StaffId] == StaffMode::Patrol); + gStaffModes[peep->StaffId] = StaffMode::Walk; gfx_invalidate_screen(); staff_update_greyed_patrol_areas(); diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index dd3ff6c863..d8f88f4360 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -384,7 +384,7 @@ static void window_staff_list_tooldown(rct_window* w, rct_widgetindex widgetInde if (isPatrolAreaSet) { - if (!(gStaffModes[peep->StaffId] & 2)) + if (gStaffModes[peep->StaffId] != StaffMode::Patrol) { continue; } @@ -722,7 +722,7 @@ void window_staff_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_ gfx_draw_string_left_clipped(dpi, format, gCommonFormatArgs, COLOUR_BLACK, { actionOffset, y }, actionColumnSize); // True if a patrol path is set for the worker - if (gStaffModes[peep->StaffId] & 2) + if (gStaffModes[peep->StaffId] == StaffMode::Patrol) { gfx_draw_sprite(dpi, SPR_STAFF_PATROL_PATH, { nameColumnSize + 5, y }, 0); } diff --git a/src/openrct2/actions/StaffHireNewAction.hpp b/src/openrct2/actions/StaffHireNewAction.hpp index 148abb1b59..0cff265c84 100644 --- a/src/openrct2/actions/StaffHireNewAction.hpp +++ b/src/openrct2/actions/StaffHireNewAction.hpp @@ -134,7 +134,7 @@ private: int32_t staffIndex; for (staffIndex = 0; staffIndex < STAFF_MAX_COUNT; ++staffIndex) { - if (!(gStaffModes[staffIndex] & 1)) + if (gStaffModes[staffIndex] == StaffMode::None) break; } @@ -244,7 +244,7 @@ private: newPeep->StaffId = staffIndex; - gStaffModes[staffIndex] = STAFF_MODE_WALK; + gStaffModes[staffIndex] = StaffMode::Walk; for (int32_t i = 0; i < STAFF_PATROL_AREA_SIZE; i++) { diff --git a/src/openrct2/actions/StaffSetPatrolAreaAction.hpp b/src/openrct2/actions/StaffSetPatrolAreaAction.hpp index 47eef2e01a..a6f18c1e29 100644 --- a/src/openrct2/actions/StaffSetPatrolAreaAction.hpp +++ b/src/openrct2/actions/StaffSetPatrolAreaAction.hpp @@ -88,10 +88,13 @@ public: } } - gStaffModes[staff->StaffId] &= ~(1 << 1); if (isPatrolling) { - gStaffModes[staff->StaffId] |= (1 << 1); + gStaffModes[staff->StaffId] = StaffMode::Patrol; + } + else if (gStaffModes[staff->StaffId] == StaffMode::Patrol) + { + gStaffModes[staff->StaffId] = StaffMode::Walk; } for (int32_t y = 0; y < 4 * COORDS_XY_STEP; y += COORDS_XY_STEP) diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index bcc51fdbdb..4f3d55234a 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1232,7 +1232,7 @@ static int32_t cc_show_limits(InteractiveConsole& console, [[maybe_unused]] cons int32_t staffCount = 0; for (int32_t i = 0; i < STAFF_MAX_COUNT; ++i) { - if (gStaffModes[i] & 1) + if (gStaffModes[i] != StaffMode::None) { staffCount++; } diff --git a/src/openrct2/peep/Peep.cpp b/src/openrct2/peep/Peep.cpp index b4e8ad63ec..c48500c36c 100644 --- a/src/openrct2/peep/Peep.cpp +++ b/src/openrct2/peep/Peep.cpp @@ -820,7 +820,7 @@ void peep_sprite_remove(Peep* peep) } else { - gStaffModes[peep->StaffId] = 0; + gStaffModes[peep->StaffId] = StaffMode::None; peep->AssignedPeepType = PeepType::Invalid; staff_update_greyed_patrol_areas(); peep->AssignedPeepType = PeepType::Staff; diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index 454f3013d1..470f0cccce 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -73,7 +73,7 @@ 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 + static_cast(StaffType::Count)) * STAFF_PATROL_AREA_SIZE]; -uint8_t gStaffModes[STAFF_MAX_COUNT + static_cast(StaffType::Count)]; +StaffMode gStaffModes[STAFF_MAX_COUNT + static_cast(StaffType::Count)]; uint16_t gStaffDrawPatrolAreas; colour_t gStaffHandymanColour; colour_t gStaffMechanicColour; @@ -92,10 +92,10 @@ template<> bool SpriteBase::Is() const void staff_reset_modes() { for (int32_t i = 0; i < STAFF_MAX_COUNT; i++) - gStaffModes[i] = STAFF_MODE_NONE; + gStaffModes[i] = StaffMode::None; for (int32_t i = STAFF_MAX_COUNT; i < (STAFF_MAX_COUNT + static_cast(StaffType::Count)); i++) - gStaffModes[i] = STAFF_MODE_WALK; + gStaffModes[i] = StaffMode::Walk; staff_update_greyed_patrol_areas(); } @@ -181,7 +181,7 @@ bool Staff::IsLocationInPatrol(const CoordsXY& loc) const return false; // Check if staff has patrol area - if (!(gStaffModes[StaffId] & 2)) + if (gStaffModes[StaffId] != StaffMode::Patrol) return true; return IsPatrolAreaSet(loc); diff --git a/src/openrct2/peep/Staff.h b/src/openrct2/peep/Staff.h index 3dc45181d7..f00da921d9 100644 --- a/src/openrct2/peep/Staff.h +++ b/src/openrct2/peep/Staff.h @@ -18,11 +18,11 @@ // Right now, it's a 32-bit array like in RCT2. 32 * 128 = 4096 bits, which is also the number of 4x4 squares on a 256x256 map. #define STAFF_PATROL_AREA_SIZE 128 -enum STAFF_MODE +enum class StaffMode : uint8_t { - STAFF_MODE_NONE, - STAFF_MODE_WALK, - STAFF_MODE_PATROL = 3 + None, + Walk, + Patrol = 3 }; enum STAFF_ORDERS @@ -57,7 +57,7 @@ extern const money32 gStaffWageTable[static_cast(StaffType::Count)]; extern const rct_string_id StaffCostumeNames[ENTERTAINER_COSTUME_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 StaffMode gStaffModes[STAFF_MAX_COUNT + static_cast(StaffType::Count)]; extern uint16_t gStaffDrawPatrolAreas; extern colour_t gStaffHandymanColour; extern colour_t gStaffMechanicColour; diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index be409da1f4..1c5f944cb8 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1379,10 +1379,10 @@ private: } // The RCT2/OpenRCT2 structures are bigger than in RCT1, so set them to zero - std::fill(std::begin(gStaffModes), std::end(gStaffModes), 0); + std::fill(std::begin(gStaffModes), std::end(gStaffModes), StaffMode::None); std::fill(std::begin(gStaffPatrolAreas), std::end(gStaffPatrolAreas), 0); - std::copy(std::begin(_s4.staff_modes), std::end(_s4.staff_modes), gStaffModes); + std::fill(std::begin(_s4.staff_modes), std::end(_s4.staff_modes), 0); for (auto peep : EntityList(EntityListId::Peep)) {