diff --git a/contributors.md b/contributors.md index 0919871312..321e18d1a1 100644 --- a/contributors.md +++ b/contributors.md @@ -87,7 +87,7 @@ The following people are not part of the development team, but have been contrib * Chad Ian Anderson (pizza2004) - Added New Game option, bug fixes, misc. * Peter Ryszkiewicz (pRizz) - Added horizontal grid lines to finance charts. * Hudson Oliveira (hdpoliveira) - Misc. -* Jim Verheijde (Jimver) - Make handymen less likely to get stuck in queue lines. +* Jim Verheijde (Jimver) - Make handymen less likely to get stuck in queue lines, misc. ## Bug fixes * (halfbro) diff --git a/src/openrct2/actions/StaffSetPatrolAreaAction.hpp b/src/openrct2/actions/StaffSetPatrolAreaAction.hpp index 083ea79bd7..c4d71c7917 100644 --- a/src/openrct2/actions/StaffSetPatrolAreaAction.hpp +++ b/src/openrct2/actions/StaffSetPatrolAreaAction.hpp @@ -76,7 +76,7 @@ public: int32_t patrolOffset = peep->StaffId * STAFF_PATROL_AREA_SIZE; - staff_toggle_patrol_area(peep->StaffId, _loc.x, _loc.y); + staff_toggle_patrol_area(peep->StaffId, _loc); bool isPatrolling = false; for (int32_t i = 0; i < 128; i++) diff --git a/src/openrct2/peep/Staff.cpp b/src/openrct2/peep/Staff.cpp index 5578f88ba6..951fa6ade6 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -373,7 +373,7 @@ void staff_reset_stats() } } -static bool staff_is_patrol_area_set(int32_t staffIndex, int32_t x, int32_t y) +static bool staff_is_patrol_area_set(int32_t staffIndex, const CoordsXY& coords) { // Patrol quads are stored in a bit map (8 patrol quads per byte). // Each patrol quad is 4x4. @@ -381,33 +381,31 @@ static bool staff_is_patrol_area_set(int32_t staffIndex, int32_t x, int32_t y) // At the end of the array (after the slots for individual staff members), // there are slots that save the combined patrol area for every staff type. - x = (x & 0x1F80) >> 7; - y = (y & 0x1F80) >> 1; + auto offsetCoords = CoordsXY{ (coords.x & 0x1F80) >> 7, (coords.y & 0x1F80) >> 1 }; int32_t peepOffset = staffIndex * STAFF_PATROL_AREA_SIZE; - int32_t offset = (x | y) >> 5; - int32_t bitIndex = (x | y) & 0x1F; + int32_t offset = (offsetCoords.x | offsetCoords.y) >> 5; + int32_t bitIndex = (offsetCoords.x | offsetCoords.y) & 0x1F; return gStaffPatrolAreas[peepOffset + offset] & (1UL << bitIndex); } bool Staff::IsPatrolAreaSet(const CoordsXY& coords) const { - return staff_is_patrol_area_set(StaffId, coords.x, coords.y); + return staff_is_patrol_area_set(StaffId, coords); } bool staff_is_patrol_area_set_for_type(STAFF_TYPE type, const CoordsXY& coords) { - return staff_is_patrol_area_set(STAFF_MAX_COUNT + type, coords.x, coords.y); + return staff_is_patrol_area_set(STAFF_MAX_COUNT + type, coords); } -void staff_set_patrol_area(int32_t staffIndex, int32_t x, int32_t y, bool value) +void staff_set_patrol_area(int32_t staffIndex, const CoordsXY& coords, bool value) { - x = (x & 0x1F80) >> 7; - y = (y & 0x1F80) >> 1; + auto offsetCoords = CoordsXY{ (coords.x & 0x1F80) >> 7, (coords.y & 0x1F80) >> 1 }; int32_t peepOffset = staffIndex * STAFF_PATROL_AREA_SIZE; - int32_t offset = (x | y) >> 5; - int32_t bitIndex = (x | y) & 0x1F; + int32_t offset = (offsetCoords.x | offsetCoords.y) >> 5; + int32_t bitIndex = (offsetCoords.x | offsetCoords.y) & 0x1F; uint32_t* addr = &gStaffPatrolAreas[peepOffset + offset]; if (value) { @@ -419,14 +417,12 @@ void staff_set_patrol_area(int32_t staffIndex, int32_t x, int32_t y, bool value) } } -void staff_toggle_patrol_area(int32_t staffIndex, int32_t x, int32_t y) +void staff_toggle_patrol_area(int32_t staffIndex, const CoordsXY& coords) { - x = (x & 0x1F80) >> 7; - y = (y & 0x1F80) >> 1; - + auto offsetCoords = CoordsXY{ (coords.x & 0x1F80) >> 7, (coords.y & 0x1F80) >> 1 }; int32_t peepOffset = staffIndex * STAFF_PATROL_AREA_SIZE; - int32_t offset = (x | y) >> 5; - int32_t bitIndex = (x | y) & 0x1F; + int32_t offset = (offsetCoords.x | offsetCoords.y) >> 5; + int32_t bitIndex = (offsetCoords.x | offsetCoords.y) & 0x1F; gStaffPatrolAreas[peepOffset + offset] ^= (1 << bitIndex); } diff --git a/src/openrct2/peep/Staff.h b/src/openrct2/peep/Staff.h index 3826dee4d0..5760bac991 100644 --- a/src/openrct2/peep/Staff.h +++ b/src/openrct2/peep/Staff.h @@ -81,8 +81,8 @@ 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); -void staff_set_patrol_area(int32_t staffIndex, int32_t x, int32_t y, bool value); -void staff_toggle_patrol_area(int32_t staffIndex, int32_t x, int32_t y); +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); uint32_t staff_get_available_entertainer_costumes(); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index b1d1ff7a20..173e07b61c 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1619,7 +1619,7 @@ private: x <<= 7; int32_t y = val & 0x3E0; y <<= 2; - staff_set_patrol_area(staffmember->StaffId, x, y, true); + staff_set_patrol_area(staffmember->StaffId, { x, y }, true); } } }