Jump to content

[10862][fix] Lost items when returning expired mail


Guest Quriq14

Recommended Posts

* What bug does the patch fix? What features does the patch add?

Item owner is not switched when returning an expired mail with items, so the new receiver can't see them.

Removed also redundant check.

* For which repository revision was the patch created?

10859

* Is there a thread in the bug report section or at lighthouse? If yes, please add a link to the thread.

Not found any.

diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 0281510..0fac2ba 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -5509,7 +5509,7 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
                delete resultItems;
            }
            //if it is mail from AH, it shouldn't be returned, but deleted
-            if (m->messageType != MAIL_NORMAL || m->messageType == MAIL_AUCTION || (m->checked & (MAIL_CHECK_MASK_COD_PAYMENT | MAIL_CHECK_MASK_RETURNED)))
+            if (m->messageType != MAIL_NORMAL || (m->checked & (MAIL_CHECK_MASK_COD_PAYMENT | MAIL_CHECK_MASK_RETURNED)))
            {
                // mail open and then not returned
                for(std::vector<MailItemInfo>::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2)
@@ -5520,6 +5520,11 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
                //mail will be returned:
                CharacterDatabase.PExecute("UPDATE mail SET sender = '%u', receiver = '%u', expire_time = '" UI64FMTD "', deliver_time = '" UI64FMTD "',cod
                    m->receiverGuid.GetCounter(), m->sender, (uint64)(basetime + 30*DAY), (uint64)basetime, MAIL_CHECK_MASK_RETURNED, m->messageID);
+                for (std::vector<MailItemInfo>::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2)
+                {
+                    CharacterDatabase.PExecute("UPDATE mail_items SET receiver = %u WHERE item_guid = '%u'", m->sender, itr2->item_guid);
+                    CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = %u WHERE guid = '%u'", m->sender, itr2->item_guid);
+                }
                delete m;
                continue;
            }

Link to comment
Share on other sites

Actually if you let mail sit 30 days with items or if it's COD and past 3 days the mail returns to players seemingly empty because the mail_items table never changes the receiver back to the original sender. I've had to manually fix this in the database many time until I added this fix:

                //mail will be returned:
               CharacterDatabase.PExecute("UPDATE mail SET sender = '%u', receiver = '%u', expire_time = '" UI64FMTD "', deliver_time = '" UI64FMTD "',cod = '0', checked = '%u' WHERE id = '%u'", m->receiver, m->sender, (uint64)(basetime + 30*DAY), (uint64)basetime, MAIL_CHECK_MASK_RETURNED, m->messageID);
+                CharacterDatabase.PExecute("UPDATE mail_items SET receiver = '%u' where mail_id = '%u'", m->sender, m->messageID);
               delete m;
               continue;
           }

Link to comment
Share on other sites

Ok, I will recheck and look code just for sure.

And second version look like more correct.

As i remember "item_instance owner update at receive (including at receive back ofc).

But mail_items part need.

[added]Ok, first patch more correct:

1) problem confirmed.

2) item_instance update need because if character set return mail wil be deleted then item will lost in other case.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use