Fix plans/route line viewport mark dirty not being wide enough

pull/195/head
Jonathan G Rennison 4 years ago
parent b4ceb93406
commit 7e68459ebd

@ -3703,12 +3703,15 @@ void MarkTileLineDirty(const TileIndex from_tile, const TileIndex to_tile, Viewp
const Point from_pt = RemapCoords2(TileX(from_tile) * TILE_SIZE + TILE_SIZE / 2, TileY(from_tile) * TILE_SIZE + TILE_SIZE / 2);
const Point to_pt = RemapCoords2(TileX(to_tile) * TILE_SIZE + TILE_SIZE / 2, TileY(to_tile) * TILE_SIZE + TILE_SIZE / 2);
const int block_radius = 20;
for (Viewport * const vp : _viewport_window_cache) {
if (flags & VMDF_NOT_MAP_MODE && vp->zoom >= ZOOM_LVL_DRAW_MAP) continue;
int x1 = from_pt.x / block_radius;
int y1 = from_pt.y / block_radius;
const int x2 = to_pt.x / block_radius;
const int y2 = to_pt.y / block_radius;
const int block_shift = 2 + vp->zoom;
int x1 = from_pt.x >> block_shift;
int y1 = from_pt.y >> block_shift;
const int x2 = to_pt.x >> block_shift;
const int y2 = to_pt.y >> block_shift;
/* http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm#Simplification */
const int dx = abs(x2 - x1);
@ -3717,11 +3720,12 @@ void MarkTileLineDirty(const TileIndex from_tile, const TileIndex to_tile, Viewp
const int sy = (y1 < y2) ? 1 : -1;
int err = dx - dy;
for (;;) {
MarkAllViewportsDirty(
(x1 - 1) * block_radius,
(y1 - 1) * block_radius,
(x1 + 1) * block_radius,
(y1 + 1) * block_radius,
MarkViewportDirty(
vp,
(x1 - 1) << block_shift,
(y1 - 1) << block_shift,
(x1 + 2) << block_shift,
(y1 + 2) << block_shift,
flags
);
if (x1 == x2 && y1 == y2) break;
@ -3736,6 +3740,7 @@ void MarkTileLineDirty(const TileIndex from_tile, const TileIndex to_tile, Viewp
}
}
}
}
static void MarkRoutePathsDirty(const std::vector<DrawnPathRouteTileLine> &lines)
{

Loading…
Cancel
Save