mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-18 04:23:20 +01:00
* Refactor STAFF_MODE to use strong enum Closes #12432 * Change type of gStaffModes to StaffMode
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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++)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<uint8_t>(StaffType::Count)) * STAFF_PATROL_AREA_SIZE];
|
||||
uint8_t gStaffModes[STAFF_MAX_COUNT + static_cast<uint8_t>(StaffType::Count)];
|
||||
StaffMode gStaffModes[STAFF_MAX_COUNT + static_cast<uint8_t>(StaffType::Count)];
|
||||
uint16_t gStaffDrawPatrolAreas;
|
||||
colour_t gStaffHandymanColour;
|
||||
colour_t gStaffMechanicColour;
|
||||
@@ -92,10 +92,10 @@ template<> bool SpriteBase::Is<Staff>() 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<uint8_t>(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);
|
||||
|
||||
@@ -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<uint8_t>(StaffType::Count)];
|
||||
extern const rct_string_id StaffCostumeNames[ENTERTAINER_COSTUME_COUNT];
|
||||
|
||||
extern uint32_t gStaffPatrolAreas[(STAFF_MAX_COUNT + static_cast<uint8_t>(StaffType::Count)) * STAFF_PATROL_AREA_SIZE];
|
||||
extern uint8_t gStaffModes[STAFF_MAX_COUNT + static_cast<uint8_t>(StaffType::Count)];
|
||||
extern StaffMode gStaffModes[STAFF_MAX_COUNT + static_cast<uint8_t>(StaffType::Count)];
|
||||
extern uint16_t gStaffDrawPatrolAreas;
|
||||
extern colour_t gStaffHandymanColour;
|
||||
extern colour_t gStaffMechanicColour;
|
||||
|
||||
@@ -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<Staff>(EntityListId::Peep))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user