mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-04 13:42:55 +01:00
Merge pull request #12175 from Jimver/staff_coords_refactor
Closes #12162: Staff coords refactor
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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++)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user