Remove goto statements

Due to uncompatibility with LuaJIT
This commit is contained in:
Athozus 2024-03-31 22:19:01 +02:00
parent c076c62841
commit 865632933a
No known key found for this signature in database
GPG key ID: B50895022E8484BF
2 changed files with 50 additions and 64 deletions

View file

@ -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

View file

@ -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