From 2559c0478c113fabf779523ae927d56e4f6deb85 Mon Sep 17 00:00:00 2001 From: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com> Date: Fri, 10 Jul 2026 20:59:06 +0100 Subject: [PATCH] Use item name only for better size usage --- plugins/inventory_sync/module/serialize.lua | 26 +++++++-------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/plugins/inventory_sync/module/serialize.lua b/plugins/inventory_sync/module/serialize.lua index 2aa7f9a2..93e11343 100644 --- a/plugins/inventory_sync/module/serialize.lua +++ b/plugins/inventory_sync/module/serialize.lua @@ -197,7 +197,7 @@ function serialize.deserialize_personal_logistic_slots(player, serialized) end -- name is a custom type where quality is "normal" and comparator is "=" (most common case) ---- @alias QuickBarSlotEncoded.name { t: "n", n: string } +--- @alias QuickBarSlotEncoded.name string --- @alias QuickBarSlotEncoded.filter { t: "f", n: string, q: string, c: string } --- @alias QuickBarSlotEncoded QuickBarSlotEncoded.name | QuickBarSlotEncoded.filter @@ -205,7 +205,7 @@ end --- @return QuickBarSlotEncoded local function serialize_filter(filter) if filter.quality == "normal" and filter.comparator == "=" then - return { t = "n", n = filter.name } + return filter.name end return { @@ -238,27 +238,19 @@ function serialize.serialize_quick_bar_slot(slot) -- pre 2.0 quality did not exist --- @cast slot LuaItemPrototype - return { - t = "n", - n = slot.name - } + return slot.name end --- @param entry string | QuickBarSlotEncoded --- @return QuickBarSlot | ItemWithQualityID | nil function serialize.deserialize_quick_bar_slot(entry) - if type(entry) == "string" then - -- Migration, old data was just the name, so convert to QuickBarSlotEncoded.name - entry = { t = "n", n = entry } - end - if v2_1_quick_bar_api then -- Return a quick bar slot - if entry.t == "n" then + if type(entry) == "string" then return { type = "filter", filter = { - name = entry.n, + name = entry, quality = "normal", comparator = "=", }, @@ -282,9 +274,9 @@ function serialize.deserialize_quick_bar_slot(entry) if v2_0_quick_bar_api then -- Return a ItemIDAndQualityIDPair (member of ItemWithQualityID) - if entry.t == "n" then + if type(entry) == "string" then return { - name = entry.n, + name = entry, quality = "normal", } end @@ -297,8 +289,8 @@ function serialize.deserialize_quick_bar_slot(entry) end -- Return a string (member of ItemPrototypeIdentification) - -- entry.t == "n" is the only case for pre 2.0 - return entry.n + -- Pre 2.0 this was the only method of encoding used + return entry end --- @param player LuaPlayer