Fix network cache bug

This commit is contained in:
Zenon Seth 2023-11-10 11:16:20 +00:00
parent 5ad4d8eaee
commit b940bcb761
2 changed files with 5 additions and 3 deletions

View File

@ -270,8 +270,10 @@ local function remove_from_network(pos, ops)
local hash = p2h(pos)
local network = logistica.get_network_or_nil(pos)
if not network then return end
ops.get_list(network)[hash] = nil
-- first clear the cache while the position is still counted as being "in-network"
ops.update_cache_node_removed(pos)
-- then remove the position from the network
ops.get_list(network)[hash] = nil
end
local MASS_STORAGE_OPS = {

View File

@ -107,13 +107,13 @@ function logistica.take_stack_from_mass_storage(stackToTake, network, collectorF
local stackToTakeName = stackToTake:get_name()
local remainingRequest = stackToTake:get_count()
local massLocations = network.storage_cache[stackToTake:get_name()]
if stackToTake:get_count() == 0 then return end
if massLocations == nil then return end
for storageHash, _ in pairs(massLocations) do
if stackToTake:get_count() == 0 then return end
local storagePos = minetest.get_position_from_hash(storageHash)
local meta = get_meta(storagePos)
local storageInv = meta:get_inventory()
local storageList = storageInv:get_list(MASS_STORAGE_LIST_NAME)
local storageList = storageInv:get_list(MASS_STORAGE_LIST_NAME) or {}
-- we can't use the usual take/put methods because mass storage exceeds max stack
for i = #storageList, 1, -1 do -- traverse backwards for taking items
local storageStack = storageList[i]