Email bugfixes

- Fix item flag not getting updated
- Fix attachments getting written to the same slot
This commit is contained in:
Gent 2020-11-08 14:51:20 -05:00
parent 8f90fdaac4
commit d505b09e98

View File

@ -836,6 +836,11 @@ void Database::updateEmailContent(EmailData* data) {
db.begin_transaction(); db.begin_transaction();
auto attachments = db.get_all<Database::EmailItem>(
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<Database::EmailData>( db.remove_all<Database::EmailData>(
where(c(&Database::EmailData::PlayerId) == data->PlayerId && c(&Database::EmailData::MsgIndex) == data->MsgIndex) where(c(&Database::EmailData::PlayerId) == data->PlayerId && c(&Database::EmailData::MsgIndex) == data->MsgIndex)
); );
@ -901,7 +906,7 @@ void Database::sendEmail(EmailData* data, std::vector<sItemBase> attachments) {
EmailItem dbItem = { EmailItem dbItem = {
data->PlayerId, data->PlayerId,
data->MsgIndex, data->MsgIndex,
slot, slot++,
item.iType, item.iType,
item.iID, item.iID,
item.iOpt, item.iOpt,