From 87bdbd520f4049310d300b2ed261c072a4d59c64 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Fri, 13 Nov 2026 22:49:12 +0100 Subject: [PATCH] Sync every quick bar slot when the pages are wider than 10 From Factorio 2.1 a quick bar page is as wide as the player set it, up to 100 slots. Only the first 100 slots were synced, so with wider pages the later pages kept the content of the destination, and restoring the page shown on a row could show those. --- plugins/player_sync/module/serialize.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/player_sync/module/serialize.lua b/plugins/player_sync/module/serialize.lua index df6dec79..88d22b23 100644 --- a/plugins/player_sync/module/serialize.lua +++ b/plugins/player_sync/module/serialize.lua @@ -662,13 +662,20 @@ function serialize.deserialize_quick_bar_slot(entry, player) return entry --[[@as string]] end +--- Slots over all 10 quick bar pages, a page is as wide as the player set it from 2.1 and 10 slots before +--- @param player LuaPlayer +--- @return integer +local function quick_bar_slot_count(player) + return 10 * (v2_1_quick_bar_api and player.quick_bar_width or 10) +end + --- @param player LuaPlayer --- @return table? function serialize.serialize_quick_bar(player) local serialized local width = v2_1_quick_bar_api and player.quick_bar_width - for i = 1, 100 do + for i = 1, quick_bar_slot_count(player) do local slot if v2_1_quick_bar_api then @@ -699,7 +706,7 @@ function serialize.deserialize_quick_bar(player, serialized) -- previous server does not come back from this server's old copy serialized = serialized or {} local width = v2_1_quick_bar_api and player.quick_bar_width - for i = 1, 100 do + for i = 1, quick_bar_slot_count(player) do local entry = serialized[tostring(i)] local slot = entry ~= nil and serialize.deserialize_quick_bar_slot(entry, player) or nil if v2_1_quick_bar_api then