Clear dirty rect during map updates
Previous solution to replace squares was destructive in nature and could possibly lead to unexpected things (especially with mods where tile 0x293 might not be opaque black). New solution follows mapper refresh routines where entire dirty rect is reset to black as a preparation step.
This commit is contained in:
parent
d040ea814a
commit
a5cefd6c8b
56
src/map.cc
56
src/map.cc
|
@ -1503,36 +1503,44 @@ static void isoWindowRefreshRect(Rect* rect)
|
||||||
// 0x483EE4
|
// 0x483EE4
|
||||||
static void isoWindowRefreshRectGame(Rect* rect)
|
static void isoWindowRefreshRectGame(Rect* rect)
|
||||||
{
|
{
|
||||||
Rect clampedDirtyRect;
|
Rect rectToUpdate;
|
||||||
if (rectIntersection(rect, &gIsoWindowRect, &clampedDirtyRect) == -1) {
|
if (rectIntersection(rect, &gIsoWindowRect, &rectToUpdate) == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tileRenderFloorsInRect(&clampedDirtyRect, gElevation);
|
// CE: Clear dirty rect to prevent most of the visual artifacts near map
|
||||||
_grid_render(&clampedDirtyRect, gElevation);
|
// edges.
|
||||||
_obj_render_pre_roof(&clampedDirtyRect, gElevation);
|
bufferFill(gIsoWindowBuffer + rectToUpdate.top * rectGetWidth(&gIsoWindowRect) + rectToUpdate.left,
|
||||||
tileRenderRoofsInRect(&clampedDirtyRect, gElevation);
|
rectGetWidth(&rectToUpdate),
|
||||||
_obj_render_post_roof(&clampedDirtyRect, gElevation);
|
rectGetHeight(&rectToUpdate),
|
||||||
|
rectGetWidth(&gIsoWindowRect),
|
||||||
|
0);
|
||||||
|
|
||||||
|
tileRenderFloorsInRect(&rectToUpdate, gElevation);
|
||||||
|
_obj_render_pre_roof(&rectToUpdate, gElevation);
|
||||||
|
tileRenderRoofsInRect(&rectToUpdate, gElevation);
|
||||||
|
_obj_render_post_roof(&rectToUpdate, gElevation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x483F44
|
// 0x483F44
|
||||||
static void isoWindowRefreshRectMapper(Rect* rect)
|
static void isoWindowRefreshRectMapper(Rect* rect)
|
||||||
{
|
{
|
||||||
Rect clampedDirtyRect;
|
Rect rectToUpdate;
|
||||||
if (rectIntersection(rect, &gIsoWindowRect, &clampedDirtyRect) == -1) {
|
if (rectIntersection(rect, &gIsoWindowRect, &rectToUpdate) == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferFill(gIsoWindowBuffer + clampedDirtyRect.top * (_scr_size.right - _scr_size.left + 1) + clampedDirtyRect.left,
|
bufferFill(gIsoWindowBuffer + rectToUpdate.top * rectGetWidth(&gIsoWindowRect) + rectToUpdate.left,
|
||||||
clampedDirtyRect.right - clampedDirtyRect.left + 1,
|
rectGetWidth(&rectToUpdate),
|
||||||
clampedDirtyRect.bottom - clampedDirtyRect.top + 1,
|
rectGetHeight(&rectToUpdate),
|
||||||
_scr_size.right - _scr_size.left + 1,
|
rectGetWidth(&gIsoWindowRect),
|
||||||
0);
|
0);
|
||||||
tileRenderFloorsInRect(&clampedDirtyRect, gElevation);
|
|
||||||
_grid_render(&clampedDirtyRect, gElevation);
|
tileRenderFloorsInRect(&rectToUpdate, gElevation);
|
||||||
_obj_render_pre_roof(&clampedDirtyRect, gElevation);
|
_grid_render(&rectToUpdate, gElevation);
|
||||||
tileRenderRoofsInRect(&clampedDirtyRect, gElevation);
|
_obj_render_pre_roof(&rectToUpdate, gElevation);
|
||||||
_obj_render_post_roof(&clampedDirtyRect, gElevation);
|
tileRenderRoofsInRect(&rectToUpdate, gElevation);
|
||||||
|
_obj_render_post_roof(&rectToUpdate, gElevation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Inlined.
|
// NOTE: Inlined.
|
||||||
|
@ -1721,18 +1729,6 @@ static int _square_load(File* stream, int flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CE: Replace null tiles with a solid black tiles. This prevents copying
|
|
||||||
// buffer contents of nearby tiles during scrolling and repeating hex
|
|
||||||
// pointer when hovering mouse over null tiles.
|
|
||||||
for (int elevation = 0; elevation < ELEVATION_COUNT; elevation++) {
|
|
||||||
for (int tileIndex = 0; tileIndex < SQUARE_GRID_SIZE; tileIndex++) {
|
|
||||||
int tile = _square[elevation]->field_0[tileIndex];
|
|
||||||
if (tile == 0x00010001) {
|
|
||||||
_square[elevation]->field_0[tileIndex] = 0x00010293;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -631,6 +631,14 @@ static void tileRefreshGame(Rect* rect, int elevation)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CE: Clear dirty rect to prevent most of the visual artifacts near map
|
||||||
|
// edges.
|
||||||
|
bufferFill(gTileWindowBuffer + rectToUpdate.top * gTileWindowPitch + rectToUpdate.left,
|
||||||
|
rectGetWidth(&rectToUpdate),
|
||||||
|
rectGetHeight(&rectToUpdate),
|
||||||
|
gTileWindowPitch,
|
||||||
|
0);
|
||||||
|
|
||||||
tileRenderFloorsInRect(&rectToUpdate, elevation);
|
tileRenderFloorsInRect(&rectToUpdate, elevation);
|
||||||
_obj_render_pre_roof(&rectToUpdate, elevation);
|
_obj_render_pre_roof(&rectToUpdate, elevation);
|
||||||
tileRenderRoofsInRect(&rectToUpdate, elevation);
|
tileRenderRoofsInRect(&rectToUpdate, elevation);
|
||||||
|
|
Loading…
Reference in New Issue