Merge pull request #1012 from bbassie/feature/inventory-sync-tools

Add inspect and modify tools for inventory sync
This commit is contained in:
Cooldude2606 authored and GitHub committed 2026-10-20 00:43:33 +01:00
commit 4128f75328
17 files changed
+1861 -65

No files matched your search

+13 -8
View File
@@ -70,7 +70,10 @@ end
--- Restore the stats of a character, the inventories are restored with place_items
function serialize.deserialize_character(character, serialized)
for _, key in pairs(character_stat_keys) do
character[key] = serialized[key]
-- Missing from imports and from data saved by another Factorio version
if serialized[key] ~= nil then
character[key] = serialized[key]
end
end
end
@@ -382,13 +385,13 @@ function serialize.deserialize_personal_logistic_slots(player, serialized)
logistic_point.remove_section(i)
end
-- If this is an array instead of a table, migrate to v2 format
-- Data from before 2.0 maps slot indices to requests, migrate it to a section
if next(serialized) == nil then
return
elseif serialized[1] ~= nil then
elseif serialized.sections == nil then
local section = logistic_point.add_section()
for i, slot in pairs(serialized) do
section.set_slot(i, {
section.set_slot(tonumber(i), {
value = {
name = slot.name,
quality = "normal",
@@ -936,6 +939,7 @@ end
--- @class SerializedPlayerData
--- @field generation number
--- @field epoch number?
--- @field name string
--- @field controller string?
--- @field color Color?
@@ -1360,10 +1364,11 @@ function serialize.deserialize_player(player, serialized, components, local_cont
end
end
if syncs(components, "appearance") and serialized.color then
player.color = serialized.color
player.chat_color = serialized.chat_color
player.tag = serialized.tag
if syncs(components, "appearance") then
-- Imports may supply any subset of these
if serialized.color then player.color = serialized.color end
if serialized.chat_color then player.chat_color = serialized.chat_color end
if serialized.tag then player.tag = serialized.tag end
end
if syncs(components, "force") and serialized.force then
player.force = serialized.force