Skip to content

Commit 77f01bc

Browse files
author
SomeName42
committed
Fixed machines sometimes incorrectly being treated as cables.
1 parent 7f83b62 commit 77f01bc

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

technic/machines/register/cables.lua

+1-2
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,9 @@ function technic.clear_networks(pos)
6868

6969
-- Actually add it to the (cached) network
7070
-- !! IMPORTANT: ../switching_station.lua -> check_node_subp() must be kept in sync
71-
technic.cables[minetest.hash_node_position(pos)] = network_id
7271
pos.visited = 1
7372
if technic.is_tier_cable(node.name, tier) then
74-
-- Found a cable
73+
technic.cables[minetest.hash_node_position(pos)] = network_id
7574
table.insert(network.all_nodes,pos)
7675
elseif technic.machines[tier][node.name] then
7776
-- Found a machine

technic/machines/switching_station.lua

+11-9
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ end
100100
-- Add a wire node to the LV/MV/HV network
101101
-- Returns: indicator whether the cable is new in the network
102102
local hash_node_position = minetest.hash_node_position
103-
local function add_network_node(nodes, pos, network_id)
103+
local function add_network_node(nodes, pos, network_id, cable)
104104
local node_id = hash_node_position(pos)
105-
technic.cables[node_id] = network_id
105+
if cable then
106+
technic.cables[node_id] = network_id
107+
end
106108
if nodes[node_id] then
107109
return false
108110
end
@@ -111,7 +113,7 @@ local function add_network_node(nodes, pos, network_id)
111113
end
112114

113115
local function add_cable_node(nodes, pos, network_id, queue)
114-
if add_network_node(nodes, pos, network_id) then
116+
if add_network_node(nodes, pos, network_id, true) then
115117
queue[#queue + 1] = pos
116118
end
117119
end
@@ -149,18 +151,18 @@ local check_node_subp = function(network, pos, machines, sw_pos, from_below, net
149151
end
150152

151153
if eu_type == technic.producer then
152-
add_network_node(network.PR_nodes, pos, network_id)
154+
add_network_node(network.PR_nodes, pos, network_id, false)
153155
elseif eu_type == technic.receiver then
154-
add_network_node(network.RE_nodes, pos, network_id)
156+
add_network_node(network.RE_nodes, pos, network_id, false)
155157
elseif eu_type == technic.producer_receiver then
156-
add_network_node(network.PR_nodes, pos, network_id)
157-
add_network_node(network.RE_nodes, pos, network_id)
158+
add_network_node(network.PR_nodes, pos, network_id, false)
159+
add_network_node(network.RE_nodes, pos, network_id, false)
158160
elseif eu_type == technic.battery then
159-
add_network_node(network.BA_nodes, pos, network_id)
161+
add_network_node(network.BA_nodes, pos, network_id, false)
160162
elseif eu_type == "SPECIAL" and from_below and
161163
not vector.equals(pos, sw_pos) then
162164
-- Another switching station -> disable it
163-
add_network_node(network.SP_nodes, pos, network_id)
165+
add_network_node(network.SP_nodes, pos, network_id, false)
164166
meta:set_int("active", 0)
165167
end
166168

0 commit comments

Comments
 (0)