mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 17:54:48 +01:00
Minor code style cleanup
--HG-- branch : trunk
This commit is contained in:
@@ -34,27 +34,27 @@ void AddItemsSetItem(Player*player,Item *item)
|
||||
|
||||
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);
|
||||
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;
|
||||
|
||||
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));
|
||||
@@ -62,10 +62,10 @@ void AddItemsSetItem(Player*player,Item *item)
|
||||
|
||||
size_t x = 0;
|
||||
for (; x < player->ItemSetEff.size(); x++)
|
||||
if(!player->ItemSetEff[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);
|
||||
@@ -75,27 +75,27 @@ void AddItemsSetItem(Player*player,Item *item)
|
||||
|
||||
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)
|
||||
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])
|
||||
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++)
|
||||
{
|
||||
if(!eff->spells[y]) // free slot
|
||||
if (!eff->spells[y]) // free slot
|
||||
{
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(set->spells[x]);
|
||||
if(!spellInfo)
|
||||
if (!spellInfo)
|
||||
{
|
||||
sLog.outError("WORLD: unknown spell id %u in items set %u effects", set->spells[x],setid);
|
||||
break;
|
||||
@@ -116,7 +116,7 @@ void RemoveItemsSetItem(Player*player,ItemPrototype const *proto)
|
||||
|
||||
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);
|
||||
return;
|
||||
@@ -126,7 +126,7 @@ void RemoveItemsSetItem(Player*player,ItemPrototype const *proto)
|
||||
size_t setindex = 0;
|
||||
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;
|
||||
@@ -134,23 +134,23 @@ 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++)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
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);
|
||||
@@ -160,7 +160,7 @@ void RemoveItemsSetItem(Player*player,ItemPrototype const *proto)
|
||||
}
|
||||
}
|
||||
|
||||
if(!eff->item_count) //all items of a set were removed
|
||||
if (!eff->item_count) //all items of a set were removed
|
||||
{
|
||||
assert(eff == player->ItemSetEff[setindex]);
|
||||
delete eff;
|
||||
@@ -170,7 +170,7 @@ void RemoveItemsSetItem(Player*player,ItemPrototype const *proto)
|
||||
|
||||
bool ItemCanGoIntoBag(ItemPrototype const *pProto, ItemPrototype const *pBagProto)
|
||||
{
|
||||
if(!pProto || !pBagProto)
|
||||
if (!pProto || !pBagProto)
|
||||
return false;
|
||||
|
||||
switch(pBagProto->Class)
|
||||
@@ -181,35 +181,35 @@ bool ItemCanGoIntoBag(ItemPrototype const *pProto, ItemPrototype const *pBagProt
|
||||
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:
|
||||
@@ -219,11 +219,11 @@ bool ItemCanGoIntoBag(ItemPrototype const *pProto, ItemPrototype const *pBagProt
|
||||
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:
|
||||
@@ -260,7 +260,7 @@ bool Item::Create( uint32 guidlow, uint32 itemid, Player const* owner)
|
||||
SetUInt64Value(ITEM_FIELD_CONTAINED, owner ? owner->GetGUID() : 0);
|
||||
|
||||
ItemPrototype const *itemProto = objmgr.GetItemPrototype(itemid);
|
||||
if(!itemProto)
|
||||
if (!itemProto)
|
||||
return false;
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1);
|
||||
@@ -300,33 +300,37 @@ void Item::SaveToDB()
|
||||
switch (uState)
|
||||
{
|
||||
case ITEM_NEW:
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "REPLACE INTO item_instance (guid,owner_guid,data) VALUES (" << guid << "," << GUID_LOPART(GetOwnerGUID()) << ",'";
|
||||
for (uint16 i = 0; i < m_valuesCount; ++i )
|
||||
for (uint16 i = 0; i < m_valuesCount; ++i)
|
||||
ss << GetUInt32Value(i) << " ";
|
||||
ss << "' )";
|
||||
CharacterDatabase.Execute(ss.str().c_str());
|
||||
break;
|
||||
}break;
|
||||
case ITEM_CHANGED:
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "UPDATE item_instance SET data = '";
|
||||
for (uint16 i = 0; i < m_valuesCount; ++i )
|
||||
for (uint16 i = 0; i < m_valuesCount; ++i)
|
||||
ss << GetUInt32Value(i) << " ";
|
||||
ss << "', owner_guid = '" << GUID_LOPART(GetOwnerGUID()) << "' WHERE guid = '" << guid << "'";
|
||||
|
||||
CharacterDatabase.Execute( ss.str().c_str() );
|
||||
|
||||
if(HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))
|
||||
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))
|
||||
CharacterDatabase.PExecute("UPDATE character_gifts SET guid = '%u' WHERE item_guid = '%u'", GUID_LOPART(GetOwnerGUID()),GetGUIDLow());
|
||||
break;
|
||||
}break;
|
||||
case ITEM_REMOVED:
|
||||
if (GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID) > 0 )
|
||||
{
|
||||
if (GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID) > 0)
|
||||
CharacterDatabase.PExecute("DELETE FROM item_text WHERE id = '%u'", GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID));
|
||||
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", guid);
|
||||
if(HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))
|
||||
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))
|
||||
CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", GetGUIDLow());
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
case ITEM_UNCHANGED:
|
||||
break;
|
||||
}
|
||||
@@ -339,7 +343,7 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult_AutoPtr result
|
||||
// and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
|
||||
Object::_Create(guid, 0, HIGHGUID_ITEM);
|
||||
|
||||
if(!result)
|
||||
if (!result)
|
||||
result = CharacterDatabase.PQuery("SELECT data FROM item_instance WHERE guid = '%u'", guid);
|
||||
|
||||
if (!result)
|
||||
@@ -350,7 +354,7 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult_AutoPtr result
|
||||
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
if(!LoadValues(fields[0].GetString()))
|
||||
if (!LoadValues(fields[0].GetString()))
|
||||
{
|
||||
sLog.outError("Item #%d have broken data in `data` field. Can't be loaded.",guid);
|
||||
return false;
|
||||
@@ -360,30 +364,30 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult_AutoPtr result
|
||||
|
||||
// overwrite possible wrong/corrupted guid
|
||||
uint64 new_item_guid = MAKE_NEW_GUID(guid,0, HIGHGUID_ITEM);
|
||||
if(GetUInt64Value(OBJECT_FIELD_GUID) != new_item_guid)
|
||||
if (GetUInt64Value(OBJECT_FIELD_GUID) != new_item_guid)
|
||||
{
|
||||
SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid,0, HIGHGUID_ITEM));
|
||||
need_save = true;
|
||||
}
|
||||
|
||||
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)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -395,28 +399,28 @@ bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult_AutoPtr result
|
||||
}
|
||||
|
||||
// update duration if need, and remove if not need
|
||||
if((proto->Duration==0) != (GetUInt32Value(ITEM_FIELD_DURATION)==0))
|
||||
if ((proto->Duration==0) != (GetUInt32Value(ITEM_FIELD_DURATION)==0))
|
||||
{
|
||||
SetUInt32Value(ITEM_FIELD_DURATION,abs(proto->Duration));
|
||||
need_save = true;
|
||||
}
|
||||
|
||||
// set correct owner
|
||||
if(owner_guid != 0 && GetOwnerGUID() != owner_guid)
|
||||
if (owner_guid != 0 && GetOwnerGUID() != owner_guid)
|
||||
{
|
||||
SetOwnerGUID(owner_guid);
|
||||
need_save = true;
|
||||
}
|
||||
|
||||
if(need_save) // normal item changed state set not work at loading
|
||||
if (need_save) // normal item changed state set not work at loading
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "UPDATE item_instance SET data = '";
|
||||
for (uint16 i = 0; i < m_valuesCount; ++i )
|
||||
for (uint16 i = 0; i < m_valuesCount; ++i)
|
||||
ss << GetUInt32Value(i) << " ";
|
||||
ss << "', owner_guid = '" << GUID_LOPART(GetOwnerGUID()) << "' WHERE guid = '" << guid << "'";
|
||||
|
||||
CharacterDatabase.Execute( ss.str().c_str() );
|
||||
CharacterDatabase.Execute(ss.str().c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -463,13 +467,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];
|
||||
@@ -506,7 +510,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;
|
||||
@@ -523,26 +527,26 @@ int32 Item::GenerateItemRandomPropertyId(uint32 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);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// RandomProperty case
|
||||
if(itemProto->RandomProperty)
|
||||
if (itemProto->RandomProperty)
|
||||
{
|
||||
int32 randomPropId = GetItemEnchantMod(itemProto->RandomProperty);
|
||||
ItemRandomPropertiesEntry const *random_id = sItemRandomPropertiesStore.LookupEntry(randomPropId);
|
||||
if(!random_id)
|
||||
if (!random_id)
|
||||
{
|
||||
sLog.outErrorDb("Enchantment id #%u used but it doesn't have records in 'ItemRandomProperties.dbc'",randomPropId);
|
||||
return 0;
|
||||
@@ -555,7 +559,7 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
|
||||
{
|
||||
uint32 randomPropId = GetItemEnchantMod(itemProto->RandomSuffix);
|
||||
ItemRandomSuffixEntry const *random_id = sItemRandomSuffixStore.LookupEntry(randomPropId);
|
||||
if(!random_id)
|
||||
if (!random_id)
|
||||
{
|
||||
sLog.outErrorDb("Enchantment id #%u used but it doesn't have records in sItemRandomSuffixStore.",randomPropId);
|
||||
return 0;
|
||||
@@ -567,15 +571,15 @@ 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)
|
||||
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);
|
||||
@@ -587,9 +591,9 @@ void Item::SetItemRandomProperties(int32 randomPropId)
|
||||
else
|
||||
{
|
||||
ItemRandomSuffixEntry const *item_rand = sItemRandomSuffixStore.LookupEntry(-randomPropId);
|
||||
if(item_rand)
|
||||
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));
|
||||
@@ -606,7 +610,7 @@ 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;
|
||||
@@ -704,12 +708,12 @@ bool Item::CanBeTraded(bool mail) const
|
||||
if ((!mail || !IsBoundAccountWide()) && IsSoulBound())
|
||||
return false;
|
||||
|
||||
if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty()) )
|
||||
if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty()))
|
||||
return false;
|
||||
|
||||
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()==GetGUID())
|
||||
return false;
|
||||
@@ -769,25 +773,25 @@ bool Item::IsFitToSpellRequirements(SpellEntry const* spellInfo) const
|
||||
if (spellInfo->EquippedItemClass != -1) // -1 == any item class
|
||||
{
|
||||
// Special case - accept vellum for armor/weapon requirements
|
||||
if( (spellInfo->EquippedItemClass==ITEM_CLASS_ARMOR && proto->IsArmorVellum())
|
||||
if ((spellInfo->EquippedItemClass==ITEM_CLASS_ARMOR && proto->IsArmorVellum())
|
||||
||( spellInfo->EquippedItemClass==ITEM_CLASS_WEAPON && proto->IsWeaponVellum()))
|
||||
if (spellmgr.IsSkillTypeSpell(spellInfo->Id, SKILL_ENCHANTING)) // only for enchanting spells
|
||||
return true;
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
if(spellInfo->EquippedItemInventoryTypeMask != 0) // 0 == any inventory type
|
||||
if (spellInfo->EquippedItemInventoryTypeMask != 0) // 0 == any inventory type
|
||||
{
|
||||
// Special case - accept weapon type for main and offhand requirements
|
||||
if(proto->InventoryType == INVTYPE_WEAPON &&
|
||||
if (proto->InventoryType == INVTYPE_WEAPON &&
|
||||
(spellInfo->EquippedItemInventoryTypeMask & (1 << INVTYPE_WEAPONMAINHAND) ||
|
||||
spellInfo->EquippedItemInventoryTypeMask & (1 << INVTYPE_WEAPONOFFHAND)))
|
||||
return true;
|
||||
@@ -809,7 +813,7 @@ bool Item::IsTargetValidForItemUse(Unit* pUnitTarget)
|
||||
return false;
|
||||
|
||||
for (ItemRequiredTargetMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
|
||||
if(itr->second.IsFitToRequirements(pUnitTarget))
|
||||
if (itr->second.IsFitToRequirements(pUnitTarget))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -818,7 +822,7 @@ 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);
|
||||
@@ -829,7 +833,7 @@ void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint
|
||||
|
||||
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);
|
||||
@@ -838,7 +842,7 @@ void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration)
|
||||
|
||||
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);
|
||||
@@ -847,7 +851,7 @@ void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges)
|
||||
|
||||
void Item::ClearEnchantment(EnchantmentSlot slot)
|
||||
{
|
||||
if(!GetEnchantmentId(slot))
|
||||
if (!GetEnchantmentId(slot))
|
||||
return;
|
||||
|
||||
for (uint8 x = 0; x < 3; ++x)
|
||||
@@ -863,29 +867,29 @@ bool Item::GemsFitSockets() const
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -901,14 +905,14 @@ uint8 Item::GetGemCountWithID(uint32 GemID) const
|
||||
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;
|
||||
@@ -920,18 +924,18 @@ uint8 Item::GetGemCountWithLimitCategory(uint32 limitCategory) const
|
||||
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;
|
||||
@@ -940,7 +944,7 @@ uint8 Item::GetGemCountWithLimitCategory(uint32 limitCategory) 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 );
|
||||
return proto && (proto->Map && proto->Map != cur_mapId || proto->Area && proto->Area != cur_zoneId);
|
||||
}
|
||||
|
||||
// Though the client has the information in the item's data field,
|
||||
@@ -959,19 +963,19 @@ void Item::SendTimeUpdate(Player* owner)
|
||||
|
||||
Item* Item::CreateItem( uint32 item, uint32 count, Player const* player )
|
||||
{
|
||||
if ( count < 1 )
|
||||
if (count < 1)
|
||||
return NULL; //don't create item at zero count
|
||||
|
||||
ItemPrototype const *pProto = objmgr.GetItemPrototype( item );
|
||||
if( pProto )
|
||||
if (pProto)
|
||||
{
|
||||
if ( count > pProto->GetMaxStackSize())
|
||||
if (count > pProto->GetMaxStackSize())
|
||||
count = pProto->GetMaxStackSize();
|
||||
|
||||
assert(count !=0 && "pProto->Stackable==0 but checked at loading already");
|
||||
|
||||
Item *pItem = NewItemOrBag( pProto );
|
||||
if( pItem->Create(objmgr.GenerateLowGuid(HIGHGUID_ITEM), item, player) )
|
||||
if (pItem->Create(objmgr.GenerateLowGuid(HIGHGUID_ITEM), item, player))
|
||||
{
|
||||
pItem->SetCount( count );
|
||||
return pItem;
|
||||
@@ -987,7 +991,7 @@ Item* Item::CreateItem( uint32 item, uint32 count, Player const* player )
|
||||
Item* Item::CloneItem( uint32 count, Player const* player ) const
|
||||
{
|
||||
Item* newItem = CreateItem( GetEntry(), count, player );
|
||||
if(!newItem)
|
||||
if (!newItem)
|
||||
return NULL;
|
||||
|
||||
newItem->SetUInt32Value( ITEM_FIELD_CREATOR, GetUInt32Value( ITEM_FIELD_CREATOR ) );
|
||||
@@ -1001,19 +1005,19 @@ Item* Item::CloneItem( uint32 count, Player const* player ) const
|
||||
bool Item::IsBindedNotWith( Player const* player ) const
|
||||
{
|
||||
// not binded item
|
||||
if(!IsSoulBound())
|
||||
if (!IsSoulBound())
|
||||
return false;
|
||||
|
||||
// own item
|
||||
if(GetOwnerGUID()== player->GetGUID())
|
||||
if (GetOwnerGUID()== player->GetGUID())
|
||||
return false;
|
||||
|
||||
// not BOA item case
|
||||
if(!IsBoundAccountWide())
|
||||
if (!IsBoundAccountWide())
|
||||
return true;
|
||||
|
||||
// online
|
||||
if(Player* owner = objmgr.GetPlayer(GetOwnerGUID()))
|
||||
if (Player* owner = objmgr.GetPlayer(GetOwnerGUID()))
|
||||
{
|
||||
return owner->GetSession()->GetAccountId() != player->GetSession()->GetAccountId();
|
||||
}
|
||||
@@ -1026,10 +1030,10 @@ bool Item::IsBindedNotWith( Player const* player ) 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)
|
||||
@@ -1045,7 +1049,7 @@ bool ItemRequiredTarget::IsFitToRequirements( Unit* pUnitTarget ) const
|
||||
|
||||
void Item::BuildUpdate(UpdateDataMapType& data_map)
|
||||
{
|
||||
if(Player *owner = GetOwner())
|
||||
if (Player *owner = GetOwner())
|
||||
BuildFieldsUpdate(owner, data_map);
|
||||
ClearUpdateMask(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user