Deleted data blob in item_instance

Fixed issues with displaying sockets/enchants/durability on heroic items

--HG--
branch : trunk
This commit is contained in:
Shauren
2010-07-30 13:15:31 +02:00
parent c227065fc0
commit 77fc91bde8
13 changed files with 243 additions and 111 deletions
+13 -31
View File
@@ -4434,15 +4434,15 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
if (has_items)
{
// Data needs to be at first place for Item::LoadFromDB
QueryResult_AutoPtr resultItems = CharacterDatabase.PQuery("SELECT data,text,item_guid,item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE mail_id='%u'", mail_id);
QueryResult_AutoPtr resultItems = CharacterDatabase.PQuery("SELECT creatorGuid,giftCreatorGuid,count,duration,charges,flags,enchantments,randomPropertyId,durability,playedTime,text,item_guid,item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE mail_id='%u'", mail_id);
if (resultItems)
{
do
{
Field *fields2 = resultItems->Fetch();
uint32 item_guidlow = fields2[2].GetUInt32();
uint32 item_template = fields2[3].GetUInt32();
uint32 item_guidlow = fields2[11].GetUInt32();
uint32 item_template = fields2[12].GetUInt32();
ItemPrototype const* itemProto = objmgr.GetItemPrototype(item_template);
if (!itemProto)
@@ -4452,7 +4452,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
}
Item *pItem = NewItemOrBag(itemProto);
if (!pItem->LoadFromDB(item_guidlow, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER),resultItems))
if (!pItem->LoadFromDB(item_guidlow, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER), resultItems, item_template))
{
pItem->FSetState(ITEM_REMOVED);
pItem->SaveToDB(); // it also deletes item object!
@@ -15864,24 +15864,6 @@ float Player::GetFloatValueFromArray(Tokens const& data, uint16 index)
return result;
}
void Player::_LoadIntoDataField(const char* data, uint32 startOffset, uint32 count)
{
if (!data)
return;
Tokens tokens = StrSplit(data, " ");
if (tokens.size() != count)
return;
Tokens::iterator iter;
uint32 index;
for (iter = tokens.begin(), index = 0; index < count; ++iter, ++index)
{
m_uint32Values[startOffset + index] = atol((*iter).c_str());
}
}
bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder)
{
//// 0 1 2 3 4 5 6 7 8 9 10 11
@@ -16733,10 +16715,10 @@ void Player::_LoadInventory(QueryResult_AutoPtr result, uint32 timediff)
do
{
Field *fields = result->Fetch();
uint32 bag_guid = fields[2].GetUInt32();
uint8 slot = fields[3].GetUInt8();
uint32 item_guid = fields[4].GetUInt32();
uint32 item_id = fields[5].GetUInt32();
uint32 bag_guid = fields[11].GetUInt32();
uint8 slot = fields[12].GetUInt8();
uint32 item_guid = fields[13].GetUInt32();
uint32 item_id = fields[14].GetUInt32();
ItemPrototype const * proto = objmgr.GetItemPrototype(item_id);
@@ -16750,7 +16732,7 @@ void Player::_LoadInventory(QueryResult_AutoPtr result, uint32 timediff)
Item *item = NewItemOrBag(proto);
if (!item->LoadFromDB(item_guid, GetGUID(), result))
if (!item->LoadFromDB(item_guid, GetGUID(), result, item_id))
{
sLog.outError("Player::_LoadInventory: Player %s has broken item (id: #%u) in inventory, deleted.", GetName(),item_id);
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item_guid);
@@ -16909,15 +16891,15 @@ void Player::_LoadInventory(QueryResult_AutoPtr result, uint32 timediff)
void Player::_LoadMailedItems(Mail *mail)
{
// data needs to be at first place for Item::LoadFromDB
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT data, text, item_guid, item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE mail_id='%u'", mail->messageID);
QueryResult_AutoPtr result = CharacterDatabase.PQuery("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text, item_guid, item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE mail_id='%u'", mail->messageID);
if (!result)
return;
do
{
Field *fields = result->Fetch();
uint32 item_guid_low = fields[2].GetUInt32();
uint32 item_template = fields[3].GetUInt32();
uint32 item_guid_low = fields[11].GetUInt32();
uint32 item_template = fields[12].GetUInt32();
mail->AddItem(item_guid_low, item_template);
@@ -16933,7 +16915,7 @@ void Player::_LoadMailedItems(Mail *mail)
Item *item = NewItemOrBag(proto);
if (!item->LoadFromDB(item_guid_low, 0, result))
if (!item->LoadFromDB(item_guid_low, 0, result, item_template))
{
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);