mirror of
https://github.com/mt-mods/mail.git
synced 2025-04-30 08:21:44 -04:00
Remove goto statements
Due to uncompatibility with LuaJIT
This commit is contained in:
parent
c076c62841
commit
865632933a
2 changed files with 50 additions and 64 deletions
26
migrate.lua
26
migrate.lua
|
@ -91,9 +91,7 @@ end
|
||||||
|
|
||||||
local function is_uuid_existing(uuid)
|
local function is_uuid_existing(uuid)
|
||||||
for _, k in ipairs(mail.storage:get_keys()) do
|
for _, k in ipairs(mail.storage:get_keys()) do
|
||||||
if string.sub(k,1,5) ~= "mail/" then
|
if string.sub(k,1,5) == "mail/" then
|
||||||
goto continue
|
|
||||||
end
|
|
||||||
local p = string.sub(k, 6)
|
local p = string.sub(k, 6)
|
||||||
local result
|
local result
|
||||||
local boxes = {"inbox", "outbox", "drafts", "trash"}
|
local boxes = {"inbox", "outbox", "drafts", "trash"}
|
||||||
|
@ -101,7 +99,7 @@ local function is_uuid_existing(uuid)
|
||||||
result = search_box(p, b, uuid)
|
result = search_box(p, b, uuid)
|
||||||
if result then return result end
|
if result then return result end
|
||||||
end
|
end
|
||||||
::continue::
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -121,17 +119,10 @@ local function repair_box(playername, box)
|
||||||
for _, m in ipairs(e[box]) do
|
for _, m in ipairs(e[box]) do
|
||||||
local uuid = m.id
|
local uuid = m.id
|
||||||
local exists = is_uuid_existing(uuid)
|
local exists = is_uuid_existing(uuid)
|
||||||
if not exists then
|
if exists and not are_message_sames(exists, m) then
|
||||||
goto continue
|
|
||||||
elseif are_message_sames(exists, m) then
|
|
||||||
-- same message, continue
|
|
||||||
goto continue
|
|
||||||
else
|
|
||||||
local new_uuid = mail.new_uuid() -- generates a new uuid to replace doublons
|
local new_uuid = mail.new_uuid() -- generates a new uuid to replace doublons
|
||||||
for _, k in ipairs(mail.storage:get_keys()) do
|
for _, k in ipairs(mail.storage:get_keys()) do
|
||||||
if string.sub(k,1,5) ~= "mail/" then
|
if string.sub(k,1,5) == "mail/" then
|
||||||
goto continue_r
|
|
||||||
end
|
|
||||||
local p = string.sub(k, 6)
|
local p = string.sub(k, 6)
|
||||||
local er = mail.get_storage_entry(p)
|
local er = mail.get_storage_entry(p)
|
||||||
for _, r in ipairs(er.inbox) do
|
for _, r in ipairs(er.inbox) do
|
||||||
|
@ -155,10 +146,9 @@ local function repair_box(playername, box)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
mail.set_storage_entry(p, er)
|
mail.set_storage_entry(p, er)
|
||||||
::continue_r::
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
::continue::
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -166,15 +156,13 @@ end
|
||||||
local function repair_storage()
|
local function repair_storage()
|
||||||
-- iterate through players
|
-- iterate through players
|
||||||
for _, k in ipairs(mail.storage:get_keys()) do
|
for _, k in ipairs(mail.storage:get_keys()) do
|
||||||
if string.sub(k,1,5) ~= "mail/" then
|
if string.sub(k,1,5) == "mail/" then
|
||||||
goto continue
|
|
||||||
end
|
|
||||||
local p = string.sub(k, 6)
|
local p = string.sub(k, 6)
|
||||||
repair_box(p, "inbox")
|
repair_box(p, "inbox")
|
||||||
repair_box(p, "outbox")
|
repair_box(p, "outbox")
|
||||||
repair_box(p, "drafts")
|
repair_box(p, "drafts")
|
||||||
repair_box(p, "trash")
|
repair_box(p, "trash")
|
||||||
::continue::
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,7 @@ local random = math.random
|
||||||
|
|
||||||
local function is_uuid_unexisting(uuid)
|
local function is_uuid_unexisting(uuid)
|
||||||
for _, k in ipairs(mail.storage:get_keys()) do
|
for _, k in ipairs(mail.storage:get_keys()) do
|
||||||
if string.sub(k,1,5) ~= "mail/" then
|
if string.sub(k,1,5) == "mail/" then
|
||||||
goto continue
|
|
||||||
end
|
|
||||||
local p = string.sub(k, 6)
|
local p = string.sub(k, 6)
|
||||||
local e = mail.get_storage_entry(p)
|
local e = mail.get_storage_entry(p)
|
||||||
for _, m in ipairs(e.inbox) do
|
for _, m in ipairs(e.inbox) do
|
||||||
|
@ -20,7 +18,7 @@ local function is_uuid_unexisting(uuid)
|
||||||
for _, m in ipairs(e.trash) do
|
for _, m in ipairs(e.trash) do
|
||||||
if m.id == uuid then return false end
|
if m.id == uuid then return false end
|
||||||
end
|
end
|
||||||
::continue::
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue