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)
|
||||
for _, k in ipairs(mail.storage:get_keys()) do
|
||||
if string.sub(k,1,5) ~= "mail/" then
|
||||
goto continue
|
||||
end
|
||||
if string.sub(k,1,5) == "mail/" then
|
||||
local p = string.sub(k, 6)
|
||||
local result
|
||||
local boxes = {"inbox", "outbox", "drafts", "trash"}
|
||||
|
@ -101,7 +99,7 @@ local function is_uuid_existing(uuid)
|
|||
result = search_box(p, b, uuid)
|
||||
if result then return result end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
@ -121,17 +119,10 @@ local function repair_box(playername, box)
|
|||
for _, m in ipairs(e[box]) do
|
||||
local uuid = m.id
|
||||
local exists = is_uuid_existing(uuid)
|
||||
if not exists then
|
||||
goto continue
|
||||
elseif are_message_sames(exists, m) then
|
||||
-- same message, continue
|
||||
goto continue
|
||||
else
|
||||
if exists and not are_message_sames(exists, m) then
|
||||
local new_uuid = mail.new_uuid() -- generates a new uuid to replace doublons
|
||||
for _, k in ipairs(mail.storage:get_keys()) do
|
||||
if string.sub(k,1,5) ~= "mail/" then
|
||||
goto continue_r
|
||||
end
|
||||
if string.sub(k,1,5) == "mail/" then
|
||||
local p = string.sub(k, 6)
|
||||
local er = mail.get_storage_entry(p)
|
||||
for _, r in ipairs(er.inbox) do
|
||||
|
@ -155,10 +146,9 @@ local function repair_box(playername, box)
|
|||
end
|
||||
end
|
||||
mail.set_storage_entry(p, er)
|
||||
::continue_r::
|
||||
end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -166,15 +156,13 @@ end
|
|||
local function repair_storage()
|
||||
-- iterate through players
|
||||
for _, k in ipairs(mail.storage:get_keys()) do
|
||||
if string.sub(k,1,5) ~= "mail/" then
|
||||
goto continue
|
||||
end
|
||||
if string.sub(k,1,5) == "mail/" then
|
||||
local p = string.sub(k, 6)
|
||||
repair_box(p, "inbox")
|
||||
repair_box(p, "outbox")
|
||||
repair_box(p, "drafts")
|
||||
repair_box(p, "trash")
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,9 +3,7 @@ local random = math.random
|
|||
|
||||
local function is_uuid_unexisting(uuid)
|
||||
for _, k in ipairs(mail.storage:get_keys()) do
|
||||
if string.sub(k,1,5) ~= "mail/" then
|
||||
goto continue
|
||||
end
|
||||
if string.sub(k,1,5) == "mail/" then
|
||||
local p = string.sub(k, 6)
|
||||
local e = mail.get_storage_entry(p)
|
||||
for _, m in ipairs(e.inbox) do
|
||||
|
@ -20,7 +18,7 @@ local function is_uuid_unexisting(uuid)
|
|||
for _, m in ipairs(e.trash) do
|
||||
if m.id == uuid then return false end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue