From de07f6b24b4570fa049253ed781e6b377ae5b292 Mon Sep 17 00:00:00 2001 From: Buckaroo Banzai <39065740+BuckarooBanzay@users.noreply.github.com> Date: Tue, 6 Jun 2023 07:02:57 +0200 Subject: [PATCH] fix `mail.delete_mail` (again) --- storage.lua | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/storage.lua b/storage.lua index a3b14b5..922bb40 100644 --- a/storage.lua +++ b/storage.lua @@ -114,30 +114,27 @@ function mail.delete_mail(playername, msg_ids) if type(msg_ids) ~= "table" then -- if this is not a table msg_ids = { msg_ids } end - if #entry.inbox > 0 then - for i = #entry.inbox, 1, -1 do - for _, deleted_msg in ipairs(msg_ids) do - if entry.inbox[i].id == deleted_msg then - table.remove(entry.inbox, i) - end + for i = #entry.inbox, 1, -1 do + for _, deleted_msg in ipairs(msg_ids) do + if entry.inbox[i].id == deleted_msg then + table.remove(entry.inbox, i) + break end end end - if #entry.outbox > 0 then - for i = #entry.outbox, 1, -1 do - for _, deleted_msg in ipairs(msg_ids) do - if entry.outbox[i].id == deleted_msg then - table.remove(entry.outbox, i) - end + for i = #entry.outbox, 1, -1 do + for _, deleted_msg in ipairs(msg_ids) do + if entry.outbox[i].id == deleted_msg then + table.remove(entry.outbox, i) + break end end end - if #entry.drafts > 0 then - for i = #entry.drafts, 1, -1 do - for _, deleted_msg in ipairs(msg_ids) do - if entry.drafts[i].id == deleted_msg then - table.remove(entry.drafts, i) - end + for i = #entry.drafts, 1, -1 do + for _, deleted_msg in ipairs(msg_ids) do + if entry.drafts[i].id == deleted_msg then + table.remove(entry.drafts, i) + break end end end