mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-30 19:13:53 +01:00
//floodfill: fix crash
This commit is contained in:
parent
e9398862b9
commit
d1b0866af2
@ -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/))
|
- `//layers`: Add optional slope constraint (inspired by [WorldPainter](https://worldpainter.net/))
|
||||||
- `//bonemeal`: Add optional node list constraint
|
- `//bonemeal`: Add optional node list constraint
|
||||||
- `//walls`: Add optional thickness argument
|
- `//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)
|
## 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 count = 0
|
||||||
local remaining_nodes = wea.Queue.new()
|
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
|
-- Do the floodfill
|
||||||
while remaining_nodes:is_empty() == false do
|
while remaining_nodes:is_empty() == false do
|
||||||
local cur = remaining_nodes:dequeue()
|
local cur = remaining_nodes:dequeue()
|
||||||
|
|
||||||
|
print("DEBUG cur", cur)
|
||||||
|
|
||||||
-- Replace this node
|
-- Replace this node
|
||||||
data[cur] = replace_id
|
data[cur] = replace_id
|
||||||
count = count + 1
|
count = count + 1
|
||||||
|
@ -61,7 +61,7 @@ function Queue:dequeue()
|
|||||||
-- Find the next non-nil item
|
-- Find the next non-nil item
|
||||||
local value
|
local value
|
||||||
while value == nil do
|
while value == nil do
|
||||||
if first >= self.last then return nil end
|
if first > self.last then return nil end
|
||||||
value = self.items[first]
|
value = self.items[first]
|
||||||
self.items[first] = nil -- Help the garbage collector out
|
self.items[first] = nil -- Help the garbage collector out
|
||||||
first = first + 1
|
first = first + 1
|
||||||
|
Loading…
Reference in New Issue
Block a user