Skip to content

Commit

Permalink
Fixed machines sometimes incorrectly being treated as cables.
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeName42 committed Nov 16, 2024
1 parent 7f83b62 commit 77f01bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
3 changes: 1 addition & 2 deletions technic/machines/register/cables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ function technic.clear_networks(pos)

-- Actually add it to the (cached) network
-- !! IMPORTANT: ../switching_station.lua -> check_node_subp() must be kept in sync
technic.cables[minetest.hash_node_position(pos)] = network_id
pos.visited = 1
if technic.is_tier_cable(node.name, tier) then
-- Found a cable
technic.cables[minetest.hash_node_position(pos)] = network_id
table.insert(network.all_nodes,pos)
elseif technic.machines[tier][node.name] then
-- Found a machine
Expand Down
20 changes: 11 additions & 9 deletions technic/machines/switching_station.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ end
-- Add a wire node to the LV/MV/HV network
-- Returns: indicator whether the cable is new in the network
local hash_node_position = minetest.hash_node_position
local function add_network_node(nodes, pos, network_id)
local function add_network_node(nodes, pos, network_id, cable)
local node_id = hash_node_position(pos)
technic.cables[node_id] = network_id
if cable then
technic.cables[node_id] = network_id
end
if nodes[node_id] then
return false
end
Expand All @@ -111,7 +113,7 @@ local function add_network_node(nodes, pos, network_id)
end

local function add_cable_node(nodes, pos, network_id, queue)
if add_network_node(nodes, pos, network_id) then
if add_network_node(nodes, pos, network_id, true) then
queue[#queue + 1] = pos
end
end
Expand Down Expand Up @@ -149,18 +151,18 @@ local check_node_subp = function(network, pos, machines, sw_pos, from_below, net
end

if eu_type == technic.producer then
add_network_node(network.PR_nodes, pos, network_id)
add_network_node(network.PR_nodes, pos, network_id, false)
elseif eu_type == technic.receiver then
add_network_node(network.RE_nodes, pos, network_id)
add_network_node(network.RE_nodes, pos, network_id, false)
elseif eu_type == technic.producer_receiver then
add_network_node(network.PR_nodes, pos, network_id)
add_network_node(network.RE_nodes, pos, network_id)
add_network_node(network.PR_nodes, pos, network_id, false)
add_network_node(network.RE_nodes, pos, network_id, false)
elseif eu_type == technic.battery then
add_network_node(network.BA_nodes, pos, network_id)
add_network_node(network.BA_nodes, pos, network_id, false)
elseif eu_type == "SPECIAL" and from_below and
not vector.equals(pos, sw_pos) then
-- Another switching station -> disable it
add_network_node(network.SP_nodes, pos, network_id)
add_network_node(network.SP_nodes, pos, network_id, false)
meta:set_int("active", 0)
end

Expand Down

0 comments on commit 77f01bc

Please sign in to comment.