From 77f01bc9d72078773cddae24c45f0f3d8cc7af86 Mon Sep 17 00:00:00 2001 From: SomeName42 <> Date: Sat, 16 Nov 2024 17:40:21 +0100 Subject: [PATCH] Fixed machines sometimes incorrectly being treated as cables. --- technic/machines/register/cables.lua | 3 +-- technic/machines/switching_station.lua | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/technic/machines/register/cables.lua b/technic/machines/register/cables.lua index dcb7f3c4..44980296 100644 --- a/technic/machines/register/cables.lua +++ b/technic/machines/register/cables.lua @@ -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 diff --git a/technic/machines/switching_station.lua b/technic/machines/switching_station.lua index 604ee2ce..adf9d3cf 100644 --- a/technic/machines/switching_station.lua +++ b/technic/machines/switching_station.lua @@ -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 @@ -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 @@ -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