Refactor similar loop in s4 and s6 import

This commit is contained in:
Ted John committed 2022-03-11 18:39:04 +00:00
1 parent 90718ca81c
commit 0aa6ceb2aa
4 files changed
+16 -14

No files matched your search

+11
View File
@@ -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;
+1
View File
@@ -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<TileCoordsXY> GetPatrolArea();
void SetPatrolArea(const std::vector<TileCoordsXY>& area);
+2 -7
View File
@@ -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);
}
}
}
+2 -7
View File
@@ -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);
}
}
}