mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2025-01-04 07:37:31 +01:00
Make sure reverse mapping in netlist_map always includes entries all wires and sinks when there are no sources (fixes netlists not depowering when no power sources present)
This commit is contained in:
parent
e1571db17e
commit
b81cf544f8
@ -103,18 +103,6 @@ local function compute_netlist_map(netlist, netlist_id, edges)
|
|||||||
--core.log(dump{netlist})
|
--core.log(dump{netlist})
|
||||||
local distance_map = {}
|
local distance_map = {}
|
||||||
|
|
||||||
-- Create the pos-to-type map
|
|
||||||
local pos_type = {}
|
|
||||||
for _,pos in pairs(netlist.sources) do
|
|
||||||
pos_type[core.hash_node_position(pos)] = "source"
|
|
||||||
end
|
|
||||||
for _,pos in pairs(netlist.sinks) do
|
|
||||||
pos_type[core.hash_node_position(pos)] = "sink"
|
|
||||||
end
|
|
||||||
for _,pos in pairs(netlist.wires) do
|
|
||||||
pos_type[core.hash_node_position(pos)] = "wire"
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Create the source->(wire/sink) distance maps and the forward maps (source->sink and source->wire)
|
-- Create the source->(wire/sink) distance maps and the forward maps (source->sink and source->wire)
|
||||||
local forward = {
|
local forward = {
|
||||||
source = {},
|
source = {},
|
||||||
@ -128,6 +116,26 @@ local function compute_netlist_map(netlist, netlist_id, edges)
|
|||||||
sink = {},
|
sink = {},
|
||||||
air = {}
|
air = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Create the pos-to-type map
|
||||||
|
local pos_type = {}
|
||||||
|
for _,pos in pairs(netlist.sources) do
|
||||||
|
local pos_hash = core.hash_node_position(pos)
|
||||||
|
pos_type[pos_hash] = "source"
|
||||||
|
forward.source[pos_hash] = {}
|
||||||
|
end
|
||||||
|
for _,pos in pairs(netlist.sinks) do
|
||||||
|
local pos_hash = core.hash_node_position(pos)
|
||||||
|
pos_type[pos_hash] = "sink"
|
||||||
|
reverse.sink[pos_hash] = {}
|
||||||
|
end
|
||||||
|
for _,pos in pairs(netlist.wires) do
|
||||||
|
local pos_hash = core.hash_node_position(pos)
|
||||||
|
pos_type[pos_hash] = "wire"
|
||||||
|
reverse.wire[pos_hash] = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Walk edges from sources and build distance map
|
||||||
for _,source_pos in pairs(netlist.sources) do
|
for _,source_pos in pairs(netlist.sources) do
|
||||||
local source_hash = core.hash_node_position(source_pos)
|
local source_hash = core.hash_node_position(source_pos)
|
||||||
local map = {}
|
local map = {}
|
||||||
@ -155,7 +163,6 @@ local function compute_netlist_map(netlist, netlist_id, edges)
|
|||||||
|
|
||||||
-- Reverse map
|
-- Reverse map
|
||||||
local rev_map = reverse[p_type][p_hash] or {}
|
local rev_map = reverse[p_type][p_hash] or {}
|
||||||
reverse[p_type][p_hash] = rev_map
|
|
||||||
rev_map[source_hash] = dist
|
rev_map[source_hash] = dist
|
||||||
|
|
||||||
-- Add adjacent nodes to processing queue
|
-- Add adjacent nodes to processing queue
|
||||||
|
Loading…
Reference in New Issue
Block a user