Fix plans/route line viewport mark dirty not being wide enough
This commit is contained in:
@@ -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 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 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;
|
const int block_shift = 2 + vp->zoom;
|
||||||
int y1 = from_pt.y / block_radius;
|
|
||||||
const int x2 = to_pt.x / block_radius;
|
int x1 = from_pt.x >> block_shift;
|
||||||
const int y2 = to_pt.y / block_radius;
|
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 */
|
/* http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm#Simplification */
|
||||||
const int dx = abs(x2 - x1);
|
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;
|
const int sy = (y1 < y2) ? 1 : -1;
|
||||||
int err = dx - dy;
|
int err = dx - dy;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
MarkAllViewportsDirty(
|
MarkViewportDirty(
|
||||||
(x1 - 1) * block_radius,
|
vp,
|
||||||
(y1 - 1) * block_radius,
|
(x1 - 1) << block_shift,
|
||||||
(x1 + 1) * block_radius,
|
(y1 - 1) << block_shift,
|
||||||
(y1 + 1) * block_radius,
|
(x1 + 2) << block_shift,
|
||||||
|
(y1 + 2) << block_shift,
|
||||||
flags
|
flags
|
||||||
);
|
);
|
||||||
if (x1 == x2 && y1 == y2) break;
|
if (x1 == x2 && y1 == y2) break;
|
||||||
@@ -3735,6 +3739,7 @@ void MarkTileLineDirty(const TileIndex from_tile, const TileIndex to_tile, Viewp
|
|||||||
y1 += sy;
|
y1 += sy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MarkRoutePathsDirty(const std::vector<DrawnPathRouteTileLine> &lines)
|
static void MarkRoutePathsDirty(const std::vector<DrawnPathRouteTileLine> &lines)
|
||||||
|
|||||||
Reference in New Issue
Block a user