mirror of
https://github.com/mangosfour/server.git
synced 2025-12-28 13:37:13 +00:00
[SD3] first commit with SD3 inplace - not complete yet
This commit is contained in:
parent
35415eb738
commit
afc2df2f7d
603 changed files with 222771 additions and 1729 deletions
|
|
@ -29,6 +29,9 @@
|
|||
#include "Database/DatabaseEnv.h"
|
||||
#include "ItemEnchantmentMgr.h"
|
||||
#include "SQLStorages.h"
|
||||
#ifdef ENABLE_ELUNA
|
||||
#include "LuaEngine.h"
|
||||
#endif /* ENABLE_ELUNA */
|
||||
|
||||
void AddItemsSetItem(Player* player, Item* item)
|
||||
{
|
||||
|
|
@ -44,7 +47,7 @@ void AddItemsSetItem(Player* player, Item* item)
|
|||
}
|
||||
|
||||
if (set->required_skill_id && player->GetSkillValue(set->required_skill_id) < set->required_skill_value)
|
||||
return;
|
||||
{ return; }
|
||||
|
||||
ItemSetEffect* eff = NULL;
|
||||
|
||||
|
|
@ -66,12 +69,12 @@ void AddItemsSetItem(Player* player, Item* item)
|
|||
size_t x = 0;
|
||||
for (; x < player->ItemSetEff.size(); ++x)
|
||||
if (!player->ItemSetEff[x])
|
||||
break;
|
||||
{ break; }
|
||||
|
||||
if (x < player->ItemSetEff.size())
|
||||
player->ItemSetEff[x] = eff;
|
||||
{ player->ItemSetEff[x] = eff; }
|
||||
else
|
||||
player->ItemSetEff.push_back(eff);
|
||||
{ player->ItemSetEff.push_back(eff); }
|
||||
}
|
||||
|
||||
++eff->item_count;
|
||||
|
|
@ -79,18 +82,18 @@ void AddItemsSetItem(Player* player, Item* item)
|
|||
for (uint32 x = 0; x < 8; ++x)
|
||||
{
|
||||
if (!set->spells[x])
|
||||
continue;
|
||||
{ continue; }
|
||||
// not enough for spell
|
||||
if (set->items_to_triggerspell[x] > eff->item_count)
|
||||
continue;
|
||||
{ continue; }
|
||||
|
||||
uint32 z = 0;
|
||||
for (; z < 8; ++z)
|
||||
if (eff->spells[z] && eff->spells[z]->Id == set->spells[x])
|
||||
break;
|
||||
{ break; }
|
||||
|
||||
if (z < 8)
|
||||
continue;
|
||||
{ continue; }
|
||||
|
||||
// new spell
|
||||
for (uint32 y = 0; y < 8; ++y)
|
||||
|
|
@ -138,18 +141,18 @@ void RemoveItemsSetItem(Player* player, ItemPrototype const* proto)
|
|||
|
||||
// can be in case now enough skill requirement for set appling but set has been appliend when skill requirement not enough
|
||||
if (!eff)
|
||||
return;
|
||||
{ return; }
|
||||
|
||||
--eff->item_count;
|
||||
|
||||
for (uint32 x = 0; x < 8; ++x)
|
||||
{
|
||||
if (!set->spells[x])
|
||||
continue;
|
||||
{ continue; }
|
||||
|
||||
// enough for spell
|
||||
if (set->items_to_triggerspell[x] <= eff->item_count)
|
||||
continue;
|
||||
{ continue; }
|
||||
|
||||
for (uint32 z = 0; z < 8; ++z)
|
||||
{
|
||||
|
|
@ -174,7 +177,7 @@ void RemoveItemsSetItem(Player* player, ItemPrototype const* proto)
|
|||
bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProto)
|
||||
{
|
||||
if (!pProto || !pBagProto)
|
||||
return false;
|
||||
{ return false; }
|
||||
|
||||
switch (pBagProto->Class)
|
||||
{
|
||||
|
|
@ -185,15 +188,15 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt
|
|||
return true;
|
||||
case ITEM_SUBCLASS_SOUL_CONTAINER:
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_SOUL_SHARDS))
|
||||
return false;
|
||||
{ return false; }
|
||||
return true;
|
||||
case ITEM_SUBCLASS_HERB_CONTAINER:
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_HERBS))
|
||||
return false;
|
||||
{ return false; }
|
||||
return true;
|
||||
case ITEM_SUBCLASS_ENCHANTING_CONTAINER:
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_ENCHANTING_SUPP))
|
||||
return false;
|
||||
{ return false; }
|
||||
return true;
|
||||
case ITEM_SUBCLASS_MINING_CONTAINER:
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_MINING_SUPP))
|
||||
|
|
@ -201,7 +204,7 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt
|
|||
return true;
|
||||
case ITEM_SUBCLASS_ENGINEERING_CONTAINER:
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_ENGINEERING_SUPP))
|
||||
return false;
|
||||
{ return false; }
|
||||
return true;
|
||||
case ITEM_SUBCLASS_GEM_CONTAINER:
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_GEMS))
|
||||
|
|
@ -227,11 +230,11 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt
|
|||
{
|
||||
case ITEM_SUBCLASS_QUIVER:
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_ARROWS))
|
||||
return false;
|
||||
{ return false; }
|
||||
return true;
|
||||
case ITEM_SUBCLASS_AMMO_POUCH:
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_BULLETS))
|
||||
return false;
|
||||
{ return false; }
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
|
@ -383,6 +386,10 @@ Item::Item() :
|
|||
m_lootState = ITEM_LOOT_NONE;
|
||||
}
|
||||
|
||||
Item::~Item()
|
||||
{
|
||||
}
|
||||
|
||||
bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
|
||||
{
|
||||
Object::_Create(guidlow, 0, HIGHGUID_ITEM);
|
||||
|
|
@ -395,14 +402,14 @@ bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
|
|||
|
||||
ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(itemid);
|
||||
if (!itemProto)
|
||||
return false;
|
||||
{ return false; }
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1);
|
||||
SetUInt32Value(ITEM_FIELD_MAXDURABILITY, itemProto->MaxDurability);
|
||||
SetUInt32Value(ITEM_FIELD_DURABILITY, itemProto->MaxDurability);
|
||||
|
||||
for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||
SetSpellCharges(i, itemProto->Spells[i].SpellCharges);
|
||||
{ SetSpellCharges(i, itemProto->Spells[i].SpellCharges); }
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_DURATION, itemProto->Duration);
|
||||
|
||||
|
|
@ -419,12 +426,17 @@ bool Item::IsNotEmptyBag() const
|
|||
void Item::UpdateDuration(Player* owner, uint32 diff)
|
||||
{
|
||||
if (!GetUInt32Value(ITEM_FIELD_DURATION))
|
||||
return;
|
||||
{ return; }
|
||||
|
||||
// DEBUG_LOG("Item::UpdateDuration Item (Entry: %u Duration %u Diff %u)", GetEntry(), GetUInt32Value(ITEM_FIELD_DURATION), diff);
|
||||
|
||||
if (GetUInt32Value(ITEM_FIELD_DURATION) <= diff)
|
||||
{
|
||||
// Used by Eluna
|
||||
#ifdef ENABLE_ELUNA
|
||||
sEluna->OnExpire(owner, GetProto());
|
||||
#endif /* ENABLE_ELUNA */
|
||||
|
||||
if (uint32 newItemId = sObjectMgr.GetItemExpireConvert(GetEntry()))
|
||||
owner->ConvertItem(this, newItemId);
|
||||
else
|
||||
|
|
@ -451,7 +463,7 @@ void Item::SaveToDB()
|
|||
|
||||
std::ostringstream ss;
|
||||
for (uint16 i = 0; i < m_valuesCount; ++i)
|
||||
ss << GetUInt32Value(i) << " ";
|
||||
{ ss << GetUInt32Value(i) << " "; }
|
||||
|
||||
stmt = CharacterDatabase.CreateStatement(insItem, "INSERT INTO item_instance (guid,owner_guid,data,text) VALUES (?, ?, ?, ?)");
|
||||
stmt.PExecute(guid, GetOwnerGuid().GetCounter(), ss.str().c_str(), m_text.c_str());
|
||||
|
|
@ -465,7 +477,7 @@ void Item::SaveToDB()
|
|||
|
||||
std::ostringstream ss;
|
||||
for (uint16 i = 0; i < m_valuesCount; ++i)
|
||||
ss << GetUInt32Value(i) << " ";
|
||||
{ ss << GetUInt32Value(i) << " "; }
|
||||
|
||||
stmt.PExecute(ss.str().c_str(), GetOwnerGuid().GetCounter(), m_text.c_str(), guid);
|
||||
|
||||
|
|
@ -534,11 +546,11 @@ void Item::SaveToDB()
|
|||
|
||||
LootItem* item = loot.LootItemInSlot(i, owner, &qitem);
|
||||
if (!item)
|
||||
continue;
|
||||
{ continue; }
|
||||
|
||||
// questitems use the blocked field for other purposes
|
||||
if (!qitem && item->is_blocked)
|
||||
continue;
|
||||
{ continue; }
|
||||
|
||||
stmt.addUInt32(GetGUIDLow());
|
||||
stmt.addUInt32(owner->GetGUIDLow());
|
||||
|
|
@ -553,7 +565,7 @@ void Item::SaveToDB()
|
|||
}
|
||||
|
||||
if (m_lootState != ITEM_LOOT_NONE && m_lootState != ITEM_LOOT_TEMPORARY)
|
||||
SetLootState(ITEM_LOOT_UNCHANGED);
|
||||
{ SetLootState(ITEM_LOOT_UNCHANGED); }
|
||||
|
||||
SetState(ITEM_UNCHANGED);
|
||||
}
|
||||
|
|
@ -584,14 +596,14 @@ bool Item::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid)
|
|||
|
||||
ItemPrototype const* proto = GetProto();
|
||||
if (!proto)
|
||||
return false;
|
||||
{ return false; }
|
||||
|
||||
// update max durability (and durability) if need
|
||||
if (proto->MaxDurability != GetUInt32Value(ITEM_FIELD_MAXDURABILITY))
|
||||
{
|
||||
SetUInt32Value(ITEM_FIELD_MAXDURABILITY, proto->MaxDurability);
|
||||
if (GetUInt32Value(ITEM_FIELD_DURABILITY) > proto->MaxDurability)
|
||||
SetUInt32Value(ITEM_FIELD_DURABILITY, proto->MaxDurability);
|
||||
{ SetUInt32Value(ITEM_FIELD_DURABILITY, proto->MaxDurability); }
|
||||
|
||||
need_save = true;
|
||||
}
|
||||
|
|
@ -649,7 +661,7 @@ bool Item::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid)
|
|||
|
||||
std::ostringstream ss;
|
||||
for (uint16 i = 0; i < m_valuesCount; ++i)
|
||||
ss << GetUInt32Value(i) << " ";
|
||||
{ ss << GetUInt32Value(i) << " "; }
|
||||
|
||||
stmt.addString(ss);
|
||||
stmt.addUInt32(GetOwnerGuid().GetCounter());
|
||||
|
|
@ -756,15 +768,15 @@ uint32 Item::GetSkill()
|
|||
{
|
||||
case ITEM_CLASS_WEAPON:
|
||||
if (proto->SubClass >= MAX_ITEM_SUBCLASS_WEAPON)
|
||||
return 0;
|
||||
{ return 0; }
|
||||
else
|
||||
return item_weapon_skills[proto->SubClass];
|
||||
{ return item_weapon_skills[proto->SubClass]; }
|
||||
|
||||
case ITEM_CLASS_ARMOR:
|
||||
if (proto->SubClass >= MAX_ITEM_SUBCLASS_ARMOR)
|
||||
return 0;
|
||||
{ return 0; }
|
||||
else
|
||||
return item_armor_skills[proto->SubClass];
|
||||
{ return item_armor_skills[proto->SubClass]; }
|
||||
|
||||
default:
|
||||
return 0;
|
||||
|
|
@ -776,7 +788,7 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
|
|||
ItemPrototype const* itemProto = sItemStorage.LookupEntry<ItemPrototype>(item_id);
|
||||
|
||||
if (!itemProto)
|
||||
return 0;
|
||||
{ return 0; }
|
||||
|
||||
// item must have one from this field values not null if it can have random enchantments
|
||||
if ((!itemProto->RandomProperty) && (!itemProto->RandomSuffix))
|
||||
|
|
@ -813,7 +825,7 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
|
|||
void Item::SetItemRandomProperties(int32 randomPropId)
|
||||
{
|
||||
if (!randomPropId)
|
||||
return;
|
||||
{ return; }
|
||||
|
||||
if (randomPropId > 0)
|
||||
{
|
||||
|
|
@ -863,7 +875,7 @@ void Item::SetState(ItemUpdateState state, Player* forplayer)
|
|||
{
|
||||
// pretend the item never existed
|
||||
if (forplayer || GetOwnerGuid())
|
||||
RemoveFromUpdateQueueOf(forplayer);
|
||||
{ RemoveFromUpdateQueueOf(forplayer); }
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
|
|
@ -871,10 +883,10 @@ void Item::SetState(ItemUpdateState state, Player* forplayer)
|
|||
if (state != ITEM_UNCHANGED)
|
||||
{
|
||||
// new items must stay in new state until saved
|
||||
if (uState != ITEM_NEW) uState = state;
|
||||
if (uState != ITEM_NEW) { uState = state; }
|
||||
|
||||
if (forplayer || GetOwnerGuid())
|
||||
AddToUpdateQueueOf(forplayer);
|
||||
{ AddToUpdateQueueOf(forplayer); }
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -888,7 +900,7 @@ void Item::SetState(ItemUpdateState state, Player* forplayer)
|
|||
void Item::AddToUpdateQueueOf(Player* player)
|
||||
{
|
||||
if (IsInUpdateQueue())
|
||||
return;
|
||||
{ return; }
|
||||
|
||||
if (!player)
|
||||
{
|
||||
|
|
@ -909,7 +921,7 @@ void Item::AddToUpdateQueueOf(Player* player)
|
|||
}
|
||||
|
||||
if (player->m_itemUpdateQueueBlocked)
|
||||
return;
|
||||
{ return; }
|
||||
|
||||
player->m_itemUpdateQueue.push_back(this);
|
||||
uQueuePos = player->m_itemUpdateQueue.size() - 1;
|
||||
|
|
@ -918,7 +930,7 @@ void Item::AddToUpdateQueueOf(Player* player)
|
|||
void Item::RemoveFromUpdateQueueOf(Player* player)
|
||||
{
|
||||
if (!IsInUpdateQueue())
|
||||
return;
|
||||
{ return; }
|
||||
|
||||
if (!player)
|
||||
{
|
||||
|
|
@ -939,7 +951,7 @@ void Item::RemoveFromUpdateQueueOf(Player* player)
|
|||
}
|
||||
|
||||
if (player->m_itemUpdateQueueBlocked)
|
||||
return;
|
||||
{ return; }
|
||||
|
||||
player->m_itemUpdateQueue[uQueuePos] = NULL;
|
||||
uQueuePos = -1;
|
||||
|
|
@ -958,24 +970,23 @@ bool Item::IsEquipped() const
|
|||
bool Item::CanBeTraded(bool mail) const
|
||||
{
|
||||
if ((!mail || !IsBoundAccountWide()) && IsSoulBound())
|
||||
return false;
|
||||
|
||||
{ return false; }
|
||||
if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty()))
|
||||
return false;
|
||||
{ return false; }
|
||||
|
||||
if (Player* owner = GetOwner())
|
||||
{
|
||||
if (owner->CanUnequipItem(GetPos(), false) != EQUIP_ERR_OK)
|
||||
return false;
|
||||
{ return false; }
|
||||
if (owner->GetLootGuid() == GetObjectGuid())
|
||||
return false;
|
||||
{ return false; }
|
||||
}
|
||||
|
||||
if (HasGeneratedLoot())
|
||||
return false;
|
||||
{ return false; }
|
||||
|
||||
if (IsBoundByEnchant())
|
||||
return false;
|
||||
{ return false; }
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -987,7 +998,7 @@ bool Item::IsBoundByEnchant() const
|
|||
{
|
||||
uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
|
||||
if (!enchant_id)
|
||||
continue;
|
||||
{ continue; }
|
||||
|
||||
if (enchant_slot == TRANSMOGRIFY_ENCHANTMENT_SLOT)
|
||||
return true;
|
||||
|
|
@ -997,10 +1008,10 @@ bool Item::IsBoundByEnchant() const
|
|||
|
||||
SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
|
||||
if (!enchantEntry)
|
||||
continue;
|
||||
{ continue; }
|
||||
|
||||
if (enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND)
|
||||
return true;
|
||||
{ return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1032,12 +1043,12 @@ bool Item::IsFitToSpellRequirements(SpellEntry const* spellInfo) const
|
|||
if (equippedItems->EquippedItemClass != -1) // -1 == any item class
|
||||
{
|
||||
if (equippedItems->EquippedItemClass != int32(proto->Class))
|
||||
return false; // wrong item class
|
||||
{ return false; } // wrong item class
|
||||
|
||||
if (equippedItems->EquippedItemSubClassMask != 0) // 0 == any subclass
|
||||
{
|
||||
if ((equippedItems->EquippedItemSubClassMask & (1 << proto->SubClass)) == 0)
|
||||
return false; // subclass not present in mask
|
||||
{ return false; } // subclass not present in mask
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1047,7 +1058,7 @@ bool Item::IsFitToSpellRequirements(SpellEntry const* spellInfo) const
|
|||
if (equippedItems->EquippedItemInventoryTypeMask != 0 && (spellInfo->GetTargets() & TARGET_FLAG_ITEM)) // 0 == any inventory type
|
||||
{
|
||||
if ((equippedItems->EquippedItemInventoryTypeMask & (1 << proto->InventoryType)) == 0)
|
||||
return false; // inventory type not present in mask
|
||||
{ return false; } // inventory type not present in mask
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -1058,24 +1069,23 @@ bool Item::IsTargetValidForItemUse(Unit* pUnitTarget)
|
|||
ItemRequiredTargetMapBounds bounds = sObjectMgr.GetItemRequiredTargetMapBounds(GetProto()->ItemId);
|
||||
|
||||
if (bounds.first == bounds.second)
|
||||
return true;
|
||||
{ return true; }
|
||||
|
||||
if (!pUnitTarget)
|
||||
return false;
|
||||
{ return false; }
|
||||
|
||||
for (ItemRequiredTargetMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
|
||||
if (itr->second.IsFitToRequirements(pUnitTarget))
|
||||
return true;
|
||||
{ return true; }
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid casterGuid /*= ObjectGuid()*/)
|
||||
{
|
||||
// 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))
|
||||
return;
|
||||
{ return; }
|
||||
|
||||
if (slot < MAX_INSPECTED_ENCHANTMENT_SLOT)
|
||||
{
|
||||
|
|
@ -1096,7 +1106,7 @@ void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint
|
|||
void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration)
|
||||
{
|
||||
if (GetEnchantmentDuration(slot) == duration)
|
||||
return;
|
||||
{ return; }
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET, duration);
|
||||
SetState(ITEM_CHANGED);
|
||||
|
|
@ -1105,7 +1115,7 @@ void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration)
|
|||
void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges)
|
||||
{
|
||||
if (GetEnchantmentCharges(slot) == charges)
|
||||
return;
|
||||
{ return; }
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET, charges);
|
||||
SetState(ITEM_CHANGED);
|
||||
|
|
@ -1114,7 +1124,7 @@ void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges)
|
|||
void Item::ClearEnchantment(EnchantmentSlot slot)
|
||||
{
|
||||
if (!GetEnchantmentId(slot))
|
||||
return;
|
||||
{ return; }
|
||||
|
||||
for (uint8 x = 0; x < 3; ++x)
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + x, 0);
|
||||
|
|
@ -1136,7 +1146,7 @@ bool Item::GemsFitSockets() const
|
|||
bool fits = true;
|
||||
for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot)
|
||||
{
|
||||
uint8 SocketColor = GetProto()->Socket[enchant_slot - SOCK_ENCHANTMENT_SLOT].Color;
|
||||
uint8 SocketColor = GetProto()->Socket[enchant_slot-SOCK_ENCHANTMENT_SLOT].Color;
|
||||
|
||||
uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
|
||||
if (!enchant_id)
|
||||
|
|
@ -1226,7 +1236,7 @@ void Item::SendTimeUpdate(Player* owner)
|
|||
{
|
||||
uint32 duration = GetUInt32Value(ITEM_FIELD_DURATION);
|
||||
if (!duration)
|
||||
return;
|
||||
{ return; }
|
||||
|
||||
WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8 + 4));
|
||||
data << ObjectGuid(GetObjectGuid());
|
||||
|
|
@ -1237,12 +1247,12 @@ void Item::SendTimeUpdate(Player* owner)
|
|||
Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, uint32 randomPropertyId)
|
||||
{
|
||||
if (count < 1)
|
||||
return NULL; // don't create item at zero count
|
||||
{ return NULL; } // don't create item at zero count
|
||||
|
||||
if (ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item))
|
||||
{
|
||||
if (count > pProto->GetMaxStackSize())
|
||||
count = pProto->GetMaxStackSize();
|
||||
{ count = pProto->GetMaxStackSize(); }
|
||||
|
||||
MANGOS_ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already");
|
||||
|
||||
|
|
@ -1251,12 +1261,12 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, uint32 r
|
|||
{
|
||||
pItem->SetCount(count);
|
||||
if (uint32 randId = randomPropertyId ? randomPropertyId : Item::GenerateItemRandomPropertyId(item))
|
||||
pItem->SetItemRandomProperties(randId);
|
||||
{ pItem->SetItemRandomProperties(randId); }
|
||||
|
||||
return pItem;
|
||||
}
|
||||
else
|
||||
delete pItem;
|
||||
{ delete pItem; }
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -1265,7 +1275,7 @@ Item* Item::CloneItem(uint32 count, Player const* player) const
|
|||
{
|
||||
Item* newItem = CreateItem(GetEntry(), count, player, GetItemRandomPropertyId());
|
||||
if (!newItem)
|
||||
return NULL;
|
||||
{ return NULL; }
|
||||
|
||||
newItem->SetGuidValue(ITEM_FIELD_CREATOR, GetGuidValue(ITEM_FIELD_CREATOR));
|
||||
newItem->SetGuidValue(ITEM_FIELD_GIFTCREATOR, GetGuidValue(ITEM_FIELD_GIFTCREATOR));
|
||||
|
|
@ -1278,15 +1288,15 @@ bool Item::IsBindedNotWith(Player const* player) const
|
|||
{
|
||||
// own item
|
||||
if (GetOwnerGuid() == player->GetObjectGuid())
|
||||
return false;
|
||||
{ return false; }
|
||||
|
||||
// has loot with diff owner
|
||||
if (HasGeneratedLoot())
|
||||
return true;
|
||||
{ return true; }
|
||||
|
||||
// not binded item
|
||||
if (!IsSoulBound())
|
||||
return false;
|
||||
{ return false; }
|
||||
|
||||
// not BOA item case
|
||||
if (!IsBoundAccountWide())
|
||||
|
|
@ -1307,19 +1317,19 @@ bool Item::IsBindedNotWith(Player const* player) const
|
|||
void Item::AddToClientUpdateList()
|
||||
{
|
||||
if (Player* pl = GetOwner())
|
||||
pl->GetMap()->AddUpdateObject(this);
|
||||
{ pl->GetMap()->AddUpdateObject(this); }
|
||||
}
|
||||
|
||||
void Item::RemoveFromClientUpdateList()
|
||||
{
|
||||
if (Player* pl = GetOwner())
|
||||
pl->GetMap()->RemoveUpdateObject(this);
|
||||
{ pl->GetMap()->RemoveUpdateObject(this); }
|
||||
}
|
||||
|
||||
void Item::BuildUpdateData(UpdateDataMapType& update_players)
|
||||
{
|
||||
if (Player* pl = GetOwner())
|
||||
BuildUpdateDataForPlayer(pl, update_players);
|
||||
{ BuildUpdateDataForPlayer(pl, update_players); }
|
||||
|
||||
ClearUpdateMask(false);
|
||||
}
|
||||
|
|
@ -1328,15 +1338,15 @@ InventoryResult Item::CanBeMergedPartlyWith(ItemPrototype const* proto) const
|
|||
{
|
||||
// check item type
|
||||
if (GetEntry() != proto->ItemId)
|
||||
return EQUIP_ERR_ITEM_CANT_STACK;
|
||||
{ return EQUIP_ERR_ITEM_CANT_STACK; }
|
||||
|
||||
// check free space (full stacks can't be target of merge
|
||||
if (GetCount() >= proto->GetMaxStackSize())
|
||||
return EQUIP_ERR_ITEM_CANT_STACK;
|
||||
{ return EQUIP_ERR_ITEM_CANT_STACK; }
|
||||
|
||||
// not allow merge looting currently items
|
||||
if (HasGeneratedLoot())
|
||||
return EQUIP_ERR_ALREADY_LOOTED;
|
||||
{ return EQUIP_ERR_ALREADY_LOOTED; }
|
||||
|
||||
return EQUIP_ERR_OK;
|
||||
}
|
||||
|
|
@ -1344,10 +1354,10 @@ InventoryResult Item::CanBeMergedPartlyWith(ItemPrototype const* proto) const
|
|||
bool ItemRequiredTarget::IsFitToRequirements(Unit* pUnitTarget) const
|
||||
{
|
||||
if (pUnitTarget->GetTypeId() != TYPEID_UNIT)
|
||||
return false;
|
||||
{ return false; }
|
||||
|
||||
if (pUnitTarget->GetEntry() != m_uiTargetEntry)
|
||||
return false;
|
||||
{ return false; }
|
||||
|
||||
switch (m_uiType)
|
||||
{
|
||||
|
|
@ -1403,15 +1413,15 @@ void Item::SetLootState(ItemLootUpdateState state)
|
|||
case ITEM_LOOT_CHANGED:
|
||||
// new loot must stay in new state until saved, temporary must stay until remove
|
||||
if (m_lootState != ITEM_LOOT_NEW && m_lootState != ITEM_LOOT_TEMPORARY)
|
||||
m_lootState = m_lootState == ITEM_LOOT_NONE ? ITEM_LOOT_NEW : state;
|
||||
{ m_lootState = m_lootState == ITEM_LOOT_NONE ? ITEM_LOOT_NEW : state; }
|
||||
break;
|
||||
case ITEM_LOOT_UNCHANGED:
|
||||
// expected that called after DB update or load
|
||||
if (m_lootState == ITEM_LOOT_REMOVED)
|
||||
m_lootState = ITEM_LOOT_NONE;
|
||||
{ m_lootState = ITEM_LOOT_NONE; }
|
||||
// temporary must stay until remove (ignore any changes)
|
||||
else if (m_lootState != ITEM_LOOT_TEMPORARY)
|
||||
m_lootState = ITEM_LOOT_UNCHANGED;
|
||||
{ m_lootState = ITEM_LOOT_UNCHANGED; }
|
||||
break;
|
||||
case ITEM_LOOT_REMOVED:
|
||||
// if loot not saved then it existence in past can be just ignored
|
||||
|
|
@ -1426,7 +1436,12 @@ void Item::SetLootState(ItemLootUpdateState state)
|
|||
}
|
||||
|
||||
if (m_lootState != ITEM_LOOT_NONE && m_lootState != ITEM_LOOT_UNCHANGED && m_lootState != ITEM_LOOT_TEMPORARY)
|
||||
SetState(ITEM_CHANGED);
|
||||
{ SetState(ITEM_CHANGED); }
|
||||
}
|
||||
|
||||
uint32 Item::GetScriptId() const
|
||||
{
|
||||
return sScriptMgr.GetBoundScriptId(SCRIPTED_ITEM, GetEntry());
|
||||
}
|
||||
|
||||
uint32 Item::GetSpecialPrice(ItemPrototype const* proto, uint32 minimumPrice /*= 10000*/)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue