Fix battery box charging issues caused by out of sync functions

This code should be merged in the future to avoid such issues.
This commit is contained in:
SmallJoker 2022-11-26 23:25:27 +01:00
parent 521c0b74bb
commit 21e044478e
2 changed files with 4 additions and 3 deletions

View File

@ -67,7 +67,7 @@ local function clear_networks(pos)
local tier = network.tier local tier = network.tier
-- Actually add it to the (cached) network -- Actually add it to the (cached) network
-- This is similar to check_node_subp -- !! IMPORTANT: ../switching_station.lua -> check_node_subp() must be kept in sync
technic.cables[minetest.hash_node_position(pos)] = network_id technic.cables[minetest.hash_node_position(pos)] = network_id
pos.visited = 1 pos.visited = 1
if technic.is_tier_cable(node.name, tier) then if technic.is_tier_cable(node.name, tier) then
@ -76,7 +76,7 @@ local function clear_networks(pos)
elseif technic.machines[tier][node.name] then elseif technic.machines[tier][node.name] then
-- Found a machine -- Found a machine
local eu_type = technic.machines[tier][node.name] local eu_type = technic.machines[tier][node.name]
meta:set_string(tier.."_network", string.format("%X", network_id)) meta:set_string(tier.."_network", string.format("%.20g", network_id))
if eu_type == technic.producer then if eu_type == technic.producer then
table.insert(network.PR_nodes, pos) table.insert(network.PR_nodes, pos)
elseif eu_type == technic.receiver then elseif eu_type == technic.receiver then

View File

@ -117,6 +117,7 @@ local function add_cable_node(nodes, pos, network_id, queue)
end end
-- Generic function to add found connected nodes to the right classification array -- Generic function to add found connected nodes to the right classification array
-- !! IMPORTANT: register/cables.lua -> clear_networks() must be kept in sync
local check_node_subp = function(network, pos, machines, sw_pos, from_below, network_id, queue) local check_node_subp = function(network, pos, machines, sw_pos, from_below, network_id, queue)
technic.get_or_load_node(pos) technic.get_or_load_node(pos)
local name = minetest.get_node(pos).name local name = minetest.get_node(pos).name
@ -134,7 +135,7 @@ local check_node_subp = function(network, pos, machines, sw_pos, from_below, net
--dprint(name.." is a "..machines[name]) --dprint(name.." is a "..machines[name])
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
-- Normal tostring() does not have enough precision, neither does meta:set_int() -- Normal tostring() does not have enough precision, neither does meta:set_int()
-- Bug: Cannot use hexadecimal notation for compression (LuaJIT Windows bug, #911) -- Lua 5.1 bug: Cannot use hexadecimal notation for compression (see LuaJIT #911)
meta:set_string(network.tier.."_network", string.format("%.20g", network_id)) meta:set_string(network.tier.."_network", string.format("%.20g", network_id))
if eu_type == technic.producer then if eu_type == technic.producer then