Загрузить файлы в «/»

This commit is contained in:
Ade
2026-10-14 02:33:00 +00:00
parent 9309da65ca
commit 82b9bf2e03
3 changed files with 104 additions and 4 deletions
+34
View File
@@ -190,6 +190,37 @@ local function ReceiveEquip(text)
return true
end
-- bag sizes / used slots: B^name^realm^invBagsTs^bankBagsTs^inv^bank
local function EncodeBags(c)
return "B^" .. c.name .. "^" .. c.realm .. "^" .. (c.invBagsTs or 0) .. "^" .. (c.bankBagsTs or 0)
.. "^" .. (c.invBags or "") .. "^" .. (c.bankBags or "")
end
local function ReceiveBags(text)
local _, _, name, realm, its, bts, inv, bank =
string.find(text, "^B%^([^%^]*)%^([^%^]*)%^(%d*)%^(%d*)%^([^%^]*)%^(.*)$")
if not name or name == "" then return false end
local k = name .. "-" .. realm
local c = AA.db.chars[k]
if not c then
c = { name = name, realm = realm, cds = {}, remote = true }
AA.db.chars[k] = c
end
its, bts = tonumber(its) or 0, tonumber(bts) or 0
local ch = false
if its > (c.invBagsTs or 0) then
c.invBagsTs = its
c.invBags = inv
ch = true
end
if bts > (c.bankBagsTs or 0) then
c.bankBagsTs = bts
c.bankBags = bank
ch = true
end
return ch
end
local function FileRead(name)
if not (ImportFile and ExportFile) then return nil end
local ok, txt = pcall(ImportFile, name)
@@ -211,6 +242,8 @@ local function MergeText(txt)
if ReceiveProf(line) then n = n + 1 end
elseif t == "E^" then
if ReceiveEquip(line) then n = n + 1 end
elseif t == "B^" then
if ReceiveBags(line) then n = n + 1 end
elseif t == "I^" then
ReceiveItem(line)
end
@@ -245,6 +278,7 @@ local function FileWrite()
if c.prof then
for pname, p in pairs(c.prof) do table.insert(parts, EncodeProf(c, pname, p)) end
end
if c.invBags or c.bankBags then table.insert(parts, EncodeBags(c)) end
if c.equip then
table.insert(parts, EncodeEquip(c))
for slot, ref in pairs(c.equip) do