52 TC_LOG_ERROR(
"sql.sql",
"Item set {} for item (id {}) not found, mods not applied.", setid, proto->
GetId());
61 for (
size_t x = 0; x < player->
ItemSetEff.size(); ++x)
80 if (x < player->ItemSetEff.size())
112 TC_LOG_ERROR(
"entities.player.items",
"WORLD: unknown spell id {} in items set {} effects", set->
SetSpellID[x], setid);
118 eff->
spells[y] = spellInfo;
133 TC_LOG_ERROR(
"sql.sql",
"Item set #{} for item #{} not found, mods not removed.", setid, proto->
GetId());
139 for (; setindex < player->
ItemSetEff.size(); setindex++)
185 if (!pProto || !pBagProto)
307 return !bag->IsEmpty();
331 bool isInTransaction = bool(trans);
332 if (!isInTransaction)
349 std::ostringstream ssSpells;
352 stmt->
setString(++index, ssSpells.str());
356 std::ostringstream ssEnchants;
363 stmt->
setString(++index, ssEnchants.str());
395 if (!isInTransaction)
411 if (!isInTransaction)
439 bool need_save =
false;
440 if (
uint32 creator = fields[0].GetUInt32())
441 SetCreator(ObjectGuid::Create<HighGuid::Player>(creator));
442 if (
uint32 giftCreator = fields[1].GetUInt32())
443 SetGiftCreator(ObjectGuid::Create<HighGuid::Player>(giftCreator));
449 if ((proto->
GetDuration() == 0) != (duration == 0))
455 std::vector<std::string_view> tokens =
Trinity::Tokenize(fields[4].GetStringView(),
' ',
false);
463 TC_LOG_ERROR(
"entities.item",
"Invalid charge info '{}' for item {}, charge data not loaded.", tokens[i],
GetGUID());
476 TC_LOG_WARN(
"entities.item",
"Invalid enchantment data '{}' for item {}. Forcing partial load.", fields[6].GetString(),
GetGUID().ToString());
496 SetText(fields[10].GetString());
603 if (randomPropId > 0)
680 ASSERT(player !=
nullptr);
684 TC_LOG_DEBUG(
"entities.player.items",
"AddItemToUpdateQueueOf - Owner's guid ({}) and player's guid ({}) don't match!",
701 ASSERT(player !=
nullptr);
705 TC_LOG_DEBUG(
"entities.player.items",
"RemoveItemFromUpdateQueueOf - Owner's guid ({}) and player's guid ({}) don't match!",
742 if (owner->GetLootGUID() ==
GetGUID())
759 ASSERT(maxDurability >= curDurability);
761 uint32 lostDurability = maxDurability - curDurability;
773 if (!durabilityQualityEntry)
790 uint32 cost =
static_cast<uint32>(std::round(lostDurability * dmultiplier *
double(durabilityQualityEntry->
Data)));
805 if (enchantEntry->RequiredSkillID && player->
GetSkillValue(enchantEntry->RequiredSkillID) < enchantEntry->RequiredSkillRank)
819 if (enchantEntry->MinLevel > level)
820 level = enchantEntry->MinLevel;
967 GemColor = gemProperty->
Type;
1061 ASSERT_NODEBUGINFO(count != 0 &&
"pProto->Stackable == 0 but checked at loading already");
1125 owner->GetMap()->AddUpdateObject(
this);
1135 owner->GetMap()->RemoveUpdateObject(
this);
1152 if (price && forVendor)
1154 auto effectWithCharges = std::ranges::find_if(itemTemplate->
Effects,
1155 [](
ItemEffect const& itemEffect) { return itemEffect.SpellID && itemEffect.TriggerType == ITEM_SPELLTRIGGER_ON_USE && itemEffect.Charges < 0; });
1157 if (effectWithCharges != itemTemplate->
Effects.end())
1158 price = price *
GetSpellCharges(std::ranges::distance(itemTemplate->
Effects.begin(), effectWithCharges)) / effectWithCharges->Charges;
1161 if (repairCost < price)
1162 price -= repairCost;
1181 trans->Append(stmt);
1188 trans->Append(stmt);
1199 (*trans)->Append(stmt);
1233 uint32 new_playtime = current_playtime + elapsed;
1235 if (new_playtime <= 2*
HOUR)
1299 if (
TradeData* tradeData = player->GetTradeData())
1304 tradeData->SetItem(slot,
this,
true);
1311 std::stringstream sstr;
Item * NewItemOrBag(ItemTemplate const *proto)
@ CHAR_UPD_ITEM_INSTANCE_ON_LOAD
@ CHAR_DEL_CHAR_INVENTORY_BY_ITEM
@ CHAR_DEL_ITEM_BOP_TRADE
@ CHAR_DEL_ITEM_REFUND_INSTANCE
@ CHAR_INS_ITEM_REFUND_INSTANCE
@ ENCHANTMENT_CAN_SOULBOUND
DBCStorage< DurabilityQualityEntry > sDurabilityQualityStore(DurabilityQualityfmt)
DBCStorage< SpellItemEnchantmentEntry > sSpellItemEnchantmentStore(SpellItemEnchantmentfmt)
DBCStorage< ItemSetEntry > sItemSetStore(ItemSetEntryfmt)
DBCStorage< ItemRandomSuffixEntry > sItemRandomSuffixStore(ItemRandomSuffixfmt)
DBCStorage< DurabilityCostsEntry > sDurabilityCostsStore(DurabilityCostsfmt)
DBCStorage< GemPropertiesEntry > sGemPropertiesStore(GemPropertiesEntryfmt)
DBCStorage< ItemRandomPropertiesEntry > sItemRandomPropertiesStore(ItemRandomPropertiesfmt)
#define MAX_ITEM_SET_SPELLS
#define MAX_ITEM_ENCHANTMENT_EFFECTS
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
#define ASSERT_NODEBUGINFO
@ PROP_ENCHANTMENT_SLOT_0
@ PROP_ENCHANTMENT_SLOT_2
@ MAX_INSPECTED_ENCHANTMENT_SLOT
uint32 GenerateEnchSuffixFactor(uint32 item_id)
@ ITEM_SUBCLASS_WEAPON_CROSSBOW
@ ITEM_SUBCLASS_WEAPON_GUN
@ ITEM_SUBCLASS_WEAPON_AXE2
@ ITEM_SUBCLASS_WEAPON_SPEAR
@ ITEM_SUBCLASS_WEAPON_STAFF
@ ITEM_SUBCLASS_WEAPON_MACE
@ ITEM_SUBCLASS_WEAPON_MACE2
@ ITEM_SUBCLASS_WEAPON_DAGGER
@ ITEM_SUBCLASS_WEAPON_BOW
@ ITEM_SUBCLASS_WEAPON_SWORD
@ ITEM_SUBCLASS_WEAPON_AXE
@ ITEM_SUBCLASS_WEAPON_WAND
@ ITEM_SUBCLASS_WEAPON_THROWN
@ ITEM_SUBCLASS_WEAPON_SWORD2
@ ITEM_SUBCLASS_WEAPON_POLEARM
@ ITEM_FIELD_FLAG_REFUNDABLE
@ ITEM_FIELD_FLAG_SOULBOUND
@ ITEM_FIELD_FLAG_BOP_TRADEABLE
@ BAG_FAMILY_MASK_MINING_SUPP
@ BAG_FAMILY_MASK_ENCHANTING_SUPP
@ BAG_FAMILY_MASK_SOUL_SHARDS
@ BAG_FAMILY_MASK_INSCRIPTION_SUPP
@ BAG_FAMILY_MASK_BULLETS
@ BAG_FAMILY_MASK_ENGINEERING_SUPP
@ BAG_FAMILY_MASK_LEATHERWORKING_SUPP
@ ITEM_SUBCLASS_CONTAINER
@ ITEM_SUBCLASS_INSCRIPTION_CONTAINER
@ ITEM_SUBCLASS_LEATHERWORKING_CONTAINER
@ ITEM_SUBCLASS_GEM_CONTAINER
@ ITEM_SUBCLASS_SOUL_CONTAINER
@ ITEM_SUBCLASS_ENCHANTING_CONTAINER
@ ITEM_SUBCLASS_MINING_CONTAINER
@ ITEM_SUBCLASS_HERB_CONTAINER
@ ITEM_SUBCLASS_ENGINEERING_CONTAINER
@ ITEM_SUBCLASS_AMMO_POUCH
@ ITEM_SUBCLASS_ARMOR_MAIL
@ ITEM_SUBCLASS_ARMOR_CLOTH
@ ITEM_SUBCLASS_ARMOR_LEATHER
@ ITEM_SUBCLASS_ARMOR_SHIELD
@ ITEM_SUBCLASS_ARMOR_PLATE
#define MAX_ITEM_PROTO_SPELLS
void AddItemsSetItem(Player *player, Item *item)
bool ItemCanGoIntoBag(ItemTemplate const *pProto, ItemTemplate const *pBagProto)
void RemoveItemsSetItem(Player *player, ItemTemplate const *proto)
void RemoveItemFromUpdateQueueOf(Item *item, Player *player)
void AddItemToUpdateQueueOf(Item *item, Player *player)
#define MAX_ENCHANTMENT_OFFSET
@ ENCHANTMENT_CHARGES_OFFSET
@ ENCHANTMENT_DURATION_OFFSET
#define TC_LOG_WARN(filterType__,...)
#define TC_LOG_DEBUG(filterType__,...)
#define TC_LOG_ERROR(filterType__,...)
std::set< ObjectGuid > GuidSet
std::unordered_map< Player *, UpdateData > UpdateDataMapType
std::optional< T > Optional
Optional helper class to wrap optional values within.
#define INVENTORY_SLOT_BAG_0
@ SPELL_EFFECT_ENCHANT_ITEM
@ SPELL_EFFECT_ENCHANT_ITEM_PRISMATIC
@ SPELL_EFFECT_ENCHANT_ITEM_TEMPORARY
@ ITEM_FIELD_MAXDURABILITY
@ ITEM_FIELD_RANDOM_PROPERTIES_ID
@ ITEM_FIELD_PROPERTY_SEED
@ ITEM_FIELD_ENCHANTMENT_1_1
@ ITEM_FIELD_CREATE_PLAYED_TIME
Class used to access individual fields of database query result.
std::string GetDebugInfo() const override
std::string const & GetNameForLocaleIdx(LocaleConstant locale) const override
uint32 GetEnchantRequiredLevel() const
static void DeleteFromInventoryDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
void SetState(ItemUpdateState state, Player *forplayer=nullptr)
uint32 GetPaidExtendedCost() const
void SetItemFlag(ItemFieldFlags flags)
void UpdateItemSuffixFactor()
uint32 CalculateDurabilityRepairCost(float discount, bool useRateConfig=true) const
void SetSpellCharges(uint8 index, int32 value)
bool AddToObjectUpdate() override
void SetText(std::string const &text)
virtual bool LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field *fields, uint32 entry)
void UpdateDuration(Player *owner, uint32 diff)
virtual void SaveToDB(CharacterDatabaseTransaction trans)
void ReplaceAllItemFlags(ItemFieldFlags flags)
void BuildUpdate(UpdateDataMapType &) override
bool IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) const
void RemoveItemFlag(ItemFieldFlags flags)
void DeleteRefundDataFromDB(CharacterDatabaseTransaction *trans)
uint32 GetEnchantmentId(EnchantmentSlot slot) const
int32 GetSpellCharges(uint8 index=0) const
static Item * CreateItem(uint32 itemEntry, uint32 count, Player const *player=nullptr)
Item * CloneItem(uint32 count, Player const *player=nullptr) const
void SetItemRandomProperties(int32 randomPropId)
void SetPaidMoney(uint32 money)
uint8 GetGemCountWithID(uint32 GemID) const
bool IsBoundAccountWide() const
bool CanBeTraded(bool mail=false, bool trade=false) const
uint32 GetEnchantmentDuration(EnchantmentSlot slot) const
void SetCount(uint32 value)
void SetDurability(uint32 durability)
int32 GetItemRandomPropertyId() const
ObjectGuid GetCreator() const
ItemTemplate const * GetTemplate() const
bool IsBOPTradeable() const
void SaveRefundDataToDB()
void SetNotRefundable(Player *owner, bool changestate=true, CharacterDatabaseTransaction *trans=nullptr)
uint32 GetItemSuffixFactor() const
friend void RemoveItemFromUpdateQueueOf(Item *item, Player *player)
bool IsBindedNotWith(Player const *player) const
void SendTimeUpdate(Player *owner)
void UpdatePlayedTime(Player *owner)
uint32 GetBuyPrice() const
Player * GetOwner() const
ObjectGuid GetOwnerGUID() const
bool HasEnchantRequiredSkill(Player const *player) const
time_t m_lastPlayedTimeUpdate
bool IsRefundable() const
bool GemsFitSockets() const
bool IsBoundByEnchant() const
void SetSoulboundTradeable(GuidSet const &allowedLooters)
void SetContainedIn(ObjectGuid guid)
ObjectGuid GetGiftCreator() const
uint32 GetSellPrice(bool forVendor=false) const
void SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges)
void SetMaxDurability(uint32 maxDurability)
uint32 m_paidExtendedCost
void RemoveFromObjectUpdate() override
void ClearEnchantment(EnchantmentSlot slot)
void SetCreator(ObjectGuid guid)
ObjectGuid const & GetRefundRecipient() const
void SetCreatePlayedTime(uint32 createPlayedTime)
void SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration, Player *owner)
InventoryResult CanBeMergedPartlyWith(ItemTemplate const *proto) const
void SetPaidExtendedCost(uint32 iece)
uint32 GetEnchantmentCharges(EnchantmentSlot slot) const
void SetRefundRecipient(ObjectGuid const &guid)
virtual bool Create(ObjectGuid::LowType guidlow, uint32 itemId, Player const *owner)
uint32 GetPaidMoney() const
uint8 GetGemCountWithLimitCategory(uint32 limitCategory) const
void ClearSoulboundTradeable(Player *currentOwner)
bool IsNotEmptyBag() const
void SetExpiration(uint32 expiration)
bool CheckSoulboundTradeExpire()
void SetOwnerGUID(ObjectGuid guid)
void SetGiftCreator(ObjectGuid guid)
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster=ObjectGuid::Empty)
static void DeleteFromDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
friend void AddItemToUpdateQueueOf(Item *item, Player *player)
bool IsInUpdateQueue() const
bool IsFitToSpellRequirements(SpellInfo const *spellInfo) const
LowType GetCounter() const
static ObjectGuid const Empty
std::string ToString() const
void BuildFieldsUpdate(Player *, UpdateDataMapType &) const
int32 GetInt32Value(uint16 index) const
void SetInt32Value(uint16 index, int32 value)
uint32 GetUInt32Value(uint16 index) const
void ClearUpdateMask(bool remove)
bool _LoadIntoDataField(std::string const &data, uint32 startOffset, uint32 count)
virtual std::string GetDebugInfo() const
void _Create(ObjectGuid const &guid)
static ObjectGuid GetGUID(Object const *o)
void SetEntry(uint32 entry)
virtual void SetObjectScale(float scale)
void SetUInt32Value(uint16 index, uint32 value)
ObjectGuid GetGUID() const
ObjectGuid GetGuidValue(uint16 index) const
std::vector< Item * > m_itemUpdateQueue
void SendDirectMessage(WorldPacket const *data) const
uint16 GetSkillValue(uint32 skill) const
WorldSession * GetSession() const
void DestroyItem(uint8 bag, uint8 slot, bool update)
std::vector< ItemSetEffect * > ItemSetEff
static bool IsBagPos(uint16 pos)
void ApplyEquipSpell(SpellInfo const *spellInfo, Item *item, bool apply, bool form_change=false)
void DeleteRefundReference(ObjectGuid it)
bool m_itemUpdateQueueBlocked
void setInt16(uint8 index, int16 value)
void setUInt16(uint8 index, uint16 value)
void setUInt32(uint8 index, uint32 value)
void setString(uint8 index, std::string const &value)
int32 EquippedItemSubClassMask
int32 EquippedItemInventoryTypeMask
bool HasEffect(SpellEffects effect) const
WorldPacket const * Write() override
void SendEnchantmentLog(ObjectGuid target, ObjectGuid caster, uint32 itemId, uint32 enchantId)
@ SMSG_SOCKET_GEMS_RESULT
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
TC_COMMON_API std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
uint32 ArmorSubClassCost[8]
uint32 WeaponSubClassCost[21]
std::array< uint32, MAX_ITEM_ENCHANTMENT_EFFECTS > Enchantment
std::array< uint32, MAX_ITEM_ENCHANTMENT_EFFECTS > Enchantment
SpellInfo const * spells[8]
uint32 SetThreshold[MAX_ITEM_SET_SPELLS]
uint32 SetSpellID[MAX_ITEM_SET_SPELLS]
std::array< ItemEffect, MAX_ITEM_PROTO_SPELLS > Effects
uint32 GetBaseItemLevel() const
uint32 GetQuality() const
uint32 GetDuration() const
uint32 GetGemProperties() const
uint32 GetMaxStackSize() const
SocketColor GetSocketColor(uint32 index) const
uint32 GetBuyPrice() const
ItemBondingType GetBonding() const
uint32 GetItemSet() const
bool IsArmorVellum() const
std::string const & GetName(LocaleConstant locale) const
uint32 GetItemLimitCategory() const
uint32 GetSubClass() const
uint32 GetSellPrice() const
::InventoryType GetInventoryType() const
bool IsWeaponVellum() const
uint32 GetBagFamily() const