Fixed remaining bank/bag issues added in r9090
Added temporary hack to item creation to prevent new items from bugging (heroic+sockets issue), this will be removed after my work on item flags is done --HG-- branch : trunk
This commit is contained in:
@@ -87,7 +87,7 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner)
|
|||||||
|
|
||||||
SetUInt32Value(ITEM_FIELD_MAXDURABILITY, itemProto->MaxDurability);
|
SetUInt32Value(ITEM_FIELD_MAXDURABILITY, itemProto->MaxDurability);
|
||||||
SetUInt32Value(ITEM_FIELD_DURABILITY, itemProto->MaxDurability);
|
SetUInt32Value(ITEM_FIELD_DURABILITY, itemProto->MaxDurability);
|
||||||
SetUInt32Value(ITEM_FIELD_FLAGS, itemProto->Flags);
|
SetUInt32Value(ITEM_FIELD_FLAGS, itemProto->Flags & 0xFFFFFFF7); // TEMP HACK, DONT REMOVE - Shauren
|
||||||
SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1);
|
SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1);
|
||||||
|
|
||||||
// Setting the number of Slots the Container has
|
// Setting the number of Slots the Container has
|
||||||
@@ -113,6 +113,8 @@ bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult_AutoPtr result,
|
|||||||
if (!Item::LoadFromDB(guid, owner_guid, result, entry))
|
if (!Item::LoadFromDB(guid, owner_guid, result, entry))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
ItemPrototype const* itemProto = GetProto(); // checked in Item::LoadFromDB
|
||||||
|
SetUInt32Value(CONTAINER_FIELD_NUM_SLOTS, itemProto->ContainerSlots);
|
||||||
// cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
|
// cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
|
||||||
for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
|
for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
|
|||||||
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||||
SetSpellCharges(i,itemProto->Spells[i].SpellCharges);
|
SetSpellCharges(i,itemProto->Spells[i].SpellCharges);
|
||||||
|
|
||||||
SetUInt32Value(ITEM_FIELD_FLAGS, itemProto->Flags);
|
SetUInt32Value(ITEM_FIELD_FLAGS, itemProto->Flags & 0xFFFFFFF7); // TEMP HACK, DONT REMOVE - Shauren
|
||||||
SetUInt32Value(ITEM_FIELD_DURATION, abs(itemProto->Duration));
|
SetUInt32Value(ITEM_FIELD_DURATION, abs(itemProto->Duration));
|
||||||
|
|
||||||
SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, 0);
|
SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, 0);
|
||||||
@@ -388,24 +388,28 @@ void Item::SaveToDB()
|
|||||||
|
|
||||||
bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult_AutoPtr result, uint32 entry)
|
bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult_AutoPtr result, uint32 entry)
|
||||||
{
|
{
|
||||||
|
// 0 1 2 3 4 5 6 7 8 9 10
|
||||||
|
//result = CharacterDatabase.PQuery("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text FROM item_instance WHERE guid = '%u'", guid);
|
||||||
|
|
||||||
// create item before any checks for store correct guid
|
// create item before any checks for store correct guid
|
||||||
// and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
|
// and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
|
||||||
Object::_Create(guid, 0, HIGHGUID_ITEM);
|
Object::_Create(guid, 0, HIGHGUID_ITEM);
|
||||||
|
|
||||||
SetEntry(entry);
|
|
||||||
ItemPrototype const* proto = GetProto();
|
ItemPrototype const* proto = GetProto();
|
||||||
if (!proto)
|
if (!proto)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//if (!result) // 0 1 2 3 4 5 6 7 8 9 10
|
|
||||||
// result = CharacterDatabase.PQuery("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text FROM item_instance WHERE guid = '%u'", guid);
|
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
sLog.outError("Item (GUID: %u owner: %u) not found in table `item_instance`, can't load. ", guid, GUID_LOPART(owner_guid));
|
sLog.outError("Item (GUID: %u owner: %u) not found in table `item_instance`, can't load. ", guid, GUID_LOPART(owner_guid));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetEntry(entry);
|
||||||
|
SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f);
|
||||||
|
// set owner (not if item is only loaded for gbank/auction/mail
|
||||||
|
if (owner_guid != 0)
|
||||||
|
SetOwnerGUID(owner_guid);
|
||||||
|
|
||||||
Field *fields = result->Fetch();
|
Field *fields = result->Fetch();
|
||||||
bool need_save = false; // need explicit save data at load fixes
|
bool need_save = false; // need explicit save data at load fixes
|
||||||
SetUInt64Value(ITEM_FIELD_CREATOR, MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER));
|
SetUInt64Value(ITEM_FIELD_CREATOR, MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER));
|
||||||
@@ -453,20 +457,12 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult_AutoPtr result
|
|||||||
SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, fields[9].GetUInt32());
|
SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, fields[9].GetUInt32());
|
||||||
SetText(fields[10].GetCppString());
|
SetText(fields[10].GetCppString());
|
||||||
|
|
||||||
// set correct owner
|
|
||||||
if (owner_guid != 0 && GetOwnerGUID() != owner_guid)
|
|
||||||
{
|
|
||||||
SetOwnerGUID(owner_guid);
|
|
||||||
need_save = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (need_save) // normal item changed state set not work at loading
|
if (need_save) // normal item changed state set not work at loading
|
||||||
{
|
{
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
ss << "UPDATE item_instance SET duration = " << GetUInt32Value(ITEM_FIELD_DURABILITY)
|
ss << "UPDATE item_instance SET duration = " << GetUInt32Value(ITEM_FIELD_DURABILITY)
|
||||||
<< ", flags = " << GetUInt32Value(ITEM_FIELD_FLAGS)
|
<< ", flags = " << GetUInt32Value(ITEM_FIELD_FLAGS)
|
||||||
<< ", durability = " << GetUInt32Value(ITEM_FIELD_DURABILITY)
|
<< ", durability = " << GetUInt32Value(ITEM_FIELD_DURABILITY)
|
||||||
<< ", owner_guid = " << GUID_LOPART(GetOwnerGUID())
|
|
||||||
<< " WHERE guid = " << guid;
|
<< " WHERE guid = " << guid;
|
||||||
|
|
||||||
CharacterDatabase.Execute(ss.str().c_str());
|
CharacterDatabase.Execute(ss.str().c_str());
|
||||||
|
|||||||
Reference in New Issue
Block a user