From d505b09e9831cc6da76a78c2bd52f5e3a478c12d Mon Sep 17 00:00:00 2001 From: Gent Date: Sun, 8 Nov 2020 14:51:20 -0500 Subject: [PATCH] Email bugfixes - Fix item flag not getting updated - Fix attachments getting written to the same slot --- src/Database.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Database.cpp b/src/Database.cpp index 73ff2e4..b0d8c28 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -836,6 +836,11 @@ void Database::updateEmailContent(EmailData* data) { db.begin_transaction(); + auto attachments = db.get_all( + where(c(&Database::EmailItem::PlayerId) == data->PlayerId && c(&Database::EmailItem::MsgIndex) == data->MsgIndex) + ); + data->ItemFlag = (data->Taros > 0 || attachments.size() > 0) ? 1 : 0; // set attachment flag dynamically + db.remove_all( where(c(&Database::EmailData::PlayerId) == data->PlayerId && c(&Database::EmailData::MsgIndex) == data->MsgIndex) ); @@ -901,7 +906,7 @@ void Database::sendEmail(EmailData* data, std::vector attachments) { EmailItem dbItem = { data->PlayerId, data->MsgIndex, - slot, + slot++, item.iType, item.iID, item.iOpt,