![]() |
AzerothCore 3.3.5a
OpenSource WoW Emulator
|
Owns the mail lifecycle bookkeeping that lives outside a single player session: the per-character mail count mirrored in CharacterCache and the cleanup of expired mail. More...
#include "MailMgr.h"
Public Member Functions | |
| void | OnMailSent (ObjectGuid::LowType receiverLow) |
| Reports a mail row inserted for a character. | |
| void | OnMailDeleted (ObjectGuid::LowType receiverLow) |
| Reports a mail row deleted from a character's mailbox. | |
| void | OnMailReturned (ObjectGuid::LowType oldReceiverLow, ObjectGuid::LowType newReceiverLow) |
| Reports a mail row handed to a new receiver (return to sender). | |
| void | LoadMailCounts () |
| Recounts the mail of all characters from the database. Called once at startup after the character cache is filled. | |
| void | RecountMailCount (ObjectGuid::LowType receiverLow) |
| Recounts one character's mail from the database, overwriting the cached value. | |
| void | DeleteEmptyExpiredMail (uint32 mailId, ObjectGuid::LowType receiverLow) |
| Deletes an expired mail row that has no items, money or COD attached. Used at login for mail that would otherwise stay invisible in the DB until ReturnOrDeleteOldMails catches the receiver offline. | |
| void | ReturnOrDeleteOldMails (bool serverUp) |
| Returns expired mail with items to the sender and deletes the rest. | |
Static Public Member Functions | |
| static MailMgr * | instance () |
Owns the mail lifecycle bookkeeping that lives outside a single player session: the per-character mail count mirrored in CharacterCache and the cleanup of expired mail.
Every code path that inserts or deletes a row in the characters mail table must report it here, otherwise the cached count drifts until the next recount.
| void MailMgr::DeleteEmptyExpiredMail | ( | uint32 | mailId, |
| ObjectGuid::LowType | receiverLow | ||
| ) |
Deletes an expired mail row that has no items, money or COD attached. Used at login for mail that would otherwise stay invisible in the DB until ReturnOrDeleteOldMails catches the receiver offline.
| mailId | Id of the mail row to delete |
| receiverLow | Low GUID of the mail receiver |
References CHAR_DEL_MAIL_BY_ID, CharacterDatabase, OnMailDeleted(), and PreparedStatementBase::SetData().
|
static |
References instance().
Referenced by instance().
| void MailMgr::LoadMailCounts | ( | ) |
Recounts the mail of all characters from the database. Called once at startup after the character cache is filled.
References CharacterDatabase, Player, and sCharacterCache.
| void MailMgr::OnMailDeleted | ( | ObjectGuid::LowType | receiverLow | ) |
Reports a mail row deleted from a character's mailbox.
| receiverLow | Low GUID of the mail receiver |
References Player, and sCharacterCache.
Referenced by DeleteEmptyExpiredMail(), and ReturnOrDeleteOldMails().
| void MailMgr::OnMailReturned | ( | ObjectGuid::LowType | oldReceiverLow, |
| ObjectGuid::LowType | newReceiverLow | ||
| ) |
Reports a mail row handed to a new receiver (return to sender).
| oldReceiverLow | Low GUID of the previous receiver |
| newReceiverLow | Low GUID of the new receiver |
References Player, and sCharacterCache.
Referenced by ReturnOrDeleteOldMails().
| void MailMgr::OnMailSent | ( | ObjectGuid::LowType | receiverLow | ) |
Reports a mail row inserted for a character.
| receiverLow | Low GUID of the mail receiver |
References Player, and sCharacterCache.
| void MailMgr::RecountMailCount | ( | ObjectGuid::LowType | receiverLow | ) |
Recounts one character's mail from the database, overwriting the cached value.
| receiverLow | Low GUID of the character to recount |
References CharacterDatabase, Player, and sCharacterCache.
| void MailMgr::ReturnOrDeleteOldMails | ( | bool | serverUp | ) |
Returns expired mail with items to the sender and deletes the rest.
| serverUp | When true, receivers that are currently online are skipped. |
References CHAR_DEL_ITEM_INSTANCE, CHAR_DEL_MAIL_BY_ID, CHAR_DEL_MAIL_ITEM_BY_ID, CHAR_SEL_EXPIRED_MAIL, CHAR_SEL_EXPIRED_MAIL_ITEMS, CHAR_UPD_ITEM_OWNER, CHAR_UPD_MAIL_ITEM_RECEIVER, CHAR_UPD_MAIL_RETURNED, CharacterDatabase, Mail::checked, DAY, Mail::deliver_time, Mail::expire_time, ObjectAccessor::FindPlayerByLowGUID(), Field::Get(), GameTime::GetGameTime(), getMSTime(), GetMSTimeDiffToNow(), Mail::IsCODPayment(), Mail::IsReturnedMail(), Mail::IsSentByGM(), Mail::IsSentByPlayer(), MailItemInfo::item_guid, MailItemInfo::item_template, Mail::items, LOG_INFO, MAIL_CHECK_MASK_RETURNED, Mail::mailTemplateId, Mail::messageID, Mail::messageType, OnMailDeleted(), OnMailReturned(), Mail::receiver, Mail::sender, PreparedStatementBase::SetData(), and Mail::stationery.