Core/Mail: Load mails at login instead of on demand when queried by packets (logging in always sends one of the packets that cause mail loading anyway)

Port From (https://github.com/TrinityCore/TrinityCore/commit/a9b4f9aca0d0b90e59e0ed26e9bb4cce7d0ceeab)
This commit is contained in:
hondacrx
2022-03-02 09:52:35 -05:00
parent 6e6ee2d694
commit 150b09205b
9 changed files with 95 additions and 126 deletions
+5 -11
View File
@@ -9440,11 +9440,15 @@ namespace Game
uint returnedCount = 0;
do
{
ulong receiver = result.Read<ulong>(3);
if (serverUp && Global.ObjAccessor.FindConnectedPlayer(ObjectGuid.Create(HighGuid.Player, receiver)))
continue;
Mail m = new();
m.messageID = result.Read<uint>(0);
m.messageType = (MailMessageType)result.Read<byte>(1);
m.sender = result.Read<uint>(2);
m.receiver = result.Read<ulong>(3);
m.receiver = receiver;
bool has_items = result.Read<bool>(4);
m.expire_time = result.Read<long>(5);
m.deliver_time = 0;
@@ -9452,16 +9456,6 @@ namespace Game
m.checkMask = (MailCheckMask)result.Read<byte>(7);
m.mailTemplateId = result.Read<ushort>(8);
Player player = null;
if (serverUp)
player = Global.ObjAccessor.FindPlayer(ObjectGuid.Create(HighGuid.Player, m.receiver));
if (player && player.m_mailsLoaded)
{ // this code will run very improbably (the time is between 4 and 5 am, in game is online a player, who has old mail
// his in mailbox and he has already listed his mails)
continue;
}
// Delete or return mail
if (has_items)
{