mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[6959] Merge some queries on item load.
Signed-off-by: hunuza <hunuza@gmail.com>
This commit is contained in:
parent
40e540d6f8
commit
70c7dda068
4 changed files with 24 additions and 20 deletions
|
|
@ -1195,18 +1195,19 @@ void Guild::LoadGuildBankFromDB()
|
||||||
|
|
||||||
delete result;
|
delete result;
|
||||||
|
|
||||||
// 0 1 2 3
|
// data needs to be at first place for Item::LoadFromDB
|
||||||
result = CharacterDatabase.PQuery("SELECT TabId, SlotId, item_guid, item_entry FROM guild_bank_item WHERE guildid='%u' ORDER BY TabId", Id);
|
// 0 1 2 3 4
|
||||||
|
result = CharacterDatabase.PQuery("SELECT data, TabId, SlotId, item_guid, item_entry FROM guild_bank_item JOIN item_instance ON item_guid = guid WHERE guildid='%u' ORDER BY TabId", Id);
|
||||||
if(!result)
|
if(!result)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Field *fields = result->Fetch();
|
Field *fields = result->Fetch();
|
||||||
uint8 TabId = fields[0].GetUInt8();
|
uint8 TabId = fields[1].GetUInt8();
|
||||||
uint8 SlotId = fields[1].GetUInt8();
|
uint8 SlotId = fields[2].GetUInt8();
|
||||||
uint32 ItemGuid = fields[2].GetUInt32();
|
uint32 ItemGuid = fields[3].GetUInt32();
|
||||||
uint32 ItemEntry = fields[3].GetUInt32();
|
uint32 ItemEntry = fields[4].GetUInt32();
|
||||||
|
|
||||||
if (TabId >= purchased_tabs || TabId >= GUILD_BANK_MAX_TABS)
|
if (TabId >= purchased_tabs || TabId >= GUILD_BANK_MAX_TABS)
|
||||||
{
|
{
|
||||||
|
|
@ -1229,7 +1230,7 @@ void Guild::LoadGuildBankFromDB()
|
||||||
}
|
}
|
||||||
|
|
||||||
Item *pItem = NewItemOrBag(proto);
|
Item *pItem = NewItemOrBag(proto);
|
||||||
if(!pItem->LoadFromDB(ItemGuid, 0))
|
if(!pItem->LoadFromDB(ItemGuid, 0, result))
|
||||||
{
|
{
|
||||||
CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE guildid='%u' AND TabId='%u' AND SlotId='%u'", Id, uint32(TabId), uint32(SlotId));
|
CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE guildid='%u' AND TabId='%u' AND SlotId='%u'", Id, uint32(TabId), uint32(SlotId));
|
||||||
sLog.outError("Item GUID %u not found in item_instance, deleting from Guild Bank!", ItemGuid);
|
sLog.outError("Item GUID %u not found in item_instance, deleting from Guild Bank!", ItemGuid);
|
||||||
|
|
|
||||||
|
|
@ -1892,7 +1892,8 @@ void ObjectMgr::LoadItemPrototypes()
|
||||||
|
|
||||||
void ObjectMgr::LoadAuctionItems()
|
void ObjectMgr::LoadAuctionItems()
|
||||||
{
|
{
|
||||||
QueryResult *result = CharacterDatabase.Query( "SELECT itemguid,item_template FROM auctionhouse" );
|
// data needs to be at first place for Item::LoadFromDB
|
||||||
|
QueryResult *result = CharacterDatabase.Query( "SELECT data,itemguid,item_template FROM auctionhouse JOIN item_instance ON itemguid = guid" );
|
||||||
|
|
||||||
if( !result )
|
if( !result )
|
||||||
return;
|
return;
|
||||||
|
|
@ -1907,8 +1908,8 @@ void ObjectMgr::LoadAuctionItems()
|
||||||
bar.step();
|
bar.step();
|
||||||
|
|
||||||
fields = result->Fetch();
|
fields = result->Fetch();
|
||||||
uint32 item_guid = fields[0].GetUInt32();
|
uint32 item_guid = fields[1].GetUInt32();
|
||||||
uint32 item_template = fields[1].GetUInt32();
|
uint32 item_template = fields[2].GetUInt32();
|
||||||
|
|
||||||
ItemPrototype const *proto = GetItemPrototype(item_template);
|
ItemPrototype const *proto = GetItemPrototype(item_template);
|
||||||
|
|
||||||
|
|
@ -1920,7 +1921,7 @@ void ObjectMgr::LoadAuctionItems()
|
||||||
|
|
||||||
Item *item = NewItemOrBag(proto);
|
Item *item = NewItemOrBag(proto);
|
||||||
|
|
||||||
if(!item->LoadFromDB(item_guid,0))
|
if(!item->LoadFromDB(item_guid,0, result))
|
||||||
{
|
{
|
||||||
delete item;
|
delete item;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -3562,15 +3562,16 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
|
||||||
MailItemsInfo mi;
|
MailItemsInfo mi;
|
||||||
if(has_items)
|
if(has_items)
|
||||||
{
|
{
|
||||||
QueryResult *resultItems = CharacterDatabase.PQuery("SELECT item_guid,item_template FROM mail_items WHERE mail_id='%u'", mail_id);
|
// data needs to be at first place for Item::LoadFromDB
|
||||||
|
QueryResult *resultItems = CharacterDatabase.PQuery("SELECT data,item_guid,item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE mail_id='%u'", mail_id);
|
||||||
if(resultItems)
|
if(resultItems)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Field *fields2 = resultItems->Fetch();
|
Field *fields2 = resultItems->Fetch();
|
||||||
|
|
||||||
uint32 item_guidlow = fields2[0].GetUInt32();
|
uint32 item_guidlow = fields2[1].GetUInt32();
|
||||||
uint32 item_template = fields2[1].GetUInt32();
|
uint32 item_template = fields2[2].GetUInt32();
|
||||||
|
|
||||||
ItemPrototype const* itemProto = objmgr.GetItemPrototype(item_template);
|
ItemPrototype const* itemProto = objmgr.GetItemPrototype(item_template);
|
||||||
if(!itemProto)
|
if(!itemProto)
|
||||||
|
|
@ -3580,7 +3581,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
|
||||||
}
|
}
|
||||||
|
|
||||||
Item *pItem = NewItemOrBag(itemProto);
|
Item *pItem = NewItemOrBag(itemProto);
|
||||||
if(!pItem->LoadFromDB(item_guidlow, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)))
|
if(!pItem->LoadFromDB(item_guidlow, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER),resultItems))
|
||||||
{
|
{
|
||||||
pItem->FSetState(ITEM_REMOVED);
|
pItem->FSetState(ITEM_REMOVED);
|
||||||
pItem->SaveToDB(); // it also deletes item object !
|
pItem->SaveToDB(); // it also deletes item object !
|
||||||
|
|
@ -14584,15 +14585,16 @@ void Player::_LoadInventory(QueryResult *result, uint32 timediff)
|
||||||
// load mailed item which should receive current player
|
// load mailed item which should receive current player
|
||||||
void Player::_LoadMailedItems(Mail *mail)
|
void Player::_LoadMailedItems(Mail *mail)
|
||||||
{
|
{
|
||||||
QueryResult* result = CharacterDatabase.PQuery("SELECT item_guid, item_template FROM mail_items WHERE mail_id='%u'", mail->messageID);
|
// 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);
|
||||||
if(!result)
|
if(!result)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Field *fields = result->Fetch();
|
Field *fields = result->Fetch();
|
||||||
uint32 item_guid_low = fields[0].GetUInt32();
|
uint32 item_guid_low = fields[1].GetUInt32();
|
||||||
uint32 item_template = fields[1].GetUInt32();
|
uint32 item_template = fields[2].GetUInt32();
|
||||||
|
|
||||||
mail->AddItem(item_guid_low, item_template);
|
mail->AddItem(item_guid_low, item_template);
|
||||||
|
|
||||||
|
|
@ -14608,7 +14610,7 @@ void Player::_LoadMailedItems(Mail *mail)
|
||||||
|
|
||||||
Item *item = NewItemOrBag(proto);
|
Item *item = NewItemOrBag(proto);
|
||||||
|
|
||||||
if(!item->LoadFromDB(item_guid_low, 0))
|
if(!item->LoadFromDB(item_guid_low, 0, result))
|
||||||
{
|
{
|
||||||
sLog.outError( "Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, item_guid_low);
|
sLog.outError( "Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, item_guid_low);
|
||||||
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low);
|
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "6958"
|
#define REVISION_NR "6959"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue