mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 08:23:12 +09:00
Fix deserializing to a smaller inventory
Void excess slots when deserializing an inventory to a target that has fewer slots than what was serialized. This fixs inventory sync failing when a stored inventory has trash slots in use but the player does not have the slots unlocked.
This commit is contained in:
1 parent
2a221456d9
commit
54897c1447
1 file changed
+4
-1
@@ -281,8 +281,11 @@ function serialize.deserialize_inventory(inventory, serialized)
|
|||||||
|
|
||||||
local repeat_count = entry.r or 0
|
local repeat_count = entry.r or 0
|
||||||
for offset = 0, repeat_count do
|
for offset = 0, repeat_count do
|
||||||
-- XXX what if the inventory is smaller on this instance?
|
|
||||||
local index = base_index + offset
|
local index = base_index + offset
|
||||||
|
if index > #inventory then
|
||||||
|
print("Error: Inventory index out of bounds deserializing inventory, voiding excess slots")
|
||||||
|
break
|
||||||
|
end
|
||||||
local slot = inventory[index]
|
local slot = inventory[index]
|
||||||
if entry.f then
|
if entry.f then
|
||||||
local call_success, call_return = pcall(inventory.set_filter, index, entry.f)
|
local call_success, call_return = pcall(inventory.set_filter, index, entry.f)
|
||||||
|
|||||||
Reference in new issue
Block a user