[6959] Merge some queries on item load.

Signed-off-by: hunuza <hunuza@gmail.com>
This commit is contained in:
hunuza 2008-12-27 23:53:31 +01:00
parent 40e540d6f8
commit 70c7dda068
4 changed files with 24 additions and 20 deletions

View file

@ -1195,18 +1195,19 @@ void Guild::LoadGuildBankFromDB()
delete result;
// 0 1 2 3
result = CharacterDatabase.PQuery("SELECT TabId, SlotId, item_guid, item_entry FROM guild_bank_item WHERE guildid='%u' ORDER BY TabId", Id);
// data needs to be at first place for Item::LoadFromDB
// 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)
return;
do
{
Field *fields = result->Fetch();
uint8 TabId = fields[0].GetUInt8();
uint8 SlotId = fields[1].GetUInt8();
uint32 ItemGuid = fields[2].GetUInt32();
uint32 ItemEntry = fields[3].GetUInt32();
uint8 TabId = fields[1].GetUInt8();
uint8 SlotId = fields[2].GetUInt8();
uint32 ItemGuid = fields[3].GetUInt32();
uint32 ItemEntry = fields[4].GetUInt32();
if (TabId >= purchased_tabs || TabId >= GUILD_BANK_MAX_TABS)
{
@ -1229,7 +1230,7 @@ void Guild::LoadGuildBankFromDB()
}
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));
sLog.outError("Item GUID %u not found in item_instance, deleting from Guild Bank!", ItemGuid);