mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-27 23:56:25 +00:00
feat(Core/Misc): implement ObjectGuid class (port from TC) (#4885)
This commit is contained in:
@@ -56,20 +56,20 @@ void Bag::RemoveFromWorld()
|
||||
Item::RemoveFromWorld();
|
||||
}
|
||||
|
||||
bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner)
|
||||
bool Bag::Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner)
|
||||
{
|
||||
ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(itemid);
|
||||
|
||||
if (!itemProto || itemProto->ContainerSlots > MAX_BAG_SIZE)
|
||||
return false;
|
||||
|
||||
Object::_Create(guidlow, 0, HIGHGUID_CONTAINER);
|
||||
Object::_Create(guidlow, 0, HighGuid::Item);
|
||||
|
||||
SetEntry(itemid);
|
||||
SetObjectScale(1.0f);
|
||||
|
||||
SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0);
|
||||
SetUInt64Value(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : 0);
|
||||
SetGuidValue(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : ObjectGuid::Empty);
|
||||
SetGuidValue(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : ObjectGuid::Empty);
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_MAXDURABILITY, itemProto->MaxDurability);
|
||||
SetUInt32Value(ITEM_FIELD_DURABILITY, itemProto->MaxDurability);
|
||||
@@ -81,7 +81,7 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner)
|
||||
// Cleaning 20 slots
|
||||
for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
|
||||
{
|
||||
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i * 2), 0);
|
||||
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i * 2), ObjectGuid::Empty);
|
||||
m_bagslot[i] = nullptr;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ void Bag::SaveToDB(SQLTransaction& trans)
|
||||
Item::SaveToDB(trans);
|
||||
}
|
||||
|
||||
bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry)
|
||||
bool Bag::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry)
|
||||
{
|
||||
if (!Item::LoadFromDB(guid, owner_guid, fields, entry))
|
||||
return false;
|
||||
@@ -103,7 +103,7 @@ bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry
|
||||
// cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
|
||||
for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
|
||||
{
|
||||
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i * 2), 0);
|
||||
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i * 2), ObjectGuid::Empty);
|
||||
delete m_bagslot[i];
|
||||
m_bagslot[i] = nullptr;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ void Bag::RemoveItem(uint8 slot, bool /*update*/)
|
||||
m_bagslot[slot]->SetContainer(nullptr);
|
||||
|
||||
m_bagslot[slot] = nullptr;
|
||||
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (slot * 2), 0);
|
||||
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), ObjectGuid::Empty);
|
||||
}
|
||||
|
||||
void Bag::StoreItem(uint8 slot, Item* pItem, bool /*update*/)
|
||||
@@ -148,9 +148,9 @@ void Bag::StoreItem(uint8 slot, Item* pItem, bool /*update*/)
|
||||
if (pItem && pItem->GetGUID() != this->GetGUID())
|
||||
{
|
||||
m_bagslot[slot] = pItem;
|
||||
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (slot * 2), pItem->GetGUID());
|
||||
pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, GetGUID());
|
||||
pItem->SetUInt64Value(ITEM_FIELD_OWNER, GetOwnerGUID());
|
||||
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), pItem->GetGUID());
|
||||
pItem->SetGuidValue(ITEM_FIELD_CONTAINED, GetGUID());
|
||||
pItem->SetGuidValue(ITEM_FIELD_OWNER, GetOwnerGUID());
|
||||
pItem->SetContainer(this);
|
||||
pItem->SetSlot(slot);
|
||||
}
|
||||
@@ -212,7 +212,7 @@ uint32 Bag::GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem)
|
||||
return count;
|
||||
}
|
||||
|
||||
uint8 Bag::GetSlotByItemGUID(uint64 guid) const
|
||||
uint8 Bag::GetSlotByItemGUID(ObjectGuid guid) const
|
||||
{
|
||||
for (uint32 i = 0; i < GetBagSize(); ++i)
|
||||
if (m_bagslot[i] != 0)
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
void AddToWorld() override;
|
||||
void RemoveFromWorld() override;
|
||||
|
||||
bool Create(uint32 guidlow, uint32 itemid, Player const* owner) override;
|
||||
bool Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner) override;
|
||||
|
||||
void Clear();
|
||||
void StoreItem(uint8 slot, Item* pItem, bool update);
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
uint32 GetItemCount(uint32 item, Item* eItem = nullptr) const;
|
||||
uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = nullptr) const;
|
||||
|
||||
[[nodiscard]] uint8 GetSlotByItemGUID(uint64 guid) const;
|
||||
[[nodiscard]] uint8 GetSlotByItemGUID(ObjectGuid guid) const;
|
||||
[[nodiscard]] bool IsEmpty() const;
|
||||
[[nodiscard]] uint32 GetFreeSlots() const;
|
||||
[[nodiscard]] uint32 GetBagSize() const { return GetUInt32Value(CONTAINER_FIELD_NUM_SLOTS); }
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
// overwrite virtual Item::SaveToDB
|
||||
void SaveToDB(SQLTransaction& trans) override;
|
||||
// overwrite virtual Item::LoadFromDB
|
||||
bool LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry) override;
|
||||
bool LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry) override;
|
||||
// overwrite virtual Item::DeleteFromDB
|
||||
void DeleteFromDB(SQLTransaction& trans) override;
|
||||
|
||||
|
||||
@@ -247,15 +247,15 @@ Item::Item()
|
||||
m_paidExtendedCost = 0;
|
||||
}
|
||||
|
||||
bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
|
||||
bool Item::Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner)
|
||||
{
|
||||
Object::_Create(guidlow, 0, HIGHGUID_ITEM);
|
||||
Object::_Create(guidlow, 0, HighGuid::Item);
|
||||
|
||||
SetEntry(itemid);
|
||||
SetObjectScale(1.0f);
|
||||
|
||||
SetUInt64Value(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : 0);
|
||||
SetUInt64Value(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : 0);
|
||||
SetGuidValue(ITEM_FIELD_OWNER, owner ? owner->GetGUID() : ObjectGuid::Empty);
|
||||
SetGuidValue(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : ObjectGuid::Empty);
|
||||
|
||||
ItemTemplate const* itemProto = sObjectMgr->GetItemTemplate(itemid);
|
||||
if (!itemProto)
|
||||
@@ -309,7 +309,7 @@ void Item::SaveToDB(SQLTransaction& trans)
|
||||
if (!isInTransaction)
|
||||
trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
uint32 guid = GetGUIDLow();
|
||||
ObjectGuid::LowType guid = GetGUID().GetCounter();
|
||||
switch (uState)
|
||||
{
|
||||
case ITEM_NEW:
|
||||
@@ -318,9 +318,9 @@ void Item::SaveToDB(SQLTransaction& trans)
|
||||
uint8 index = 0;
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(uState == ITEM_NEW ? CHAR_REP_ITEM_INSTANCE : CHAR_UPD_ITEM_INSTANCE);
|
||||
stmt->setUInt32( index, GetEntry());
|
||||
stmt->setUInt32(++index, GUID_LOPART(GetOwnerGUID()));
|
||||
stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_CREATOR)));
|
||||
stmt->setUInt32(++index, GUID_LOPART(GetUInt64Value(ITEM_FIELD_GIFTCREATOR)));
|
||||
stmt->setUInt32(++index, GetOwnerGUID().GetCounter());
|
||||
stmt->setUInt32(++index, GetGuidValue(ITEM_FIELD_CREATOR).GetCounter());
|
||||
stmt->setUInt32(++index, GetGuidValue(ITEM_FIELD_GIFTCREATOR).GetCounter());
|
||||
stmt->setUInt32(++index, GetCount());
|
||||
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_DURATION));
|
||||
|
||||
@@ -351,7 +351,7 @@ void Item::SaveToDB(SQLTransaction& trans)
|
||||
if ((uState == ITEM_CHANGED) && HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GIFT_OWNER);
|
||||
stmt->setUInt32(0, GUID_LOPART(GetOwnerGUID()));
|
||||
stmt->setUInt32(0, GetOwnerGUID().GetCounter());
|
||||
stmt->setUInt32(1, guid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
@@ -386,14 +386,14 @@ void Item::SaveToDB(SQLTransaction& trans)
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
|
||||
bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry)
|
||||
bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, 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
|
||||
// and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
|
||||
Object::_Create(guid, 0, HIGHGUID_ITEM);
|
||||
Object::_Create(guid, 0, HighGuid::Item);
|
||||
|
||||
// Set entry, MUST be before proto check
|
||||
SetEntry(entry);
|
||||
@@ -404,12 +404,12 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entr
|
||||
return false;
|
||||
|
||||
// set owner (not if item is only loaded for gbank/auction/mail
|
||||
if (owner_guid != 0)
|
||||
if (owner_guid)
|
||||
SetOwnerGUID(owner_guid);
|
||||
|
||||
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_GIFTCREATOR, MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_PLAYER));
|
||||
SetGuidValue(ITEM_FIELD_CREATOR, ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32()));
|
||||
SetGuidValue(ITEM_FIELD_GIFTCREATOR, ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt32()));
|
||||
SetCount(fields[2].GetUInt32());
|
||||
|
||||
uint32 duration = fields[3].GetUInt32();
|
||||
@@ -470,7 +470,7 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entr
|
||||
}
|
||||
|
||||
/*static*/
|
||||
void Item::DeleteFromDB(SQLTransaction& trans, uint32 itemGuid)
|
||||
void Item::DeleteFromDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid)
|
||||
{
|
||||
sScriptMgr->OnGlobalItemDelFromDB(trans, itemGuid);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
|
||||
@@ -480,11 +480,11 @@ void Item::DeleteFromDB(SQLTransaction& trans, uint32 itemGuid)
|
||||
|
||||
void Item::DeleteFromDB(SQLTransaction& trans)
|
||||
{
|
||||
DeleteFromDB(trans, GetGUIDLow());
|
||||
DeleteFromDB(trans, GetGUID().GetCounter());
|
||||
}
|
||||
|
||||
/*static*/
|
||||
void Item::DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid)
|
||||
void Item::DeleteFromInventoryDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid)
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM);
|
||||
stmt->setUInt32(0, itemGuid);
|
||||
@@ -493,7 +493,7 @@ void Item::DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid)
|
||||
|
||||
void Item::DeleteFromInventoryDB(SQLTransaction& trans)
|
||||
{
|
||||
DeleteFromInventoryDB(trans, GetGUIDLow());
|
||||
DeleteFromInventoryDB(trans, GetGUID().GetCounter());
|
||||
}
|
||||
|
||||
ItemTemplate const* Item::GetTemplate() const
|
||||
@@ -674,7 +674,7 @@ void Item::SetState(ItemUpdateState state, Player* forplayer)
|
||||
if (forplayer)
|
||||
{
|
||||
RemoveFromUpdateQueueOf(forplayer);
|
||||
forplayer->DeleteRefundReference(GetGUIDLow());
|
||||
forplayer->DeleteRefundReference(GetGUID());
|
||||
}
|
||||
delete this;
|
||||
return;
|
||||
@@ -706,7 +706,7 @@ void Item::AddToUpdateQueueOf(Player* player)
|
||||
if (player->GetGUID() != GetOwnerGUID())
|
||||
{
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
LOG_DEBUG("entities.player.items", "Item::AddToUpdateQueueOf - Owner's guid (%u) and player's guid (%u) don't match!", GUID_LOPART(GetOwnerGUID()), player->GetGUIDLow());
|
||||
LOG_DEBUG("entities.player.items", "Item::AddToUpdateQueueOf - Owner's guid (%s) and player's guid (%s) don't match!", GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str());
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@@ -728,7 +728,7 @@ void Item::RemoveFromUpdateQueueOf(Player* player)
|
||||
if (player->GetGUID() != GetOwnerGUID())
|
||||
{
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
LOG_DEBUG("entities.player.items", "Item::RemoveFromUpdateQueueOf - Owner's guid (%u) and player's guid (%u) don't match!", GUID_LOPART(GetOwnerGUID()), player->GetGUIDLow());
|
||||
LOG_DEBUG("entities.player.items", "Item::RemoveFromUpdateQueueOf - Owner's guid (%s) and player's guid (%s) don't match!", GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str());
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@@ -880,7 +880,7 @@ bool Item::IsFitToSpellRequirements(SpellInfo const* spellInfo) const
|
||||
return true;
|
||||
}
|
||||
|
||||
void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, uint64 caster /*= 0*/)
|
||||
void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster /*= ObjectGuid::Empty*/)
|
||||
{
|
||||
// Better lost small time at check in comparison lost time at item save to DB.
|
||||
if ((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges))
|
||||
@@ -890,7 +890,7 @@ void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint
|
||||
if (slot < MAX_INSPECTED_ENCHANTMENT_SLOT)
|
||||
{
|
||||
if (uint32 oldEnchant = GetEnchantmentId(slot))
|
||||
owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), 0, GetEntry(), oldEnchant);
|
||||
owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), ObjectGuid::Empty, GetEntry(), oldEnchant);
|
||||
|
||||
if (id)
|
||||
owner->GetSession()->SendEnchantmentLog(GetOwnerGUID(), caster, GetEntry(), id);
|
||||
@@ -1025,7 +1025,7 @@ bool Item::IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) cons
|
||||
void Item::SendUpdateSockets()
|
||||
{
|
||||
WorldPacket data(SMSG_SOCKET_GEMS_RESULT, 8 + 4 + 4 + 4 + 4);
|
||||
data << uint64(GetGUID());
|
||||
data << GetGUID();
|
||||
for (uint32 i = SOCK_ENCHANTMENT_SLOT; i <= BONUS_ENCHANTMENT_SLOT; ++i)
|
||||
data << uint32(GetEnchantmentId(EnchantmentSlot(i)));
|
||||
|
||||
@@ -1042,7 +1042,7 @@ void Item::SendTimeUpdate(Player* owner)
|
||||
return;
|
||||
|
||||
WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8 + 4));
|
||||
data << uint64(GetGUID());
|
||||
data << GetGUID();
|
||||
data << uint32(duration);
|
||||
owner->GetSession()->SendPacket(&data);
|
||||
}
|
||||
@@ -1061,7 +1061,7 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, bool clo
|
||||
ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already");
|
||||
|
||||
Item* pItem = NewItemOrBag(pProto);
|
||||
if (pItem->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), item, player))
|
||||
if (pItem->Create(sObjectMgr->GetGenerator<HighGuid::Item>().Generate(), item, player))
|
||||
{
|
||||
pItem->SetCount(count);
|
||||
if (!clone)
|
||||
@@ -1103,7 +1103,7 @@ bool Item::IsBindedNotWith(Player const* player) const
|
||||
return false;
|
||||
|
||||
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE))
|
||||
if (allowedGUIDs.find(player->GetGUIDLow()) != allowedGUIDs.end())
|
||||
if (allowedGUIDs.find(player->GetGUID()) != allowedGUIDs.end())
|
||||
return false;
|
||||
|
||||
// BOA item case
|
||||
@@ -1120,16 +1120,28 @@ void Item::BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet&)
|
||||
ClearUpdateMask(false);
|
||||
}
|
||||
|
||||
void Item::AddToObjectUpdate()
|
||||
{
|
||||
if (Player* owner = GetOwner())
|
||||
owner->GetMap()->AddUpdateObject(this);
|
||||
}
|
||||
|
||||
void Item::RemoveFromObjectUpdate()
|
||||
{
|
||||
if (Player* owner = GetOwner())
|
||||
owner->GetMap()->RemoveUpdateObject(this);
|
||||
}
|
||||
|
||||
void Item::SaveRefundDataToDB()
|
||||
{
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE);
|
||||
stmt->setUInt32(0, GetGUIDLow());
|
||||
stmt->setUInt32(0, GetGUID().GetCounter());
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEM_REFUND_INSTANCE);
|
||||
stmt->setUInt32(0, GetGUIDLow());
|
||||
stmt->setUInt32(0, GetGUID().GetCounter());
|
||||
stmt->setUInt32(1, GetRefundRecipient());
|
||||
stmt->setUInt32(2, GetPaidMoney());
|
||||
stmt->setUInt16(3, uint16(GetPaidExtendedCost()));
|
||||
@@ -1143,7 +1155,7 @@ void Item::DeleteRefundDataFromDB(SQLTransaction* trans)
|
||||
if (trans)
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE);
|
||||
stmt->setUInt32(0, GetGUIDLow());
|
||||
stmt->setUInt32(0, GetGUID().GetCounter());
|
||||
(*trans)->Append(stmt);
|
||||
}
|
||||
}
|
||||
@@ -1163,7 +1175,7 @@ void Item::SetNotRefundable(Player* owner, bool changestate /*=true*/, SQLTransa
|
||||
SetPaidExtendedCost(0);
|
||||
DeleteRefundDataFromDB(trans);
|
||||
|
||||
owner->DeleteRefundReference(GetGUIDLow());
|
||||
owner->DeleteRefundReference(GetGUID());
|
||||
}
|
||||
|
||||
void Item::UpdatePlayedTime(Player* owner)
|
||||
@@ -1221,7 +1233,7 @@ void Item::ClearSoulboundTradeable(Player* currentOwner)
|
||||
allowedGUIDs.clear();
|
||||
SetState(ITEM_CHANGED, currentOwner);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_BOP_TRADE);
|
||||
stmt->setUInt32(0, GetGUIDLow());
|
||||
stmt->setUInt32(0, GetGUID().GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
||||
@@ -204,12 +204,12 @@ public:
|
||||
|
||||
Item();
|
||||
|
||||
virtual bool Create(uint32 guidlow, uint32 itemid, Player const* owner);
|
||||
virtual bool Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner);
|
||||
|
||||
[[nodiscard]] ItemTemplate const* GetTemplate() const;
|
||||
|
||||
[[nodiscard]] uint64 GetOwnerGUID() const { return GetUInt64Value(ITEM_FIELD_OWNER); }
|
||||
void SetOwnerGUID(uint64 guid) { SetUInt64Value(ITEM_FIELD_OWNER, guid); }
|
||||
[[nodiscard]] ObjectGuid GetOwnerGUID() const { return GetGuidValue(ITEM_FIELD_OWNER); }
|
||||
void SetOwnerGUID(ObjectGuid guid) { SetGuidValue(ITEM_FIELD_OWNER, guid); }
|
||||
[[nodiscard]] Player* GetOwner() const;
|
||||
|
||||
void SetBinding(bool val) { ApplyModFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_SOULBOUND, val); }
|
||||
@@ -219,10 +219,10 @@ public:
|
||||
[[nodiscard]] bool IsBoundByEnchant() const;
|
||||
[[nodiscard]] bool IsBoundByTempEnchant() const;
|
||||
virtual void SaveToDB(SQLTransaction& trans);
|
||||
virtual bool LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry);
|
||||
static void DeleteFromDB(SQLTransaction& trans, uint32 itemGuid);
|
||||
virtual bool LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry);
|
||||
static void DeleteFromDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid);
|
||||
virtual void DeleteFromDB(SQLTransaction& trans);
|
||||
static void DeleteFromInventoryDB(SQLTransaction& trans, uint32 itemGuid);
|
||||
static void DeleteFromInventoryDB(SQLTransaction& trans, ObjectGuid::LowType itemGuid);
|
||||
void DeleteFromInventoryDB(SQLTransaction& trans);
|
||||
void SaveRefundDataToDB();
|
||||
void DeleteRefundDataFromDB(SQLTransaction* trans);
|
||||
@@ -274,7 +274,7 @@ public:
|
||||
void SetItemRandomProperties(int32 randomPropId);
|
||||
void UpdateItemSuffixFactor();
|
||||
static int32 GenerateItemRandomPropertyId(uint32 item_id);
|
||||
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, uint64 caster = 0);
|
||||
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster = ObjectGuid::Empty);
|
||||
void SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration, Player* owner);
|
||||
void SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges);
|
||||
void ClearEnchantment(EnchantmentSlot slot);
|
||||
@@ -318,10 +318,10 @@ public:
|
||||
|
||||
// Item Refund system
|
||||
void SetNotRefundable(Player* owner, bool changestate = true, SQLTransaction* trans = nullptr);
|
||||
void SetRefundRecipient(uint32 pGuidLow) { m_refundRecipient = pGuidLow; }
|
||||
void SetRefundRecipient(ObjectGuid::LowType pGuidLow) { m_refundRecipient = pGuidLow; }
|
||||
void SetPaidMoney(uint32 money) { m_paidMoney = money; }
|
||||
void SetPaidExtendedCost(uint32 iece) { m_paidExtendedCost = iece; }
|
||||
uint32 GetRefundRecipient() { return m_refundRecipient; }
|
||||
ObjectGuid::LowType GetRefundRecipient() { return m_refundRecipient; }
|
||||
uint32 GetPaidMoney() { return m_paidMoney; }
|
||||
uint32 GetPaidExtendedCost() { return m_paidExtendedCost; }
|
||||
|
||||
@@ -335,6 +335,8 @@ public:
|
||||
bool CheckSoulboundTradeExpire();
|
||||
|
||||
void BuildUpdate(UpdateDataMapType& data_map, UpdatePlayerSet&) override;
|
||||
void AddToObjectUpdate() override;
|
||||
void RemoveFromObjectUpdate() override;
|
||||
|
||||
[[nodiscard]] uint32 GetScriptId() const { return GetTemplate()->ScriptId; }
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user