mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 15:33:00 +00:00
//floodfill: fix crash
This commit is contained in:
parent
e9398862b9
commit
d1b0866af2
3 changed files with 6 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue