fix(Core): fixed crash happening when clearing old mail (#3604)
This commit is contained in:
@@ -3696,7 +3696,6 @@ void Player::UpdateNextMailTimeAndUnreads()
|
|||||||
|
|
||||||
void Player::AddNewMailDeliverTime(time_t deliver_time)
|
void Player::AddNewMailDeliverTime(time_t deliver_time)
|
||||||
{
|
{
|
||||||
++totalMailCount;
|
|
||||||
sWorld->UpdateGlobalPlayerMails(GetGUIDLow(), totalMailCount, false);
|
sWorld->UpdateGlobalPlayerMails(GetGUIDLow(), totalMailCount, false);
|
||||||
if (deliver_time <= time(nullptr)) // ready now
|
if (deliver_time <= time(nullptr)) // ready now
|
||||||
{
|
{
|
||||||
@@ -19065,7 +19064,7 @@ void Player::_LoadMailInit(PreparedQueryResult resultMailCount, PreparedQueryRes
|
|||||||
//Set count for all mails used to display correct size later one
|
//Set count for all mails used to display correct size later one
|
||||||
if (resultMailCount)
|
if (resultMailCount)
|
||||||
{
|
{
|
||||||
totalMailCount = uint64((*resultMailCount)[0].GetUInt64());
|
totalMailCount = uint32((*resultMailCount)[0].GetUInt32());
|
||||||
sWorld->UpdateGlobalPlayerMails(GetGUIDLow(), totalMailCount, false);
|
sWorld->UpdateGlobalPlayerMails(GetGUIDLow(), totalMailCount, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19097,10 +19096,12 @@ void Player::_LoadMail()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//This should in theory always be < 100
|
//This should in theory always be < 100
|
||||||
for (PlayerMails::iterator itr = GetMailBegin(); itr != GetMailEnd(); ++itr)
|
for (PlayerMails::iterator itr = GetMailBegin(); itr != GetMailEnd();)
|
||||||
{
|
{
|
||||||
delete *itr;
|
Mail* m = *itr;
|
||||||
m_mailCache.erase(itr);
|
m_mailCache.erase(itr);
|
||||||
|
if(m)
|
||||||
|
delete m;
|
||||||
itr = GetMailBegin();
|
itr = GetMailBegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20093,6 +20094,8 @@ void Player::_SaveMail(SQLTransaction& trans)
|
|||||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM_BY_ID);
|
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM_BY_ID);
|
||||||
stmt->setUInt32(0, m->messageID);
|
stmt->setUInt32(0, m->messageID);
|
||||||
trans->Append(stmt);
|
trans->Append(stmt);
|
||||||
|
if (totalMailCount > 0)
|
||||||
|
totalMailCount--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1669,7 +1669,7 @@ public:
|
|||||||
|
|
||||||
void RemoveMail(uint32 id);
|
void RemoveMail(uint32 id);
|
||||||
|
|
||||||
void AddMail(Mail* mail) { m_mailCache.push_front(mail); }// for call from WorldSession::SendMailTo
|
void AddMail(Mail* mail) { totalMailCount++; m_mailCache.push_front(mail); }// for call from WorldSession::SendMailTo
|
||||||
uint32 GetMailSize() { return totalMailCount; }
|
uint32 GetMailSize() { return totalMailCount; }
|
||||||
uint32 GetMailCacheSize() { return m_mailCache.size();}
|
uint32 GetMailCacheSize() { return m_mailCache.size();}
|
||||||
Mail* GetMail(uint32 id);
|
Mail* GetMail(uint32 id);
|
||||||
@@ -1682,7 +1682,7 @@ public:
|
|||||||
/*********************************************************/
|
/*********************************************************/
|
||||||
|
|
||||||
uint8 unReadMails;
|
uint8 unReadMails;
|
||||||
uint64 totalMailCount;
|
uint32 totalMailCount;
|
||||||
time_t m_nextMailDelivereTime;
|
time_t m_nextMailDelivereTime;
|
||||||
|
|
||||||
typedef std::unordered_map<uint32, Item*> ItemMap;
|
typedef std::unordered_map<uint32, Item*> ItemMap;
|
||||||
|
|||||||
Reference in New Issue
Block a user