[9627] Make mail load async.

Signed-off-by: hunuza <hunuza@gmail.com>
This commit is contained in:
hunuza 2010-03-27 11:15:22 +01:00
parent 9311a36d2a
commit 841db412e9
4 changed files with 51 additions and 44 deletions

View file

@ -97,6 +97,8 @@ bool LoginQueryHolder::Initialize()
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADACCOUNTDATA, "SELECT type, time, data FROM character_account_data WHERE guid='%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSKILLS, "SELECT skill, value, max FROM character_skills WHERE guid = '%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGLYPHS, "SELECT spec, slot, glyph FROM character_glyphs WHERE guid='%u'", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILS, "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", GUID_LOPART(m_guid));
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILEDITEMS, "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));
return res;
}

View file

@ -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,13 +15689,14 @@ 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
{
Field *fields = result->Fetch();
@ -15717,13 +15724,9 @@ void Player::_LoadMail()
m->state = MAIL_STATE_UNCHANGED;
if (has_items)
_LoadMailedItems(m);
m_mail.push_back(m);
} while( result->NextRow() );
delete result;
}
}
void Player::LoadPet()

View file

@ -889,7 +889,9 @@ enum PlayerLoginQueryIndex
PLAYER_LOGIN_QUERY_LOADACCOUNTDATA = 20,
PLAYER_LOGIN_QUERY_LOADSKILLS = 21,
PLAYER_LOGIN_QUERY_LOADGLYPHS = 22,
MAX_PLAYER_LOGIN_QUERY = 23
PLAYER_LOGIN_QUERY_LOADMAILS = 23,
PLAYER_LOGIN_QUERY_LOADMAILEDITEMS = 24,
MAX_PLAYER_LOGIN_QUERY = 25
};
enum PlayerDelayedOperations
@ -2311,8 +2313,8 @@ class MANGOS_DLL_SPEC Player : public Unit
void _LoadAuras(QueryResult *result, uint32 timediff);
void _LoadBoundInstances(QueryResult *result);
void _LoadInventory(QueryResult *result, uint32 timediff);
void _LoadMail();
void _LoadMailedItems(Mail *mail);
void _LoadMails(QueryResult *result);
void _LoadMailedItems(QueryResult *result);
void _LoadQuestStatus(QueryResult *result);
void _LoadDailyQuestStatus(QueryResult *result);
void _LoadGroup(QueryResult *result);

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9626"
#define REVISION_NR "9627"
#endif // __REVISION_NR_H__