|
|
|
|
@@ -19,6 +19,7 @@
|
|
|
|
|
#include "Common.h"
|
|
|
|
|
#include "ConditionMgr.h"
|
|
|
|
|
#include "DatabaseEnv.h"
|
|
|
|
|
#include "GameTime.h"
|
|
|
|
|
#include "ItemEnchantmentMgr.h"
|
|
|
|
|
#include "ObjectMgr.h"
|
|
|
|
|
#include "Player.h"
|
|
|
|
|
@@ -27,6 +28,8 @@
|
|
|
|
|
#include "SpellMgr.h"
|
|
|
|
|
#include "WorldPacket.h"
|
|
|
|
|
#include "WorldSession.h"
|
|
|
|
|
#include "Tokenize.h"
|
|
|
|
|
#include "StringConvert.h"
|
|
|
|
|
|
|
|
|
|
void AddItemsSetItem(Player* player, Item* item)
|
|
|
|
|
{
|
|
|
|
|
@@ -37,7 +40,7 @@ void AddItemsSetItem(Player* player, Item* item)
|
|
|
|
|
|
|
|
|
|
if (!set)
|
|
|
|
|
{
|
|
|
|
|
LOG_ERROR("sql.sql", "Item set %u for item (id %u) not found, mods not applied.", setid, proto->ItemId);
|
|
|
|
|
LOG_ERROR("sql.sql", "Item set {} for item (id {}) not found, mods not applied.", setid, proto->ItemId);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -97,7 +100,7 @@ void AddItemsSetItem(Player* player, Item* item)
|
|
|
|
|
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(set->spells[x]);
|
|
|
|
|
if (!spellInfo)
|
|
|
|
|
{
|
|
|
|
|
LOG_ERROR("entities.item", "WORLD: unknown spell id %u in items set %u effects", set->spells[x], setid);
|
|
|
|
|
LOG_ERROR("entities.item", "WORLD: unknown spell id {} in items set {} effects", set->spells[x], setid);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -122,7 +125,7 @@ void RemoveItemsSetItem(Player* player, ItemTemplate const* proto)
|
|
|
|
|
|
|
|
|
|
if (!set)
|
|
|
|
|
{
|
|
|
|
|
LOG_ERROR("sql.sql", "Item set #%u for item #%u not found, mods not removed.", setid, proto->ItemId);
|
|
|
|
|
LOG_ERROR("sql.sql", "Item set #{} for item #{} not found, mods not removed.", setid, proto->ItemId);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -251,7 +254,7 @@ Item::Item()
|
|
|
|
|
m_container = nullptr;
|
|
|
|
|
m_lootGenerated = false;
|
|
|
|
|
mb_in_trade = false;
|
|
|
|
|
m_lastPlayedTimeUpdate = time(nullptr);
|
|
|
|
|
m_lastPlayedTimeUpdate = GameTime::GetGameTime().count();
|
|
|
|
|
|
|
|
|
|
m_refundRecipient = 0;
|
|
|
|
|
m_paidMoney = 0;
|
|
|
|
|
@@ -299,7 +302,7 @@ void Item::UpdateDuration(Player* owner, uint32 diff)
|
|
|
|
|
if (!GetUInt32Value(ITEM_FIELD_DURATION))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
LOG_DEBUG("entities.player.items", "Item::UpdateDuration Item (Entry: %u Duration %u Diff %u)", GetEntry(), GetUInt32Value(ITEM_FIELD_DURATION), diff);
|
|
|
|
|
LOG_DEBUG("entities.player.items", "Item::UpdateDuration Item (Entry: {} Duration {} Diff {})", GetEntry(), GetUInt32Value(ITEM_FIELD_DURATION), diff);
|
|
|
|
|
|
|
|
|
|
if (GetUInt32Value(ITEM_FIELD_DURATION) <= diff)
|
|
|
|
|
{
|
|
|
|
|
@@ -326,19 +329,19 @@ void Item::SaveToDB(CharacterDatabaseTransaction trans)
|
|
|
|
|
{
|
|
|
|
|
uint8 index = 0;
|
|
|
|
|
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(uState == ITEM_NEW ? CHAR_REP_ITEM_INSTANCE : CHAR_UPD_ITEM_INSTANCE);
|
|
|
|
|
stmt->setUInt32( index, GetEntry());
|
|
|
|
|
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));
|
|
|
|
|
stmt->SetData( index, GetEntry());
|
|
|
|
|
stmt->SetData(++index, GetOwnerGUID().GetCounter());
|
|
|
|
|
stmt->SetData(++index, GetGuidValue(ITEM_FIELD_CREATOR).GetCounter());
|
|
|
|
|
stmt->SetData(++index, GetGuidValue(ITEM_FIELD_GIFTCREATOR).GetCounter());
|
|
|
|
|
stmt->SetData(++index, GetCount());
|
|
|
|
|
stmt->SetData(++index, GetUInt32Value(ITEM_FIELD_DURATION));
|
|
|
|
|
|
|
|
|
|
std::ostringstream ssSpells;
|
|
|
|
|
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
|
|
|
|
ssSpells << GetSpellCharges(i) << ' ';
|
|
|
|
|
stmt->setString(++index, ssSpells.str());
|
|
|
|
|
stmt->SetData(++index, ssSpells.str());
|
|
|
|
|
|
|
|
|
|
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_FLAGS));
|
|
|
|
|
stmt->SetData(++index, GetUInt32Value(ITEM_FIELD_FLAGS));
|
|
|
|
|
|
|
|
|
|
std::ostringstream ssEnchants;
|
|
|
|
|
for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i)
|
|
|
|
|
@@ -347,21 +350,21 @@ void Item::SaveToDB(CharacterDatabaseTransaction trans)
|
|
|
|
|
ssEnchants << GetEnchantmentDuration(EnchantmentSlot(i)) << ' ';
|
|
|
|
|
ssEnchants << GetEnchantmentCharges(EnchantmentSlot(i)) << ' ';
|
|
|
|
|
}
|
|
|
|
|
stmt->setString(++index, ssEnchants.str());
|
|
|
|
|
stmt->SetData(++index, ssEnchants.str());
|
|
|
|
|
|
|
|
|
|
stmt->setInt16 (++index, GetItemRandomPropertyId());
|
|
|
|
|
stmt->setUInt16(++index, GetUInt32Value(ITEM_FIELD_DURABILITY));
|
|
|
|
|
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME));
|
|
|
|
|
stmt->setString(++index, m_text);
|
|
|
|
|
stmt->setUInt32(++index, guid);
|
|
|
|
|
stmt->SetData (++index, GetItemRandomPropertyId());
|
|
|
|
|
stmt->SetData(++index, GetUInt32Value(ITEM_FIELD_DURABILITY));
|
|
|
|
|
stmt->SetData(++index, GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME));
|
|
|
|
|
stmt->SetData(++index, m_text);
|
|
|
|
|
stmt->SetData(++index, guid);
|
|
|
|
|
|
|
|
|
|
trans->Append(stmt);
|
|
|
|
|
|
|
|
|
|
if ((uState == ITEM_CHANGED) && HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
|
|
|
|
|
{
|
|
|
|
|
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GIFT_OWNER);
|
|
|
|
|
stmt->setUInt32(0, GetOwnerGUID().GetCounter());
|
|
|
|
|
stmt->setUInt32(1, guid);
|
|
|
|
|
stmt->SetData(0, GetOwnerGUID().GetCounter());
|
|
|
|
|
stmt->SetData(1, guid);
|
|
|
|
|
trans->Append(stmt);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
@@ -369,13 +372,13 @@ void Item::SaveToDB(CharacterDatabaseTransaction trans)
|
|
|
|
|
case ITEM_REMOVED:
|
|
|
|
|
{
|
|
|
|
|
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
|
|
|
|
|
stmt->setUInt32(0, guid);
|
|
|
|
|
stmt->SetData(0, guid);
|
|
|
|
|
trans->Append(stmt);
|
|
|
|
|
|
|
|
|
|
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
|
|
|
|
|
{
|
|
|
|
|
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);
|
|
|
|
|
stmt->setUInt32(0, guid);
|
|
|
|
|
stmt->SetData(0, guid);
|
|
|
|
|
trans->Append(stmt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -398,7 +401,7 @@ void Item::SaveToDB(CharacterDatabaseTransaction trans)
|
|
|
|
|
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);
|
|
|
|
|
//result = CharacterDatabase.Query("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text FROM item_instance WHERE guid = '{}'", guid);
|
|
|
|
|
|
|
|
|
|
// create item before any checks for store correct guid
|
|
|
|
|
// and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
|
|
|
|
|
@@ -410,18 +413,21 @@ bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fi
|
|
|
|
|
|
|
|
|
|
ItemTemplate const* proto = GetTemplate();
|
|
|
|
|
if (!proto)
|
|
|
|
|
{
|
|
|
|
|
LOG_ERROR("entities.item", "Invalid entry {} for item {}. Refusing to load.", GetEntry(), GetGUID().ToString());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// set owner (not if item is only loaded for gbank/auction/mail
|
|
|
|
|
if (owner_guid)
|
|
|
|
|
SetOwnerGUID(owner_guid);
|
|
|
|
|
|
|
|
|
|
bool need_save = false; // need explicit save data at load fixes
|
|
|
|
|
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());
|
|
|
|
|
SetGuidValue(ITEM_FIELD_CREATOR, ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>()));
|
|
|
|
|
SetGuidValue(ITEM_FIELD_GIFTCREATOR, ObjectGuid::Create<HighGuid::Player>(fields[1].Get<uint32>()));
|
|
|
|
|
SetCount(fields[2].Get<uint32>());
|
|
|
|
|
|
|
|
|
|
uint32 duration = fields[3].GetUInt32();
|
|
|
|
|
uint32 duration = fields[3].Get<uint32>();
|
|
|
|
|
SetUInt32Value(ITEM_FIELD_DURATION, duration);
|
|
|
|
|
// update duration if need, and remove if not need
|
|
|
|
|
if ((proto->Duration == 0) != (duration == 0))
|
|
|
|
|
@@ -430,12 +436,19 @@ bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fi
|
|
|
|
|
need_save = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Tokenizer tokens(fields[4].GetString(), ' ', MAX_ITEM_PROTO_SPELLS);
|
|
|
|
|
std::vector<std::string_view> tokens = Acore::Tokenize(fields[4].Get<std::string_view>(), ' ', false);
|
|
|
|
|
if (tokens.size() == MAX_ITEM_PROTO_SPELLS)
|
|
|
|
|
{
|
|
|
|
|
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
|
|
|
|
SetSpellCharges(i, atoi(tokens[i]));
|
|
|
|
|
{
|
|
|
|
|
if (Optional<int32> charges = Acore::StringTo<int32>(tokens[i]))
|
|
|
|
|
SetSpellCharges(i, *charges);
|
|
|
|
|
else
|
|
|
|
|
LOG_ERROR("entities.item", "Invalid charge info '{}' for item {}, charge data not loaded.", tokens.at(i), GetGUID().ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetUInt32Value(ITEM_FIELD_FLAGS, fields[5].GetUInt32());
|
|
|
|
|
SetUInt32Value(ITEM_FIELD_FLAGS, fields[5].Get<uint32>());
|
|
|
|
|
// Remove bind flag for items vs NO_BIND set
|
|
|
|
|
if (IsSoulBound() && proto->Bonding == NO_BIND && sScriptMgr->CanApplySoulboundFlag(this, proto))
|
|
|
|
|
{
|
|
|
|
|
@@ -443,14 +456,19 @@ bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fi
|
|
|
|
|
need_save = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string enchants = fields[6].GetString();
|
|
|
|
|
_LoadIntoDataField(enchants.c_str(), ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET);
|
|
|
|
|
SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, fields[7].GetInt16());
|
|
|
|
|
std::string enchants = fields[6].Get<std::string>();
|
|
|
|
|
|
|
|
|
|
if (!_LoadIntoDataField(fields[6].Get<std::string>(), ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET))
|
|
|
|
|
{
|
|
|
|
|
LOG_WARN("entities.item", "Invalid enchantment data '{}' for item {}. Forcing partial load.", fields[6].Get<std::string>(), GetGUID().ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, fields[7].Get<int16>());
|
|
|
|
|
// recalculate suffix factor
|
|
|
|
|
if (GetItemRandomPropertyId() < 0)
|
|
|
|
|
UpdateItemSuffixFactor();
|
|
|
|
|
|
|
|
|
|
uint32 durability = fields[8].GetUInt16();
|
|
|
|
|
uint32 durability = fields[8].Get<uint16>();
|
|
|
|
|
SetUInt32Value(ITEM_FIELD_DURABILITY, durability);
|
|
|
|
|
|
|
|
|
|
// update max durability (and durability) if need
|
|
|
|
|
@@ -462,16 +480,16 @@ bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fi
|
|
|
|
|
need_save = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, fields[9].GetUInt32());
|
|
|
|
|
SetText(fields[10].GetString());
|
|
|
|
|
SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, fields[9].Get<uint32>());
|
|
|
|
|
SetText(fields[10].Get<std::string>());
|
|
|
|
|
|
|
|
|
|
if (need_save) // normal item changed state set not work at loading
|
|
|
|
|
{
|
|
|
|
|
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_INSTANCE_ON_LOAD);
|
|
|
|
|
stmt->setUInt32(0, GetUInt32Value(ITEM_FIELD_DURATION));
|
|
|
|
|
stmt->setUInt32(1, GetUInt32Value(ITEM_FIELD_FLAGS));
|
|
|
|
|
stmt->setUInt32(2, GetUInt32Value(ITEM_FIELD_DURABILITY));
|
|
|
|
|
stmt->setUInt32(3, guid);
|
|
|
|
|
stmt->SetData(0, GetUInt32Value(ITEM_FIELD_DURATION));
|
|
|
|
|
stmt->SetData(1, GetUInt32Value(ITEM_FIELD_FLAGS));
|
|
|
|
|
stmt->SetData(2, GetUInt32Value(ITEM_FIELD_DURABILITY));
|
|
|
|
|
stmt->SetData(3, guid);
|
|
|
|
|
CharacterDatabase.Execute(stmt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -483,7 +501,7 @@ void Item::DeleteFromDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType
|
|
|
|
|
{
|
|
|
|
|
sScriptMgr->OnGlobalItemDelFromDB(trans, itemGuid);
|
|
|
|
|
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
|
|
|
|
|
stmt->setUInt32(0, itemGuid);
|
|
|
|
|
stmt->SetData(0, itemGuid);
|
|
|
|
|
trans->Append(stmt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -496,7 +514,7 @@ void Item::DeleteFromDB(CharacterDatabaseTransaction trans)
|
|
|
|
|
void Item::DeleteFromInventoryDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
|
|
|
|
|
{
|
|
|
|
|
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM);
|
|
|
|
|
stmt->setUInt32(0, itemGuid);
|
|
|
|
|
stmt->SetData(0, itemGuid);
|
|
|
|
|
trans->Append(stmt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -597,7 +615,7 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
|
|
|
|
|
// item can have not null only one from field values
|
|
|
|
|
if ((itemProto->RandomProperty) && (itemProto->RandomSuffix))
|
|
|
|
|
{
|
|
|
|
|
LOG_ERROR("sql.sql", "Item template %u have RandomProperty == %u and RandomSuffix == %u, but must have one from field =0", itemProto->ItemId, itemProto->RandomProperty, itemProto->RandomSuffix);
|
|
|
|
|
LOG_ERROR("sql.sql", "Item template {} have RandomProperty == {} and RandomSuffix == {}, but must have one from field =0", itemProto->ItemId, itemProto->RandomProperty, itemProto->RandomSuffix);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -608,7 +626,7 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
|
|
|
|
|
ItemRandomPropertiesEntry const* random_id = sItemRandomPropertiesStore.LookupEntry(randomPropId);
|
|
|
|
|
if (!random_id)
|
|
|
|
|
{
|
|
|
|
|
LOG_ERROR("sql.sql", "Enchantment id #%u used but it doesn't have records in 'ItemRandomProperties.dbc'", randomPropId);
|
|
|
|
|
LOG_ERROR("sql.sql", "Enchantment id #{} used but it doesn't have records in 'ItemRandomProperties.dbc'", randomPropId);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -621,7 +639,7 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
|
|
|
|
|
ItemRandomSuffixEntry const* random_id = sItemRandomSuffixStore.LookupEntry(randomPropId);
|
|
|
|
|
if (!random_id)
|
|
|
|
|
{
|
|
|
|
|
LOG_ERROR("sql.sql", "Enchantment id #%u used but it doesn't have records in sItemRandomSuffixStore.", randomPropId);
|
|
|
|
|
LOG_ERROR("sql.sql", "Enchantment id #{} used but it doesn't have records in sItemRandomSuffixStore.", randomPropId);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -714,7 +732,7 @@ void Item::AddToUpdateQueueOf(Player* player)
|
|
|
|
|
|
|
|
|
|
if (player->GetGUID() != GetOwnerGUID())
|
|
|
|
|
{
|
|
|
|
|
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());
|
|
|
|
|
LOG_DEBUG("entities.player.items", "Item::AddToUpdateQueueOf - Owner's guid ({}) and player's guid ({}) don't match!", GetOwnerGUID().ToString(), player->GetGUID().ToString());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -734,7 +752,7 @@ void Item::RemoveFromUpdateQueueOf(Player* player)
|
|
|
|
|
|
|
|
|
|
if (player->GetGUID() != GetOwnerGUID())
|
|
|
|
|
{
|
|
|
|
|
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());
|
|
|
|
|
LOG_DEBUG("entities.player.items", "Item::RemoveFromUpdateQueueOf - Owner's guid ({}) and player's guid ({}) don't match!", GetOwnerGUID().ToString(), player->GetGUID().ToString());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -782,7 +800,7 @@ bool Item::CanBeTraded(bool mail, bool trade) const
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Item::HasEnchantRequiredSkill(const Player* player) const
|
|
|
|
|
bool Item::HasEnchantRequiredSkill(Player const* player) const
|
|
|
|
|
{
|
|
|
|
|
// Check all enchants for required skill
|
|
|
|
|
for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot)
|
|
|
|
|
@@ -1038,11 +1056,6 @@ void Item::SendUpdateSockets()
|
|
|
|
|
// time.
|
|
|
|
|
void Item::SendTimeUpdate(Player* owner)
|
|
|
|
|
{
|
|
|
|
|
#ifdef PLAYERBOTS
|
|
|
|
|
if (!owner || !owner->IsInWorld() || owner->GetPlayerbotAI())
|
|
|
|
|
return;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
uint32 duration = GetUInt32Value(ITEM_FIELD_DURATION);
|
|
|
|
|
if (!duration)
|
|
|
|
|
return;
|
|
|
|
|
@@ -1143,14 +1156,14 @@ void Item::SaveRefundDataToDB()
|
|
|
|
|
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
|
|
|
|
|
|
|
|
|
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE);
|
|
|
|
|
stmt->setUInt32(0, GetGUID().GetCounter());
|
|
|
|
|
stmt->SetData(0, GetGUID().GetCounter());
|
|
|
|
|
trans->Append(stmt);
|
|
|
|
|
|
|
|
|
|
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEM_REFUND_INSTANCE);
|
|
|
|
|
stmt->setUInt32(0, GetGUID().GetCounter());
|
|
|
|
|
stmt->setUInt32(1, GetRefundRecipient());
|
|
|
|
|
stmt->setUInt32(2, GetPaidMoney());
|
|
|
|
|
stmt->setUInt16(3, uint16(GetPaidExtendedCost()));
|
|
|
|
|
stmt->SetData(0, GetGUID().GetCounter());
|
|
|
|
|
stmt->SetData(1, GetRefundRecipient());
|
|
|
|
|
stmt->SetData(2, GetPaidMoney());
|
|
|
|
|
stmt->SetData(3, uint16(GetPaidExtendedCost()));
|
|
|
|
|
trans->Append(stmt);
|
|
|
|
|
|
|
|
|
|
CharacterDatabase.CommitTransaction(trans);
|
|
|
|
|
@@ -1161,7 +1174,7 @@ void Item::DeleteRefundDataFromDB(CharacterDatabaseTransaction* trans)
|
|
|
|
|
if (trans)
|
|
|
|
|
{
|
|
|
|
|
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE);
|
|
|
|
|
stmt->setUInt32(0, GetGUID().GetCounter());
|
|
|
|
|
stmt->SetData(0, GetGUID().GetCounter());
|
|
|
|
|
(*trans)->Append(stmt);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -1193,7 +1206,7 @@ void Item::UpdatePlayedTime(Player* owner)
|
|
|
|
|
// Get current played time
|
|
|
|
|
uint32 current_playtime = GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME);
|
|
|
|
|
// Calculate time elapsed since last played time update
|
|
|
|
|
time_t curtime = time(nullptr);
|
|
|
|
|
time_t curtime = GameTime::GetGameTime().count();
|
|
|
|
|
uint32 elapsed = uint32(curtime - m_lastPlayedTimeUpdate);
|
|
|
|
|
uint32 new_playtime = current_playtime + elapsed;
|
|
|
|
|
// Check if the refund timer has expired yet
|
|
|
|
|
@@ -1214,7 +1227,7 @@ void Item::UpdatePlayedTime(Player* owner)
|
|
|
|
|
|
|
|
|
|
uint32 Item::GetPlayedTime()
|
|
|
|
|
{
|
|
|
|
|
time_t curtime = time(nullptr);
|
|
|
|
|
time_t curtime = GameTime::GetGameTime().count();
|
|
|
|
|
uint32 elapsed = uint32(curtime - m_lastPlayedTimeUpdate);
|
|
|
|
|
return GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME) + elapsed;
|
|
|
|
|
}
|
|
|
|
|
@@ -1239,7 +1252,7 @@ void Item::ClearSoulboundTradeable(Player* currentOwner)
|
|
|
|
|
allowedGUIDs.clear();
|
|
|
|
|
SetState(ITEM_CHANGED, currentOwner);
|
|
|
|
|
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_BOP_TRADE);
|
|
|
|
|
stmt->setUInt32(0, GetGUID().GetCounter());
|
|
|
|
|
stmt->SetData(0, GetGUID().GetCounter());
|
|
|
|
|
CharacterDatabase.Execute(stmt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|