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..83d1d45ce8 100644 --- a/src/openrct2/peep/Staff.cpp +++ b/src/openrct2/peep/Staff.cpp @@ -419,14 +419,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..d541d906cb 100644 --- a/src/openrct2/peep/Staff.h +++ b/src/openrct2/peep/Staff.h @@ -82,7 +82,7 @@ bool staff_can_ignore_wide_flag(Peep* mechanic, const CoordsXYZ& staffPos, TileE 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_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();