// 让 UI 显示最后一封邮件 VOID CMailPool::ShowLastMail() { // 就是把最后一封邮件的位置用事件通知 UI // m_MailPool.size() - 1 CEventSystem::GetMe()->PushEvent( GE_UPDATE_EMAIL, GetMailCount() - 1 ); CEventSystem::GetMe()->PushEvent( GE_HAVE_MAIL ); }
BOOL KMailBox::SendMail(KMail* pMail, size_t uMailLen) { BOOL bResult = false; BOOL bRetCode = false; KMail* pNewMail = NULL; int nMaxCount = 0; KMailCount MailCount; std::pair<KMailTable::iterator, bool> InsRet; assert(pMail); assert(pMail->byType < eMailType_Total); GetMailCount(&MailCount); // 留言邮件,数量达到上限时覆盖最早的邮件 if (pMail->byType == eMailType_GmMessage) { nMaxCount = g_pSO3GameCenter->m_Settings.m_nMaxGmMsgMailCount; EliminateMail(pMail->byType, MailCount.nGmMsgMail + 1 - nMaxCount); } else if (pMail->byType == eMailType_PlayerMessage) { nMaxCount = g_pSO3GameCenter->m_Settings.m_nMaxPlayerMsgMailCount; EliminateMail(pMail->byType, MailCount.nPlayerMsgMail + 1 - nMaxCount); } if (m_MailTable.size() >= KMAILBOX_MAX_MAIL_COUNT) { KRole* pRole = g_pSO3GameCenter->m_RoleManager.GetRole(m_dwID); KGLOG_PROCESS_ERROR(pRole); KGLogPrintf( KGLOG_INFO, "[Mail] Failed to send mail: %s-->%s, title:%s, money = %d", pMail->szSenderName, pRole->m_szName, pMail->szTitle, pMail->nMoney ); goto Exit0; } pNewMail = (KMail*)KMemory::Alloc(uMailLen); KGLOG_PROCESS_ERROR(pNewMail); memcpy(pNewMail, pMail, uMailLen); pNewMail->bRead = false; pNewMail->nLockTime = 0; pNewMail->dwMailID = m_dwNextMailID++; if (m_nBaseTime == 0) { m_nBaseTime = (pNewMail->nRecvTime / KMAIL_WITHDRAW_CYCLE + 1) * KMAIL_WITHDRAW_CYCLE; } InsRet = m_MailTable.insert(std::make_pair(pNewMail->dwMailID, pNewMail)); KGLOG_PROCESS_ERROR(InsRet.second); m_bSaved = false; bResult = true; Exit0: if (!bResult) { KMEMORY_FREE(pNewMail); } return bResult; }