//floodfill: fix crash

This commit is contained in:
Starbeamrainbowlabs 2021-08-07 02:30:38 +01:00
parent e9398862b9
commit d1b0866af2
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 6 additions and 2 deletions

View file

@ -12,6 +12,7 @@ Note to self: See the bottom of this file for the release template text.
- `//layers`: Add optional slope constraint (inspired by [WorldPainter](https://worldpainter.net/))
- `//bonemeal`: Add optional node list constraint
- `//walls`: Add optional thickness argument
- `//floodfill`: Fix crash caused by internal refactoring of the `Queue` data structure
## v1.12: The selection tools update (26th June 2021)

View file

@ -28,12 +28,15 @@ function worldeditadditions.floodfill(start_pos, radius, replace_node)
local count = 0
local remaining_nodes = wea.Queue.new()
remaining_nodes:enqueue(start_pos_index)
print("DEBUG enqueue start_pos_index", start_pos_index)
print("DEBUG enqueued id", remaining_nodes:enqueue(start_pos_index))
-- Do the floodfill
while remaining_nodes:is_empty() == false do
local cur = remaining_nodes:dequeue()
print("DEBUG cur", cur)
-- Replace this node
data[cur] = replace_id
count = count + 1

View file

@ -61,7 +61,7 @@ function Queue:dequeue()
-- Find the next non-nil item
local value
while value == nil do
if first >= self.last then return nil end
if first > self.last then return nil end
value = self.items[first]
self.items[first] = nil -- Help the garbage collector out
first = first + 1