mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[11612] Code style in Item.*
Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
52134f1852
commit
2686963d6d
3 changed files with 198 additions and 198 deletions
|
|
@ -23,45 +23,45 @@
|
|||
#include "Database/DatabaseEnv.h"
|
||||
#include "ItemEnchantmentMgr.h"
|
||||
|
||||
void AddItemsSetItem(Player*player,Item *item)
|
||||
void AddItemsSetItem(Player* player, Item* item)
|
||||
{
|
||||
ItemPrototype const *proto = item->GetProto();
|
||||
ItemPrototype const* proto = item->GetProto();
|
||||
uint32 setid = proto->ItemSet;
|
||||
|
||||
ItemSetEntry const *set = sItemSetStore.LookupEntry(setid);
|
||||
ItemSetEntry const* set = sItemSetStore.LookupEntry(setid);
|
||||
|
||||
if(!set)
|
||||
if (!set)
|
||||
{
|
||||
sLog.outErrorDb("Item set %u for item (id %u) not found, mods not applied.",setid,proto->ItemId);
|
||||
sLog.outErrorDb("Item set %u for item (id %u) not found, mods not applied.", setid,proto->ItemId);
|
||||
return;
|
||||
}
|
||||
|
||||
if( set->required_skill_id && player->GetSkillValue(set->required_skill_id) < set->required_skill_value )
|
||||
if (set->required_skill_id && player->GetSkillValue(set->required_skill_id) < set->required_skill_value)
|
||||
return;
|
||||
|
||||
ItemSetEffect *eff = NULL;
|
||||
ItemSetEffect* eff = NULL;
|
||||
|
||||
for(size_t x = 0; x < player->ItemSetEff.size(); ++x)
|
||||
for (size_t x = 0; x < player->ItemSetEff.size(); ++x)
|
||||
{
|
||||
if(player->ItemSetEff[x] && player->ItemSetEff[x]->setid == setid)
|
||||
if (player->ItemSetEff[x] && player->ItemSetEff[x]->setid == setid)
|
||||
{
|
||||
eff = player->ItemSetEff[x];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!eff)
|
||||
if (!eff)
|
||||
{
|
||||
eff = new ItemSetEffect;
|
||||
memset(eff,0,sizeof(ItemSetEffect));
|
||||
memset(eff, 0, sizeof(ItemSetEffect));
|
||||
eff->setid = setid;
|
||||
|
||||
size_t x = 0;
|
||||
for(; x < player->ItemSetEff.size(); x++)
|
||||
if(!player->ItemSetEff[x])
|
||||
for (; x < player->ItemSetEff.size(); x++)
|
||||
if (!player->ItemSetEff[x])
|
||||
break;
|
||||
|
||||
if(x < player->ItemSetEff.size())
|
||||
if (x < player->ItemSetEff.size())
|
||||
player->ItemSetEff[x]=eff;
|
||||
else
|
||||
player->ItemSetEff.push_back(eff);
|
||||
|
|
@ -69,36 +69,36 @@ void AddItemsSetItem(Player*player,Item *item)
|
|||
|
||||
++eff->item_count;
|
||||
|
||||
for(uint32 x=0;x<8;x++)
|
||||
for (uint32 x = 0; x < 8; x++)
|
||||
{
|
||||
if(!set->spells [x])
|
||||
if (!set->spells[x])
|
||||
continue;
|
||||
//not enough for spell
|
||||
if(set->items_to_triggerspell[x] > eff->item_count)
|
||||
// not enough for spell
|
||||
if (set->items_to_triggerspell[x] > eff->item_count)
|
||||
continue;
|
||||
|
||||
uint32 z=0;
|
||||
for(;z<8;z++)
|
||||
if(eff->spells[z] && eff->spells[z]->Id==set->spells[x])
|
||||
uint32 z = 0;
|
||||
for (; z < 8; z++)
|
||||
if (eff->spells[z] && eff->spells[z]->Id == set->spells[x])
|
||||
break;
|
||||
|
||||
if(z < 8)
|
||||
if (z < 8)
|
||||
continue;
|
||||
|
||||
//new spell
|
||||
for(uint32 y=0;y<8;y++)
|
||||
// new spell
|
||||
for (uint32 y = 0; y < 8; y++)
|
||||
{
|
||||
if(!eff->spells[y]) // free slot
|
||||
if (!eff->spells[y]) // free slot
|
||||
{
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(set->spells[x]);
|
||||
if(!spellInfo)
|
||||
SpellEntry const* spellInfo = sSpellStore.LookupEntry(set->spells[x]);
|
||||
if (!spellInfo)
|
||||
{
|
||||
sLog.outError("WORLD: unknown spell id %u in items set %u effects", set->spells[x],setid);
|
||||
break;
|
||||
}
|
||||
|
||||
// spell casted only if fit form requirement, in other case will casted at form change
|
||||
player->ApplyEquipSpell(spellInfo,NULL,true);
|
||||
player->ApplyEquipSpell(spellInfo, NULL, true);
|
||||
eff->spells[y] = spellInfo;
|
||||
break;
|
||||
}
|
||||
|
|
@ -106,23 +106,23 @@ void AddItemsSetItem(Player*player,Item *item)
|
|||
}
|
||||
}
|
||||
|
||||
void RemoveItemsSetItem(Player*player,ItemPrototype const *proto)
|
||||
void RemoveItemsSetItem(Player* player, ItemPrototype const* proto)
|
||||
{
|
||||
uint32 setid = proto->ItemSet;
|
||||
|
||||
ItemSetEntry const *set = sItemSetStore.LookupEntry(setid);
|
||||
ItemSetEntry const* set = sItemSetStore.LookupEntry(setid);
|
||||
|
||||
if(!set)
|
||||
if (!set)
|
||||
{
|
||||
sLog.outErrorDb("Item set #%u for item #%u not found, mods not removed.",setid,proto->ItemId);
|
||||
sLog.outErrorDb("Item set #%u for item #%u not found, mods not removed.", setid,proto->ItemId);
|
||||
return;
|
||||
}
|
||||
|
||||
ItemSetEffect *eff = NULL;
|
||||
ItemSetEffect* eff = NULL;
|
||||
size_t setindex = 0;
|
||||
for(;setindex < player->ItemSetEff.size(); setindex++)
|
||||
for (; setindex < player->ItemSetEff.size(); setindex++)
|
||||
{
|
||||
if(player->ItemSetEff[setindex] && player->ItemSetEff[setindex]->setid == setid)
|
||||
if (player->ItemSetEff[setindex] && player->ItemSetEff[setindex]->setid == setid)
|
||||
{
|
||||
eff = player->ItemSetEff[setindex];
|
||||
break;
|
||||
|
|
@ -130,33 +130,33 @@ 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)
|
||||
if (!eff)
|
||||
return;
|
||||
|
||||
--eff->item_count;
|
||||
|
||||
for(uint32 x=0;x<8;x++)
|
||||
for (uint32 x = 0; x < 8; x++)
|
||||
{
|
||||
if(!set->spells[x])
|
||||
if (!set->spells[x])
|
||||
continue;
|
||||
|
||||
// enough for spell
|
||||
if(set->items_to_triggerspell[x] <= eff->item_count)
|
||||
if (set->items_to_triggerspell[x] <= eff->item_count)
|
||||
continue;
|
||||
|
||||
for(uint32 z=0;z<8;z++)
|
||||
for (uint32 z = 0; z < 8; z++)
|
||||
{
|
||||
if(eff->spells[z] && eff->spells[z]->Id==set->spells[x])
|
||||
if (eff->spells[z] && eff->spells[z]->Id == set->spells[x])
|
||||
{
|
||||
// spell can be not active if not fit form requirement
|
||||
player->ApplyEquipSpell(eff->spells[z],NULL,false);
|
||||
eff->spells[z]=NULL;
|
||||
player->ApplyEquipSpell(eff->spells[z], NULL, false);
|
||||
eff->spells[z] = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!eff->item_count) //all items of a set were removed
|
||||
if (!eff->item_count) // all items of a set were removed
|
||||
{
|
||||
MANGOS_ASSERT(eff == player->ItemSetEff[setindex]);
|
||||
delete eff;
|
||||
|
|
@ -164,62 +164,62 @@ void RemoveItemsSetItem(Player*player,ItemPrototype const *proto)
|
|||
}
|
||||
}
|
||||
|
||||
bool ItemCanGoIntoBag(ItemPrototype const *pProto, ItemPrototype const *pBagProto)
|
||||
bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProto)
|
||||
{
|
||||
if(!pProto || !pBagProto)
|
||||
if (!pProto || !pBagProto)
|
||||
return false;
|
||||
|
||||
switch(pBagProto->Class)
|
||||
switch (pBagProto->Class)
|
||||
{
|
||||
case ITEM_CLASS_CONTAINER:
|
||||
switch(pBagProto->SubClass)
|
||||
switch (pBagProto->SubClass)
|
||||
{
|
||||
case ITEM_SUBCLASS_CONTAINER:
|
||||
return true;
|
||||
case ITEM_SUBCLASS_SOUL_CONTAINER:
|
||||
if(!(pProto->BagFamily & BAG_FAMILY_MASK_SOUL_SHARDS))
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_MASK_SOUL_SHARDS))
|
||||
return false;
|
||||
return true;
|
||||
case ITEM_SUBCLASS_HERB_CONTAINER:
|
||||
if(!(pProto->BagFamily & BAG_FAMILY_MASK_HERBS))
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_MASK_HERBS))
|
||||
return false;
|
||||
return true;
|
||||
case ITEM_SUBCLASS_ENCHANTING_CONTAINER:
|
||||
if(!(pProto->BagFamily & BAG_FAMILY_MASK_ENCHANTING_SUPP))
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_MASK_ENCHANTING_SUPP))
|
||||
return false;
|
||||
return true;
|
||||
case ITEM_SUBCLASS_MINING_CONTAINER:
|
||||
if(!(pProto->BagFamily & BAG_FAMILY_MASK_MINING_SUPP))
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_MASK_MINING_SUPP))
|
||||
return false;
|
||||
return true;
|
||||
case ITEM_SUBCLASS_ENGINEERING_CONTAINER:
|
||||
if(!(pProto->BagFamily & BAG_FAMILY_MASK_ENGINEERING_SUPP))
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_MASK_ENGINEERING_SUPP))
|
||||
return false;
|
||||
return true;
|
||||
case ITEM_SUBCLASS_GEM_CONTAINER:
|
||||
if(!(pProto->BagFamily & BAG_FAMILY_MASK_GEMS))
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_MASK_GEMS))
|
||||
return false;
|
||||
return true;
|
||||
case ITEM_SUBCLASS_LEATHERWORKING_CONTAINER:
|
||||
if(!(pProto->BagFamily & BAG_FAMILY_MASK_LEATHERWORKING_SUPP))
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_MASK_LEATHERWORKING_SUPP))
|
||||
return false;
|
||||
return true;
|
||||
case ITEM_SUBCLASS_INSCRIPTION_CONTAINER:
|
||||
if(!(pProto->BagFamily & BAG_FAMILY_MASK_INSCRIPTION_SUPP))
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_MASK_INSCRIPTION_SUPP))
|
||||
return false;
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
case ITEM_CLASS_QUIVER:
|
||||
switch(pBagProto->SubClass)
|
||||
switch (pBagProto->SubClass)
|
||||
{
|
||||
case ITEM_SUBCLASS_QUIVER:
|
||||
if(!(pProto->BagFamily & BAG_FAMILY_MASK_ARROWS))
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_MASK_ARROWS))
|
||||
return false;
|
||||
return true;
|
||||
case ITEM_SUBCLASS_AMMO_POUCH:
|
||||
if(!(pProto->BagFamily & BAG_FAMILY_MASK_BULLETS))
|
||||
if (!(pProto->BagFamily & BAG_FAMILY_MASK_BULLETS))
|
||||
return false;
|
||||
return true;
|
||||
default:
|
||||
|
|
@ -229,7 +229,7 @@ bool ItemCanGoIntoBag(ItemPrototype const *pProto, ItemPrototype const *pBagProt
|
|||
return false;
|
||||
}
|
||||
|
||||
Item::Item( )
|
||||
Item::Item()
|
||||
{
|
||||
m_objectType |= TYPEMASK_ITEM;
|
||||
m_objectTypeId = TYPEID_ITEM;
|
||||
|
|
@ -245,7 +245,7 @@ Item::Item( )
|
|||
m_lootState = ITEM_LOOT_NONE;
|
||||
}
|
||||
|
||||
bool Item::Create( uint32 guidlow, uint32 itemid, Player const* owner)
|
||||
bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
|
||||
{
|
||||
Object::_Create(guidlow, 0, HIGHGUID_ITEM);
|
||||
|
||||
|
|
@ -255,15 +255,15 @@ bool Item::Create( uint32 guidlow, uint32 itemid, Player const* owner)
|
|||
SetGuidValue(ITEM_FIELD_OWNER, owner ? owner->GetObjectGuid() : ObjectGuid());
|
||||
SetGuidValue(ITEM_FIELD_CONTAINED, ObjectGuid());
|
||||
|
||||
ItemPrototype const *itemProto = ObjectMgr::GetItemPrototype(itemid);
|
||||
if(!itemProto)
|
||||
ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(itemid);
|
||||
if (!itemProto)
|
||||
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)
|
||||
for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||
SetSpellCharges(i,itemProto->Spells[i].SpellCharges);
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_DURATION, itemProto->Duration);
|
||||
|
|
@ -276,9 +276,9 @@ void Item::UpdateDuration(Player* owner, uint32 diff)
|
|||
if (!GetUInt32Value(ITEM_FIELD_DURATION))
|
||||
return;
|
||||
|
||||
//DEBUG_LOG("Item::UpdateDuration Item (Entry: %u Duration %u Diff %u)",GetEntry(),GetUInt32Value(ITEM_FIELD_DURATION),diff);
|
||||
//DEBUG_LOG("Item::UpdateDuration Item (Entry: %u Duration %u Diff %u)", GetEntry(), GetUInt32Value(ITEM_FIELD_DURATION), diff);
|
||||
|
||||
if (GetUInt32Value(ITEM_FIELD_DURATION)<=diff)
|
||||
if (GetUInt32Value(ITEM_FIELD_DURATION) <= diff)
|
||||
{
|
||||
owner->DestroyItem(GetBagSlot(), GetSlot(), true);
|
||||
return;
|
||||
|
|
@ -302,7 +302,7 @@ void Item::SaveToDB()
|
|||
stmt.PExecute(guid);
|
||||
|
||||
std::ostringstream ss;
|
||||
for(uint16 i = 0; i < m_valuesCount; ++i )
|
||||
for (uint16 i = 0; i < m_valuesCount; ++i)
|
||||
ss << GetUInt32Value(i) << " ";
|
||||
|
||||
stmt = CharacterDatabase.CreateStatement(insItem, "INSERT INTO item_instance (guid,owner_guid,data,text) VALUES (?, ?, ?, ?)");
|
||||
|
|
@ -316,7 +316,7 @@ void Item::SaveToDB()
|
|||
SqlStatement stmt = CharacterDatabase.CreateStatement(updInstance, "UPDATE item_instance SET data = ?, owner_guid = ?, text = ? WHERE guid = ?");
|
||||
|
||||
std::ostringstream ss;
|
||||
for(uint16 i = 0; i < m_valuesCount; ++i )
|
||||
for (uint16 i = 0; i < m_valuesCount; ++i)
|
||||
ss << GetUInt32Value(i) << " ";
|
||||
|
||||
stmt.PExecute(ss.str().c_str(), GetOwnerGuid().GetCounter(), m_text.c_str(), guid);
|
||||
|
|
@ -365,7 +365,7 @@ void Item::SaveToDB()
|
|||
|
||||
if (m_lootState == ITEM_LOOT_NEW || m_lootState == ITEM_LOOT_CHANGED)
|
||||
{
|
||||
if(Player* owner = GetOwner())
|
||||
if (Player* owner = GetOwner())
|
||||
{
|
||||
static SqlStatementID saveGold ;
|
||||
static SqlStatementID saveLoot ;
|
||||
|
|
@ -382,10 +382,10 @@ void Item::SaveToDB()
|
|||
// save items and quest items (at load its all will added as normal, but this not important for item loot case)
|
||||
for (size_t i = 0; i < loot.GetMaxSlotInLootFor(owner); ++i)
|
||||
{
|
||||
QuestItem *qitem = NULL;
|
||||
QuestItem* qitem = NULL;
|
||||
|
||||
LootItem *item = loot.LootItemInSlot(i,owner,&qitem);
|
||||
if(!item)
|
||||
LootItem* item = loot.LootItemInSlot(i, owner, &qitem);
|
||||
if (!item)
|
||||
continue;
|
||||
|
||||
// questitems use the blocked field for other purposes
|
||||
|
|
@ -411,7 +411,7 @@ void Item::SaveToDB()
|
|||
SetState(ITEM_UNCHANGED);
|
||||
}
|
||||
|
||||
bool Item::LoadFromDB(uint32 guidLow, Field *fields, ObjectGuid ownerGuid)
|
||||
bool Item::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid)
|
||||
{
|
||||
// create item before any checks for store correct guid
|
||||
// and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
|
||||
|
|
@ -436,23 +436,23 @@ bool Item::LoadFromDB(uint32 guidLow, Field *fields, ObjectGuid ownerGuid)
|
|||
}
|
||||
|
||||
ItemPrototype const* proto = GetProto();
|
||||
if(!proto)
|
||||
if (!proto)
|
||||
return false;
|
||||
|
||||
// update max durability (and durability) if need
|
||||
if(proto->MaxDurability!= GetUInt32Value(ITEM_FIELD_MAXDURABILITY))
|
||||
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_MAXDURABILITY, proto->MaxDurability);
|
||||
if (GetUInt32Value(ITEM_FIELD_DURABILITY) > proto->MaxDurability)
|
||||
SetUInt32Value(ITEM_FIELD_DURABILITY, proto->MaxDurability);
|
||||
|
||||
need_save = true;
|
||||
}
|
||||
|
||||
// recalculate suffix factor
|
||||
if(GetItemRandomPropertyId() < 0)
|
||||
if (GetItemRandomPropertyId() < 0)
|
||||
{
|
||||
if(UpdateItemSuffixFactor())
|
||||
if (UpdateItemSuffixFactor())
|
||||
need_save = true;
|
||||
}
|
||||
|
||||
|
|
@ -501,8 +501,8 @@ bool Item::LoadFromDB(uint32 guidLow, Field *fields, ObjectGuid ownerGuid)
|
|||
SqlStatement stmt = CharacterDatabase.CreateStatement(updItem, "UPDATE item_instance SET data = ?, owner_guid = ? WHERE guid = ?");
|
||||
|
||||
std::ostringstream ss;
|
||||
for(uint16 i = 0; i < m_valuesCount; ++i )
|
||||
ss << GetUInt32Value(i) << " ";
|
||||
for (uint16 i = 0; i < m_valuesCount; ++i)
|
||||
ss << GetUInt32Value(i) << "";
|
||||
|
||||
stmt.addString(ss);
|
||||
stmt.addUInt32(GetOwnerGuid().GetCounter());
|
||||
|
|
@ -513,7 +513,7 @@ bool Item::LoadFromDB(uint32 guidLow, Field *fields, ObjectGuid ownerGuid)
|
|||
return true;
|
||||
}
|
||||
|
||||
void Item::LoadLootFromDB(Field *fields)
|
||||
void Item::LoadLootFromDB(Field* fields)
|
||||
{
|
||||
uint32 item_id = fields[1].GetUInt32();
|
||||
uint32 item_amount = fields[2].GetUInt32();
|
||||
|
|
@ -531,7 +531,7 @@ void Item::LoadLootFromDB(Field *fields)
|
|||
// normal item case
|
||||
ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item_id);
|
||||
|
||||
if(!proto)
|
||||
if (!proto)
|
||||
{
|
||||
CharacterDatabase.PExecute("DELETE FROM item_loot WHERE guid = '%u' AND itemid = '%u'", GetGUIDLow(), item_id);
|
||||
sLog.outError("Item::LoadLootFromDB: %s has an unknown item (id: #%u) in item_loot, deleted.", GetOwnerGuid().GetString().c_str(), item_id);
|
||||
|
|
@ -560,7 +560,7 @@ void Item::DeleteFromInventoryDB()
|
|||
stmt.PExecute(GetGUIDLow());
|
||||
}
|
||||
|
||||
ItemPrototype const *Item::GetProto() const
|
||||
ItemPrototype const* Item::GetProto() const
|
||||
{
|
||||
return ObjectMgr::GetItemPrototype(GetEntry());
|
||||
}
|
||||
|
|
@ -583,7 +583,7 @@ uint32 Item::GetSkill()
|
|||
|
||||
const static uint32 item_armor_skills[MAX_ITEM_SUBCLASS_ARMOR] =
|
||||
{
|
||||
0,SKILL_CLOTH,SKILL_LEATHER,SKILL_MAIL,SKILL_PLATE_MAIL,0,SKILL_SHIELD,0,0,0,0
|
||||
0, SKILL_CLOTH, SKILL_LEATHER, SKILL_MAIL, SKILL_PLATE_MAIL, 0, SKILL_SHIELD, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
ItemPrototype const* proto = GetProto();
|
||||
|
|
@ -591,13 +591,13 @@ uint32 Item::GetSkill()
|
|||
switch (proto->Class)
|
||||
{
|
||||
case ITEM_CLASS_WEAPON:
|
||||
if( proto->SubClass >= MAX_ITEM_SUBCLASS_WEAPON )
|
||||
if (proto->SubClass >= MAX_ITEM_SUBCLASS_WEAPON)
|
||||
return 0;
|
||||
else
|
||||
return item_weapon_skills[proto->SubClass];
|
||||
|
||||
case ITEM_CLASS_ARMOR:
|
||||
if( proto->SubClass >= MAX_ITEM_SUBCLASS_ARMOR )
|
||||
if (proto->SubClass >= MAX_ITEM_SUBCLASS_ARMOR)
|
||||
return 0;
|
||||
else
|
||||
return item_armor_skills[proto->SubClass];
|
||||
|
|
@ -634,7 +634,7 @@ uint32 Item::GetSpell()
|
|||
default: return 0;
|
||||
}
|
||||
case ITEM_CLASS_ARMOR:
|
||||
switch(proto->SubClass)
|
||||
switch (proto->SubClass)
|
||||
{
|
||||
case ITEM_SUBCLASS_ARMOR_CLOTH: return 9078;
|
||||
case ITEM_SUBCLASS_ARMOR_LEATHER: return 9077;
|
||||
|
|
@ -649,43 +649,43 @@ uint32 Item::GetSpell()
|
|||
|
||||
int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
|
||||
{
|
||||
ItemPrototype const *itemProto = sItemStorage.LookupEntry<ItemPrototype>(item_id);
|
||||
ItemPrototype const* itemProto = sItemStorage.LookupEntry<ItemPrototype>(item_id);
|
||||
|
||||
if(!itemProto)
|
||||
if (!itemProto)
|
||||
return 0;
|
||||
|
||||
// item must have one from this field values not null if it can have random enchantments
|
||||
if((!itemProto->RandomProperty) && (!itemProto->RandomSuffix))
|
||||
if ((!itemProto->RandomProperty) && (!itemProto->RandomSuffix))
|
||||
return 0;
|
||||
|
||||
// item can have not null only one from field values
|
||||
if((itemProto->RandomProperty) && (itemProto->RandomSuffix))
|
||||
if ((itemProto->RandomProperty) && (itemProto->RandomSuffix))
|
||||
{
|
||||
sLog.outErrorDb("Item template %u have RandomProperty==%u and RandomSuffix==%u, but must have one from field =0",itemProto->ItemId,itemProto->RandomProperty,itemProto->RandomSuffix);
|
||||
sLog.outErrorDb("Item template %u have RandomProperty==%u and RandomSuffix==%u, but must have one from field =0", itemProto->ItemId, itemProto->RandomProperty, itemProto->RandomSuffix);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// RandomProperty case
|
||||
if(itemProto->RandomProperty)
|
||||
// Random Property case
|
||||
if (itemProto->RandomProperty)
|
||||
{
|
||||
uint32 randomPropId = GetItemEnchantMod(itemProto->RandomProperty);
|
||||
ItemRandomPropertiesEntry const *random_id = sItemRandomPropertiesStore.LookupEntry(randomPropId);
|
||||
if(!random_id)
|
||||
ItemRandomPropertiesEntry const* random_id = sItemRandomPropertiesStore.LookupEntry(randomPropId);
|
||||
if (!random_id)
|
||||
{
|
||||
sLog.outErrorDb("Enchantment id #%u used but it doesn't have records in 'ItemRandomProperties.dbc'",randomPropId);
|
||||
sLog.outErrorDb("Enchantment id #%u used but it doesn't have records in 'ItemRandomProperties.dbc'", randomPropId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return random_id->ID;
|
||||
}
|
||||
// RandomSuffix case
|
||||
// Random Suffix case
|
||||
else
|
||||
{
|
||||
uint32 randomPropId = GetItemEnchantMod(itemProto->RandomSuffix);
|
||||
ItemRandomSuffixEntry const *random_id = sItemRandomSuffixStore.LookupEntry(randomPropId);
|
||||
if(!random_id)
|
||||
ItemRandomSuffixEntry const* random_id = sItemRandomSuffixStore.LookupEntry(randomPropId);
|
||||
if (!random_id)
|
||||
{
|
||||
sLog.outErrorDb("Enchantment id #%u used but it doesn't have records in sItemRandomSuffixStore.",randomPropId);
|
||||
sLog.outErrorDb("Enchantment id #%u used but it doesn't have records in sItemRandomSuffixStore.", randomPropId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -695,38 +695,38 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
|
|||
|
||||
void Item::SetItemRandomProperties(int32 randomPropId)
|
||||
{
|
||||
if(!randomPropId)
|
||||
if (!randomPropId)
|
||||
return;
|
||||
|
||||
if(randomPropId > 0)
|
||||
if (randomPropId > 0)
|
||||
{
|
||||
ItemRandomPropertiesEntry const *item_rand = sItemRandomPropertiesStore.LookupEntry(randomPropId);
|
||||
if(item_rand)
|
||||
ItemRandomPropertiesEntry const* item_rand = sItemRandomPropertiesStore.LookupEntry(randomPropId);
|
||||
if (item_rand)
|
||||
{
|
||||
if(GetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID) != int32(item_rand->ID))
|
||||
if (GetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID) != int32(item_rand->ID))
|
||||
{
|
||||
SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID,item_rand->ID);
|
||||
SetState(ITEM_CHANGED);
|
||||
}
|
||||
for(uint32 i = PROP_ENCHANTMENT_SLOT_2; i < PROP_ENCHANTMENT_SLOT_2 + 3; ++i)
|
||||
SetEnchantment(EnchantmentSlot(i),item_rand->enchant_id[i - PROP_ENCHANTMENT_SLOT_2],0,0);
|
||||
for (uint32 i = PROP_ENCHANTMENT_SLOT_2; i < PROP_ENCHANTMENT_SLOT_2 + 3; ++i)
|
||||
SetEnchantment(EnchantmentSlot(i), item_rand->enchant_id[i - PROP_ENCHANTMENT_SLOT_2], 0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemRandomSuffixEntry const *item_rand = sItemRandomSuffixStore.LookupEntry(-randomPropId);
|
||||
if(item_rand)
|
||||
ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(-randomPropId);
|
||||
if (item_rand)
|
||||
{
|
||||
if( GetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID) != -int32(item_rand->ID) ||
|
||||
if (GetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID) != -int32(item_rand->ID) ||
|
||||
!GetItemSuffixFactor())
|
||||
{
|
||||
SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID,-int32(item_rand->ID));
|
||||
SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, -int32(item_rand->ID));
|
||||
UpdateItemSuffixFactor();
|
||||
SetState(ITEM_CHANGED);
|
||||
}
|
||||
|
||||
for(uint32 i = PROP_ENCHANTMENT_SLOT_0; i < PROP_ENCHANTMENT_SLOT_0 + 3; ++i)
|
||||
SetEnchantment(EnchantmentSlot(i),item_rand->enchant_id[i - PROP_ENCHANTMENT_SLOT_0],0,0);
|
||||
for (uint32 i = PROP_ENCHANTMENT_SLOT_0; i < PROP_ENCHANTMENT_SLOT_0 + 3; ++i)
|
||||
SetEnchantment(EnchantmentSlot(i), item_rand->enchant_id[i - PROP_ENCHANTMENT_SLOT_0], 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -734,13 +734,13 @@ void Item::SetItemRandomProperties(int32 randomPropId)
|
|||
bool Item::UpdateItemSuffixFactor()
|
||||
{
|
||||
uint32 suffixFactor = GenerateEnchSuffixFactor(GetEntry());
|
||||
if(GetItemSuffixFactor()==suffixFactor)
|
||||
if (GetItemSuffixFactor() == suffixFactor)
|
||||
return false;
|
||||
SetUInt32Value(ITEM_FIELD_PROPERTY_SEED,suffixFactor);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Item::SetState(ItemUpdateState state, Player *forplayer)
|
||||
void Item::SetState(ItemUpdateState state, Player* forplayer)
|
||||
{
|
||||
if (uState == ITEM_NEW && state == ITEM_REMOVED)
|
||||
{
|
||||
|
|
@ -765,7 +765,7 @@ void Item::SetState(ItemUpdateState state, Player *forplayer)
|
|||
}
|
||||
}
|
||||
|
||||
void Item::AddToUpdateQueueOf(Player *player)
|
||||
void Item::AddToUpdateQueueOf(Player* player)
|
||||
{
|
||||
if (IsInUpdateQueue())
|
||||
return;
|
||||
|
|
@ -792,10 +792,10 @@ void Item::AddToUpdateQueueOf(Player *player)
|
|||
return;
|
||||
|
||||
player->m_itemUpdateQueue.push_back(this);
|
||||
uQueuePos = player->m_itemUpdateQueue.size()-1;
|
||||
uQueuePos = player->m_itemUpdateQueue.size() -1;
|
||||
}
|
||||
|
||||
void Item::RemoveFromUpdateQueueOf(Player *player)
|
||||
void Item::RemoveFromUpdateQueueOf(Player* player)
|
||||
{
|
||||
if (!IsInUpdateQueue())
|
||||
return;
|
||||
|
|
@ -845,7 +845,7 @@ bool Item::CanBeTraded(bool mail) const
|
|||
|
||||
if (Player* owner = GetOwner())
|
||||
{
|
||||
if (owner->CanUnequipItem(GetPos(),false) != EQUIP_ERR_OK )
|
||||
if (owner->CanUnequipItem(GetPos(), false) != EQUIP_ERR_OK )
|
||||
return false;
|
||||
if (owner->GetLootGuid() == GetObjectGuid())
|
||||
return false;
|
||||
|
|
@ -863,17 +863,17 @@ bool Item::CanBeTraded(bool mail) const
|
|||
bool Item::IsBoundByEnchant() const
|
||||
{
|
||||
// Check all enchants for soulbound
|
||||
for(uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot)
|
||||
for (uint32 enchant_slot = PERM_ENCHANTMENT_SLOT; enchant_slot < MAX_ENCHANTMENT_SLOT; ++enchant_slot)
|
||||
{
|
||||
uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
|
||||
if(!enchant_id)
|
||||
if (!enchant_id)
|
||||
continue;
|
||||
|
||||
SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
|
||||
if(!enchantEntry)
|
||||
if (!enchantEntry)
|
||||
continue;
|
||||
|
||||
if(enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND)
|
||||
if (enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -896,12 +896,12 @@ bool Item::IsFitToSpellRequirements(SpellEntry const* spellInfo) const
|
|||
|
||||
if (spellInfo->EquippedItemClass != -1) // -1 == any item class
|
||||
{
|
||||
if(spellInfo->EquippedItemClass != int32(proto->Class))
|
||||
if (spellInfo->EquippedItemClass != int32(proto->Class))
|
||||
return false; // wrong item class
|
||||
|
||||
if(spellInfo->EquippedItemSubClassMask != 0) // 0 == any subclass
|
||||
if (spellInfo->EquippedItemSubClassMask != 0) // 0 == any subclass
|
||||
{
|
||||
if((spellInfo->EquippedItemSubClassMask & (1 << proto->SubClass)) == 0)
|
||||
if ((spellInfo->EquippedItemSubClassMask & (1 << proto->SubClass)) == 0)
|
||||
return false; // subclass not present in mask
|
||||
}
|
||||
}
|
||||
|
|
@ -909,9 +909,9 @@ bool Item::IsFitToSpellRequirements(SpellEntry const* spellInfo) const
|
|||
// Only check for item enchantments (TARGET_FLAG_ITEM), all other spells are either NPC spells
|
||||
// or spells where slot requirements are already handled with AttributesEx3 fields
|
||||
// and special code (Titan's Grip, Windfury Attack). Check clearly not applicable for Lava Lash.
|
||||
if(spellInfo->EquippedItemInventoryTypeMask != 0 && (spellInfo->Targets & TARGET_FLAG_ITEM)) // 0 == any inventory type
|
||||
if (spellInfo->EquippedItemInventoryTypeMask != 0 && (spellInfo->Targets & TARGET_FLAG_ITEM)) // 0 == any inventory type
|
||||
{
|
||||
if((spellInfo->EquippedItemInventoryTypeMask & (1 << proto->InventoryType)) == 0)
|
||||
if ((spellInfo->EquippedItemInventoryTypeMask & (1 << proto->InventoryType)) == 0)
|
||||
return false; // inventory type not present in mask
|
||||
}
|
||||
|
||||
|
|
@ -928,8 +928,8 @@ bool Item::IsTargetValidForItemUse(Unit* pUnitTarget)
|
|||
if (!pUnitTarget)
|
||||
return false;
|
||||
|
||||
for(ItemRequiredTargetMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
|
||||
if(itr->second.IsFitToRequirements(pUnitTarget))
|
||||
for (ItemRequiredTargetMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
|
||||
if (itr->second.IsFitToRequirements(pUnitTarget))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
@ -938,74 +938,74 @@ bool Item::IsTargetValidForItemUse(Unit* pUnitTarget)
|
|||
void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges)
|
||||
{
|
||||
// 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))
|
||||
if ((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges))
|
||||
return;
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET,id);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET,duration);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET,charges);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET, id);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET, duration);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET, charges);
|
||||
SetState(ITEM_CHANGED);
|
||||
}
|
||||
|
||||
void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration)
|
||||
{
|
||||
if(GetEnchantmentDuration(slot) == duration)
|
||||
if (GetEnchantmentDuration(slot) == duration)
|
||||
return;
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET,duration);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET, duration);
|
||||
SetState(ITEM_CHANGED);
|
||||
}
|
||||
|
||||
void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges)
|
||||
{
|
||||
if(GetEnchantmentCharges(slot) == charges)
|
||||
if (GetEnchantmentCharges(slot) == charges)
|
||||
return;
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET,charges);
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET, charges);
|
||||
SetState(ITEM_CHANGED);
|
||||
}
|
||||
|
||||
void Item::ClearEnchantment(EnchantmentSlot slot)
|
||||
{
|
||||
if(!GetEnchantmentId(slot))
|
||||
if (!GetEnchantmentId(slot))
|
||||
return;
|
||||
|
||||
for(uint8 x = 0; x < 3; ++x)
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + x, 0);
|
||||
for (uint8 x = 0; x < 3; ++x)
|
||||
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + x, 0);
|
||||
SetState(ITEM_CHANGED);
|
||||
}
|
||||
|
||||
bool Item::GemsFitSockets() const
|
||||
{
|
||||
bool fits = true;
|
||||
for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+MAX_GEM_SOCKETS; ++enchant_slot)
|
||||
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;
|
||||
|
||||
uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
|
||||
if(!enchant_id)
|
||||
if (!enchant_id)
|
||||
{
|
||||
if(SocketColor) fits &= false;
|
||||
if (SocketColor) fits &= false;
|
||||
continue;
|
||||
}
|
||||
|
||||
SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
|
||||
if(!enchantEntry)
|
||||
if (!enchantEntry)
|
||||
{
|
||||
if(SocketColor) fits &= false;
|
||||
if (SocketColor) fits &= false;
|
||||
continue;
|
||||
}
|
||||
|
||||
uint8 GemColor = 0;
|
||||
|
||||
uint32 gemid = enchantEntry->GemID;
|
||||
if(gemid)
|
||||
if (gemid)
|
||||
{
|
||||
ItemPrototype const* gemProto = sItemStorage.LookupEntry<ItemPrototype>(gemid);
|
||||
if(gemProto)
|
||||
if (gemProto)
|
||||
{
|
||||
GemPropertiesEntry const* gemProperty = sGemPropertiesStore.LookupEntry(gemProto->GemProperties);
|
||||
if(gemProperty)
|
||||
if (gemProperty)
|
||||
GemColor = gemProperty->color;
|
||||
}
|
||||
}
|
||||
|
|
@ -1018,17 +1018,17 @@ bool Item::GemsFitSockets() const
|
|||
uint8 Item::GetGemCountWithID(uint32 GemID) const
|
||||
{
|
||||
uint8 count = 0;
|
||||
for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+MAX_GEM_SOCKETS; ++enchant_slot)
|
||||
for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot)
|
||||
{
|
||||
uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
|
||||
if(!enchant_id)
|
||||
if (!enchant_id)
|
||||
continue;
|
||||
|
||||
SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
|
||||
if(!enchantEntry)
|
||||
if (!enchantEntry)
|
||||
continue;
|
||||
|
||||
if(GemID == enchantEntry->GemID)
|
||||
if (GemID == enchantEntry->GemID)
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
|
|
@ -1037,27 +1037,27 @@ uint8 Item::GetGemCountWithID(uint32 GemID) const
|
|||
uint8 Item::GetGemCountWithLimitCategory(uint32 limitCategory) const
|
||||
{
|
||||
uint8 count = 0;
|
||||
for(uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+MAX_GEM_SOCKETS; ++enchant_slot)
|
||||
for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot)
|
||||
{
|
||||
uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
|
||||
if(!enchant_id)
|
||||
if (!enchant_id)
|
||||
continue;
|
||||
|
||||
SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
|
||||
if(!enchantEntry)
|
||||
if (!enchantEntry)
|
||||
continue;
|
||||
|
||||
ItemPrototype const* gemProto = ObjectMgr::GetItemPrototype(enchantEntry->GemID);
|
||||
if(!gemProto)
|
||||
if (!gemProto)
|
||||
continue;
|
||||
|
||||
if(gemProto->ItemLimitCategory==limitCategory)
|
||||
if (gemProto->ItemLimitCategory == limitCategory)
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
bool Item::IsLimitedToAnotherMapOrZone( uint32 cur_mapId, uint32 cur_zoneId) const
|
||||
bool Item::IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) const
|
||||
{
|
||||
ItemPrototype const* proto = GetProto();
|
||||
return proto && ((proto->Map && proto->Map != cur_mapId) || (proto->Area && proto->Area != cur_zoneId));
|
||||
|
|
@ -1072,7 +1072,7 @@ void Item::SendTimeUpdate(Player* owner)
|
|||
if (!duration)
|
||||
return;
|
||||
|
||||
WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8+4));
|
||||
WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8 + 4));
|
||||
data << ObjectGuid(GetObjectGuid());
|
||||
data << uint32(duration);
|
||||
owner->GetSession()->SendPacket(&data);
|
||||
|
|
@ -1083,17 +1083,17 @@ Item* Item::CreateItem( uint32 item, uint32 count, Player const* player )
|
|||
if (count < 1)
|
||||
return NULL; //don't create item at zero count
|
||||
|
||||
if (ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(item))
|
||||
if (ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item))
|
||||
{
|
||||
if (count > pProto->GetMaxStackSize())
|
||||
count = pProto->GetMaxStackSize();
|
||||
|
||||
MANGOS_ASSERT(count !=0 && "pProto->Stackable==0 but checked at loading already");
|
||||
MANGOS_ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already");
|
||||
|
||||
Item *pItem = NewItemOrBag( pProto );
|
||||
if (pItem->Create(sObjectMgr.GenerateItemLowGuid(), item, player) )
|
||||
Item* pItem = NewItemOrBag(pProto);
|
||||
if (pItem->Create(sObjectMgr.GenerateItemLowGuid(), item, player))
|
||||
{
|
||||
pItem->SetCount( count );
|
||||
pItem->SetCount(count);
|
||||
return pItem;
|
||||
}
|
||||
else
|
||||
|
|
@ -1102,10 +1102,10 @@ Item* Item::CreateItem( uint32 item, uint32 count, Player const* player )
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Item* Item::CloneItem( uint32 count, Player const* player ) const
|
||||
Item* Item::CloneItem(uint32 count, Player const* player) const
|
||||
{
|
||||
Item* newItem = CreateItem( GetEntry(), count, player );
|
||||
if(!newItem)
|
||||
Item* newItem = CreateItem(GetEntry(), count, player);
|
||||
if (!newItem)
|
||||
return NULL;
|
||||
|
||||
newItem->SetGuidValue(ITEM_FIELD_CREATOR, GetGuidValue(ITEM_FIELD_CREATOR));
|
||||
|
|
@ -1116,7 +1116,7 @@ Item* Item::CloneItem( uint32 count, Player const* player ) const
|
|||
return newItem;
|
||||
}
|
||||
|
||||
bool Item::IsBindedNotWith( Player const* player ) const
|
||||
bool Item::IsBindedNotWith(Player const* player) const
|
||||
{
|
||||
// own item
|
||||
if (GetOwnerGuid() == player->GetObjectGuid())
|
||||
|
|
@ -1166,7 +1166,7 @@ void Item::BuildUpdateData(UpdateDataMapType& update_players)
|
|||
ClearUpdateMask(false);
|
||||
}
|
||||
|
||||
InventoryResult Item::CanBeMergedPartlyWith( ItemPrototype const* proto ) const
|
||||
InventoryResult Item::CanBeMergedPartlyWith(ItemPrototype const* proto) const
|
||||
{
|
||||
// check item type
|
||||
if (GetEntry() != proto->ItemId)
|
||||
|
|
@ -1183,15 +1183,15 @@ InventoryResult Item::CanBeMergedPartlyWith( ItemPrototype const* proto ) const
|
|||
return EQUIP_ERR_OK;
|
||||
}
|
||||
|
||||
bool ItemRequiredTarget::IsFitToRequirements( Unit* pUnitTarget ) const
|
||||
bool ItemRequiredTarget::IsFitToRequirements(Unit* pUnitTarget) const
|
||||
{
|
||||
if(pUnitTarget->GetTypeId() != TYPEID_UNIT)
|
||||
if (pUnitTarget->GetTypeId() != TYPEID_UNIT)
|
||||
return false;
|
||||
|
||||
if(pUnitTarget->GetEntry() != m_uiTargetEntry)
|
||||
if (pUnitTarget->GetEntry() != m_uiTargetEntry)
|
||||
return false;
|
||||
|
||||
switch(m_uiType)
|
||||
switch (m_uiType)
|
||||
{
|
||||
case ITEM_TARGET_TYPE_CREATURE:
|
||||
return pUnitTarget->isAlive();
|
||||
|
|
@ -1206,7 +1206,7 @@ bool Item::HasMaxCharges() const
|
|||
{
|
||||
ItemPrototype const* itemProto = GetProto();
|
||||
|
||||
for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||
for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||
if (GetSpellCharges(i) != itemProto->Spells[i].SpellCharges)
|
||||
return false;
|
||||
|
||||
|
|
@ -1217,7 +1217,7 @@ void Item::RestoreCharges()
|
|||
{
|
||||
ItemPrototype const* itemProto = GetProto();
|
||||
|
||||
for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||
for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||
{
|
||||
if (GetSpellCharges(i) != itemProto->Spells[i].SpellCharges)
|
||||
{
|
||||
|
|
@ -1227,12 +1227,12 @@ void Item::RestoreCharges()
|
|||
}
|
||||
}
|
||||
|
||||
void Item::SetLootState( ItemLootUpdateState state )
|
||||
void Item::SetLootState(ItemLootUpdateState state)
|
||||
{
|
||||
// ITEM_LOOT_NONE -> ITEM_LOOT_TEMPORARY -> ITEM_LOOT_NONE
|
||||
// ITEM_LOOT_NONE -> ITEM_LOOT_NEW -> ITEM_LOOT_NONE
|
||||
// ITEM_LOOT_NONE -> ITEM_LOOT_NEW -> ITEM_LOOT_UNCHANGED [<-> ITEM_LOOT_CHANGED] -> ITEM_LOOT_REMOVED -> ITEM_LOOT_NONE
|
||||
switch(state)
|
||||
switch (state)
|
||||
{
|
||||
case ITEM_LOOT_NONE:
|
||||
case ITEM_LOOT_NEW:
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ struct ItemSetEffect
|
|||
{
|
||||
uint32 setid;
|
||||
uint32 item_count;
|
||||
SpellEntry const *spells[8];
|
||||
SpellEntry const* spells[8];
|
||||
};
|
||||
|
||||
enum InventoryResult
|
||||
|
|
@ -273,16 +273,16 @@ bool ItemCanGoIntoBag(ItemPrototype const *proto, ItemPrototype const *pBagProto
|
|||
class MANGOS_DLL_SPEC Item : public Object
|
||||
{
|
||||
public:
|
||||
static Item* CreateItem( uint32 item, uint32 count, Player const* player = NULL );
|
||||
static Item* CreateItem(uint32 item, uint32 count, Player const* player = NULL);
|
||||
Item* CloneItem( uint32 count, Player const* player = NULL ) const;
|
||||
|
||||
Item ( );
|
||||
Item();
|
||||
|
||||
virtual bool Create( uint32 guidlow, uint32 itemid, Player const* owner);
|
||||
|
||||
ItemPrototype const* GetProto() const;
|
||||
|
||||
ObjectGuid const& GetOwnerGuid() const { return GetGuidValue(ITEM_FIELD_OWNER); }
|
||||
ObjectGuid const& GetOwnerGuid() const { return GetGuidValue(ITEM_FIELD_OWNER); }
|
||||
void SetOwnerGuid(ObjectGuid guid) { SetGuidValue(ITEM_FIELD_OWNER, guid); }
|
||||
Player* GetOwner()const;
|
||||
|
||||
|
|
@ -292,10 +292,10 @@ class MANGOS_DLL_SPEC Item : public Object
|
|||
bool IsBindedNotWith(Player const* player) const;
|
||||
bool IsBoundByEnchant() const;
|
||||
virtual void SaveToDB();
|
||||
virtual bool LoadFromDB(uint32 guidLow, Field *fields, ObjectGuid ownerGuid = ObjectGuid());
|
||||
virtual bool LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid = ObjectGuid());
|
||||
virtual void DeleteFromDB();
|
||||
void DeleteFromInventoryDB();
|
||||
void LoadLootFromDB(Field *fields);
|
||||
void LoadLootFromDB(Field* fields);
|
||||
|
||||
bool IsBag() const { return GetProto()->InventoryType == INVTYPE_BAG; }
|
||||
bool IsBroken() const { return GetUInt32Value(ITEM_FIELD_MAXDURABILITY) > 0 && GetUInt32Value(ITEM_FIELD_DURABILITY) == 0; }
|
||||
|
|
@ -305,7 +305,7 @@ class MANGOS_DLL_SPEC Item : public Object
|
|||
|
||||
bool IsFitToSpellRequirements(SpellEntry const* spellInfo) const;
|
||||
bool IsTargetValidForItemUse(Unit* pUnitTarget);
|
||||
bool IsLimitedToAnotherMapOrZone( uint32 cur_mapId, uint32 cur_zoneId) const;
|
||||
bool IsLimitedToAnotherMapOrZone(uint32 cur_mapId, uint32 cur_zoneId) const;
|
||||
bool GemsFitSockets() const;
|
||||
|
||||
uint32 GetCount() const { return GetUInt32Value (ITEM_FIELD_STACK_COUNT); }
|
||||
|
|
@ -316,7 +316,7 @@ class MANGOS_DLL_SPEC Item : public Object
|
|||
InventoryResult CanBeMergedPartlyWith(ItemPrototype const* proto) const;
|
||||
|
||||
uint8 GetSlot() const {return m_slot;}
|
||||
Bag *GetContainer() { return m_container; }
|
||||
Bag* GetContainer() { return m_container; }
|
||||
uint8 GetBagSlot() const;
|
||||
void SetSlot(uint8 slot) {m_slot = slot;}
|
||||
uint16 GetPos() const { return uint16(GetBagSlot()) << 8 | GetSlot(); }
|
||||
|
|
@ -338,9 +338,9 @@ class MANGOS_DLL_SPEC Item : public Object
|
|||
void SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration);
|
||||
void SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges);
|
||||
void ClearEnchantment(EnchantmentSlot slot);
|
||||
uint32 GetEnchantmentId(EnchantmentSlot slot) const { return GetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET);}
|
||||
uint32 GetEnchantmentDuration(EnchantmentSlot slot) const { return GetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET);}
|
||||
uint32 GetEnchantmentCharges(EnchantmentSlot slot) const { return GetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot*MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET);}
|
||||
uint32 GetEnchantmentId(EnchantmentSlot slot) const { return GetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_ID_OFFSET);}
|
||||
uint32 GetEnchantmentDuration(EnchantmentSlot slot) const { return GetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET);}
|
||||
uint32 GetEnchantmentCharges(EnchantmentSlot slot) const { return GetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET);}
|
||||
|
||||
std::string const& GetText() const { return m_text; }
|
||||
void SetText(std::string const& text) { m_text = text; }
|
||||
|
|
@ -350,7 +350,7 @@ class MANGOS_DLL_SPEC Item : public Object
|
|||
|
||||
// spell charges (signed but stored as unsigned)
|
||||
int32 GetSpellCharges(uint8 index/*0..5*/ = 0) const { return GetInt32Value(ITEM_FIELD_SPELL_CHARGES + index); }
|
||||
void SetSpellCharges(uint8 index/*0..5*/, int32 value) { SetInt32Value(ITEM_FIELD_SPELL_CHARGES + index,value); }
|
||||
void SetSpellCharges(uint8 index/*0..5*/, int32 value) { SetInt32Value(ITEM_FIELD_SPELL_CHARGES + index,value); }
|
||||
bool HasMaxCharges() const;
|
||||
void RestoreCharges();
|
||||
|
||||
|
|
@ -364,9 +364,9 @@ class MANGOS_DLL_SPEC Item : public Object
|
|||
|
||||
// Update States
|
||||
ItemUpdateState GetState() const { return uState; }
|
||||
void SetState(ItemUpdateState state, Player *forplayer = NULL);
|
||||
void AddToUpdateQueueOf(Player *player);
|
||||
void RemoveFromUpdateQueueOf(Player *player);
|
||||
void SetState(ItemUpdateState state, Player* forplayer = NULL);
|
||||
void AddToUpdateQueueOf(Player* player);
|
||||
void RemoveFromUpdateQueueOf(Player* player);
|
||||
bool IsInUpdateQueue() const { return uQueuePos != -1; }
|
||||
uint16 GetQueuePos() const { return uQueuePos; }
|
||||
void FSetState(ItemUpdateState state) // forced
|
||||
|
|
@ -385,7 +385,7 @@ class MANGOS_DLL_SPEC Item : public Object
|
|||
private:
|
||||
std::string m_text;
|
||||
uint8 m_slot;
|
||||
Bag *m_container;
|
||||
Bag* m_container;
|
||||
ItemUpdateState uState;
|
||||
int16 uQueuePos;
|
||||
bool mb_in_trade; // true if item is currently in trade-window
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11611"
|
||||
#define REVISION_NR "11612"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue