diff --git a/src/openrct2/entity/Staff.cpp b/src/openrct2/entity/Staff.cpp index 195056413c..da4dd878df 100644 --- a/src/openrct2/entity/Staff.cpp +++ b/src/openrct2/entity/Staff.cpp @@ -299,6 +299,17 @@ void Staff::SetPatrolArea(const CoordsXY& coords, bool value) PatrolInfo->Set(coords, value); } +void Staff::SetPatrolArea(const MapRange& range, bool value) +{ + for (int32_t yy = range.GetTop(); yy <= range.GetBottom(); yy += COORDS_XY_STEP) + { + for (int32_t xx = range.GetLeft(); xx <= range.GetRight(); xx += COORDS_XY_STEP) + { + SetPatrolArea({ xx, yy }, value); + } + } +} + void Staff::ClearPatrolArea() { delete PatrolInfo; diff --git a/src/openrct2/entity/Staff.h b/src/openrct2/entity/Staff.h index 472665dc0b..d373e99be7 100644 --- a/src/openrct2/entity/Staff.h +++ b/src/openrct2/entity/Staff.h @@ -63,6 +63,7 @@ public: void ClearPatrolArea(); void SetPatrolArea(const CoordsXY& coords, bool value); + void SetPatrolArea(const MapRange& range, bool value); bool HasPatrolArea() const; std::vector GetPatrolArea(); void SetPatrolArea(const std::vector& area); diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 7530c8f64e..4bd196d03f 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -1361,13 +1361,8 @@ namespace RCT1 x <<= 7; int32_t y = val & 0x3E0; y <<= 2; - for (int32_t offsetY = 0; offsetY < 4 * COORDS_XY_STEP; offsetY += COORDS_XY_STEP) - { - for (int32_t offsetX = 0; offsetX < 4 * COORDS_XY_STEP; offsetX += COORDS_XY_STEP) - { - staffmember->SetPatrolArea({ x + offsetX, y + offsetY }, true); - } - } + staffmember->SetPatrolArea( + MapRange(x, y, x + (4 * COORDS_XY_STEP) - 1, y + (4 * COORDS_XY_STEP) - 1), true); } } } diff --git a/src/openrct2/rct2/S6Importer.cpp b/src/openrct2/rct2/S6Importer.cpp index a4d667e48c..2d1261b32b 100644 --- a/src/openrct2/rct2/S6Importer.cpp +++ b/src/openrct2/rct2/S6Importer.cpp @@ -1516,13 +1516,8 @@ namespace RCT2 x <<= 7; int32_t y = val & 0xFC0; y <<= 1; - for (int32_t offsetY = 0; offsetY < 4 * COORDS_XY_STEP; offsetY += COORDS_XY_STEP) - { - for (int32_t offsetX = 0; offsetX < 4 * COORDS_XY_STEP; offsetX += COORDS_XY_STEP) - { - staffmember->SetPatrolArea({ x + offsetX, y + offsetY }, true); - } - } + staffmember->SetPatrolArea( + MapRange(x, y, x + (4 * COORDS_XY_STEP) - 1, y + (4 * COORDS_XY_STEP) - 1), true); } } }