Skip to content

Commit

Permalink
Merge pull request #1274 from jfisher446/jfisher446-design-overcount
Browse files Browse the repository at this point in the history
[gui/design] Update Line & Freeform tools to not overcount tiles
  • Loading branch information
myk002 authored Aug 23, 2024
2 parents b845dd4 + 3c6befd commit 02d90fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Template for new versions:
## Fixes
- `timestream`: ensure child growth events (e.g. becoming an adult) are not skipped over
- `empty-bin`: ``--liquids`` option correctly emptying containers filled with LIQUID_MISC
- `gui/design`: Update Line & Freeform tools to not overcount tiles

## Misc Improvements
- `gui/sitemap`: show whether a unit is friendly, hostile, or wildlife
Expand Down
12 changes: 8 additions & 4 deletions internal/design/shapes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,10 @@ function Line:plot_bresenham(x0, y0, x1, y1, thickness)
while true do
for j = -math.floor(thickness / 2), math.ceil(thickness / 2) - 1 do
if not self.arr[x + j] then self.arr[x + j] = {} end
self.arr[x + j][y] = true
self.num_tiles = self.num_tiles + 1
if not self.arr[x + j][y] then
self.arr[x + j][y] = true
self.num_tiles = self.num_tiles + 1
end
end

if x == x1 and y == y1 + i then
Expand Down Expand Up @@ -641,8 +643,10 @@ function FreeForm:update(points, extra_points)
for x, y_row in pairs(line_class.arr) do
for y, _ in pairs(y_row) do
if not self.arr[x] then self.arr[x] = {} end
self.arr[x][y] = true
self.num_tiles = self.num_tiles + 1
if not self.arr[x][y] then
self.arr[x][y] = true
self.num_tiles = self.num_tiles + 1
end
end
end
end
Expand Down

0 comments on commit 02d90fe

Please sign in to comment.