mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-25 08:23:13 +09:00
Use item name only for better size usage
This commit is contained in:
1 file changed
+9
-17
@@ -197,7 +197,7 @@ function serialize.deserialize_personal_logistic_slots(player, serialized)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- name is a custom type where quality is "normal" and comparator is "=" (most common case)
|
-- 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.filter { t: "f", n: string, q: string, c: string }
|
||||||
--- @alias QuickBarSlotEncoded QuickBarSlotEncoded.name | QuickBarSlotEncoded.filter
|
--- @alias QuickBarSlotEncoded QuickBarSlotEncoded.name | QuickBarSlotEncoded.filter
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ end
|
|||||||
--- @return QuickBarSlotEncoded
|
--- @return QuickBarSlotEncoded
|
||||||
local function serialize_filter(filter)
|
local function serialize_filter(filter)
|
||||||
if filter.quality == "normal" and filter.comparator == "=" then
|
if filter.quality == "normal" and filter.comparator == "=" then
|
||||||
return { t = "n", n = filter.name }
|
return filter.name
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -238,27 +238,19 @@ function serialize.serialize_quick_bar_slot(slot)
|
|||||||
|
|
||||||
-- pre 2.0 quality did not exist
|
-- pre 2.0 quality did not exist
|
||||||
--- @cast slot LuaItemPrototype
|
--- @cast slot LuaItemPrototype
|
||||||
return {
|
return slot.name
|
||||||
t = "n",
|
|
||||||
n = slot.name
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param entry string | QuickBarSlotEncoded
|
--- @param entry string | QuickBarSlotEncoded
|
||||||
--- @return QuickBarSlot | ItemWithQualityID | nil
|
--- @return QuickBarSlot | ItemWithQualityID | nil
|
||||||
function serialize.deserialize_quick_bar_slot(entry)
|
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
|
if v2_1_quick_bar_api then
|
||||||
-- Return a quick bar slot
|
-- Return a quick bar slot
|
||||||
if entry.t == "n" then
|
if type(entry) == "string" then
|
||||||
return {
|
return {
|
||||||
type = "filter",
|
type = "filter",
|
||||||
filter = {
|
filter = {
|
||||||
name = entry.n,
|
name = entry,
|
||||||
quality = "normal",
|
quality = "normal",
|
||||||
comparator = "=",
|
comparator = "=",
|
||||||
},
|
},
|
||||||
@@ -282,9 +274,9 @@ function serialize.deserialize_quick_bar_slot(entry)
|
|||||||
|
|
||||||
if v2_0_quick_bar_api then
|
if v2_0_quick_bar_api then
|
||||||
-- Return a ItemIDAndQualityIDPair (member of ItemWithQualityID)
|
-- Return a ItemIDAndQualityIDPair (member of ItemWithQualityID)
|
||||||
if entry.t == "n" then
|
if type(entry) == "string" then
|
||||||
return {
|
return {
|
||||||
name = entry.n,
|
name = entry,
|
||||||
quality = "normal",
|
quality = "normal",
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@@ -297,8 +289,8 @@ function serialize.deserialize_quick_bar_slot(entry)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Return a string (member of ItemPrototypeIdentification)
|
-- Return a string (member of ItemPrototypeIdentification)
|
||||||
-- entry.t == "n" is the only case for pre 2.0
|
-- Pre 2.0 this was the only method of encoding used
|
||||||
return entry.n
|
return entry
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param player LuaPlayer
|
--- @param player LuaPlayer
|
||||||
|
|||||||
Reference in new issue
Block a user