mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-25 15:54:31 +01:00
Refactored the function into a separate get dirty rows function.
This commit is contained in:
@@ -377,52 +377,52 @@ void X8DrawingEngine::ConfigureDirtyGrid()
|
||||
|
||||
void X8DrawingEngine::DrawAllDirtyBlocks()
|
||||
{
|
||||
uint32_t dirtyBlockColumns = _dirtyGrid.BlockColumns;
|
||||
uint32_t dirtyBlockRows = _dirtyGrid.BlockRows;
|
||||
uint8_t* dirtyBlocks = _dirtyGrid.Blocks;
|
||||
|
||||
for (uint32_t x = 0; x < dirtyBlockColumns; x++)
|
||||
for (uint32_t x = 0; x < _dirtyGrid.BlockColumns; x++)
|
||||
{
|
||||
for (uint32_t y = 0; y < dirtyBlockRows; y++)
|
||||
for (uint32_t y = 0; y < _dirtyGrid.BlockRows; y++)
|
||||
{
|
||||
uint32_t yOffset = y * dirtyBlockColumns;
|
||||
if (dirtyBlocks[yOffset + x] == 0)
|
||||
uint32_t yOffset = y * _dirtyGrid.BlockColumns;
|
||||
if (_dirtyGrid.Blocks[yOffset + x] == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Determine columns
|
||||
uint32_t xx;
|
||||
for (xx = x; xx < dirtyBlockColumns; xx++)
|
||||
for (xx = x; xx < _dirtyGrid.BlockColumns; xx++)
|
||||
{
|
||||
if (dirtyBlocks[yOffset + xx] == 0)
|
||||
if (_dirtyGrid.Blocks[yOffset + xx] == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
uint32_t columns = xx - x;
|
||||
|
||||
// Check rows
|
||||
uint32_t yy;
|
||||
for (yy = y; yy < dirtyBlockRows; yy++)
|
||||
{
|
||||
uint32_t yyOffset = yy * dirtyBlockColumns;
|
||||
for (xx = x; xx < x + columns; xx++)
|
||||
{
|
||||
if (dirtyBlocks[yyOffset + xx] == 0)
|
||||
{
|
||||
goto endRowCheck;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endRowCheck:
|
||||
uint32_t rows = yy - y;
|
||||
uint32_t columns = xx - x;
|
||||
auto rows = GetNumDirtyRows(x, y, columns);
|
||||
DrawDirtyBlocks(x, y, columns, rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t X8DrawingEngine::GetNumDirtyRows(const uint32_t x, const uint32_t y, const uint32_t columns)
|
||||
{
|
||||
uint32_t yy = y;
|
||||
|
||||
for (yy = y; yy < _dirtyGrid.BlockRows; yy++)
|
||||
{
|
||||
uint32_t yyOffset = yy * _dirtyGrid.BlockColumns;
|
||||
for (uint32_t xx = x; xx < x + columns; xx++)
|
||||
{
|
||||
if (_dirtyGrid.Blocks[yyOffset + xx] == 0)
|
||||
{
|
||||
return yy - y;
|
||||
}
|
||||
}
|
||||
}
|
||||
return yy - y;
|
||||
}
|
||||
|
||||
void X8DrawingEngine::DrawDirtyBlocks(uint32_t x, uint32_t y, uint32_t columns, uint32_t rows)
|
||||
{
|
||||
uint32_t dirtyBlockColumns = _dirtyGrid.BlockColumns;
|
||||
|
||||
@@ -123,6 +123,7 @@ namespace OpenRCT2
|
||||
void ConfigureDirtyGrid();
|
||||
static void ResetWindowVisbilities();
|
||||
void DrawAllDirtyBlocks();
|
||||
uint32_t GetNumDirtyRows(const uint32_t x, const uint32_t y, const uint32_t columns);
|
||||
void DrawDirtyBlocks(uint32_t x, uint32_t y, uint32_t columns, uint32_t rows);
|
||||
};
|
||||
#ifdef __WARN_SUGGEST_FINAL_TYPES__
|
||||
|
||||
Reference in New Issue
Block a user