mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[9627] Make mail load async.
Signed-off-by: hunuza <hunuza@gmail.com>
This commit is contained in:
parent
9311a36d2a
commit
841db412e9
4 changed files with 51 additions and 44 deletions
|
|
@ -15091,7 +15091,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
// apply original stats mods before spell loading or item equipment that call before equip _RemoveStatsMods()
|
||||
|
||||
// Mail
|
||||
_LoadMail();
|
||||
_LoadMails(holder->GetResult(PLAYER_LOGIN_QUERY_LOADMAILS));
|
||||
_LoadMailedItems(holder->GetResult(PLAYER_LOGIN_QUERY_LOADMAILEDITEMS));
|
||||
UpdateNextMailTimeAndUnreads();
|
||||
|
||||
m_specsCount = fields[59].GetUInt8();
|
||||
|
|
@ -15641,19 +15642,24 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff)
|
|||
}
|
||||
|
||||
// load mailed item which should receive current player
|
||||
void Player::_LoadMailedItems(Mail *mail)
|
||||
void Player::_LoadMailedItems(QueryResult *result)
|
||||
{
|
||||
// data needs to be at first place for Item::LoadFromDB
|
||||
QueryResult* result = CharacterDatabase.PQuery("SELECT data, item_guid, item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE mail_id='%u'", mail->messageID);
|
||||
// 0 1 2 3
|
||||
// "SELECT data, mail_id, item_guid, item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE receiver = '%u'", GUID_LOPART(m_guid)
|
||||
if(!result)
|
||||
return;
|
||||
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
uint32 item_guid_low = fields[1].GetUInt32();
|
||||
uint32 item_template = fields[2].GetUInt32();
|
||||
uint32 mail_id = fields[1].GetUInt32();
|
||||
uint32 item_guid_low = fields[2].GetUInt32();
|
||||
uint32 item_template = fields[3].GetUInt32();
|
||||
|
||||
Mail* mail = GetMail(mail_id);
|
||||
if(!mail)
|
||||
continue;
|
||||
mail->AddItem(item_guid_low, item_template);
|
||||
|
||||
ItemPrototype const *proto = ObjectMgr::GetItemPrototype(item_template);
|
||||
|
|
@ -15683,47 +15689,44 @@ void Player::_LoadMailedItems(Mail *mail)
|
|||
delete result;
|
||||
}
|
||||
|
||||
void Player::_LoadMail()
|
||||
void Player::_LoadMails(QueryResult *result)
|
||||
{
|
||||
m_mail.clear();
|
||||
//mails are in right order 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
||||
QueryResult *result = CharacterDatabase.PQuery("SELECT id,messageType,sender,receiver,subject,itemTextId,has_items,expire_time,deliver_time,money,cod,checked,stationery,mailTemplateId FROM mail WHERE receiver = '%u' ORDER BY id DESC",GetGUIDLow());
|
||||
if(result)
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
||||
//"SELECT id,messageType,sender,receiver,subject,itemTextId,has_items,expire_time,deliver_time,money,cod,checked,stationery,mailTemplateId FROM mail WHERE receiver = '%u' ORDER BY id DESC",GetGUIDLow()
|
||||
if(!result)
|
||||
return;
|
||||
|
||||
do
|
||||
{
|
||||
do
|
||||
Field *fields = result->Fetch();
|
||||
Mail *m = new Mail;
|
||||
m->messageID = fields[0].GetUInt32();
|
||||
m->messageType = fields[1].GetUInt8();
|
||||
m->sender = fields[2].GetUInt32();
|
||||
m->receiver = fields[3].GetUInt32();
|
||||
m->subject = fields[4].GetCppString();
|
||||
m->itemTextId = fields[5].GetUInt32();
|
||||
bool has_items = fields[6].GetBool();
|
||||
m->expire_time = (time_t)fields[7].GetUInt64();
|
||||
m->deliver_time = (time_t)fields[8].GetUInt64();
|
||||
m->money = fields[9].GetUInt32();
|
||||
m->COD = fields[10].GetUInt32();
|
||||
m->checked = fields[11].GetUInt32();
|
||||
m->stationery = fields[12].GetUInt8();
|
||||
m->mailTemplateId = fields[13].GetInt16();
|
||||
|
||||
if(m->mailTemplateId && !sMailTemplateStore.LookupEntry(m->mailTemplateId))
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
Mail *m = new Mail;
|
||||
m->messageID = fields[0].GetUInt32();
|
||||
m->messageType = fields[1].GetUInt8();
|
||||
m->sender = fields[2].GetUInt32();
|
||||
m->receiver = fields[3].GetUInt32();
|
||||
m->subject = fields[4].GetCppString();
|
||||
m->itemTextId = fields[5].GetUInt32();
|
||||
bool has_items = fields[6].GetBool();
|
||||
m->expire_time = (time_t)fields[7].GetUInt64();
|
||||
m->deliver_time = (time_t)fields[8].GetUInt64();
|
||||
m->money = fields[9].GetUInt32();
|
||||
m->COD = fields[10].GetUInt32();
|
||||
m->checked = fields[11].GetUInt32();
|
||||
m->stationery = fields[12].GetUInt8();
|
||||
m->mailTemplateId = fields[13].GetInt16();
|
||||
sLog.outError( "Player::_LoadMail - Mail (%u) have not existed MailTemplateId (%u), remove at load", m->messageID, m->mailTemplateId);
|
||||
m->mailTemplateId = 0;
|
||||
}
|
||||
|
||||
if(m->mailTemplateId && !sMailTemplateStore.LookupEntry(m->mailTemplateId))
|
||||
{
|
||||
sLog.outError( "Player::_LoadMail - Mail (%u) have not existed MailTemplateId (%u), remove at load", m->messageID, m->mailTemplateId);
|
||||
m->mailTemplateId = 0;
|
||||
}
|
||||
m->state = MAIL_STATE_UNCHANGED;
|
||||
|
||||
m->state = MAIL_STATE_UNCHANGED;
|
||||
|
||||
if (has_items)
|
||||
_LoadMailedItems(m);
|
||||
|
||||
m_mail.push_back(m);
|
||||
} while( result->NextRow() );
|
||||
delete result;
|
||||
}
|
||||
m_mail.push_back(m);
|
||||
} while( result->NextRow() );
|
||||
delete result;
|
||||
}
|
||||
|
||||
void Player::LoadPet()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue