aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/Player.cpp86
1 files changed, 46 insertions, 40 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index c29c9abe065..ba86b6b5bec 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -9870,17 +9870,17 @@ uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bo
return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED;
uint8 eslot = FindEquipSlot( pProto, slot, swap );
- if( eslot == NULL_SLOT )
+ if (eslot == NULL_SLOT)
return EQUIP_ERR_ITEM_CANT_BE_EQUIPPED;
- uint8 msg = CanUseItem( pItem , not_loading );
- if( msg != EQUIP_ERR_OK )
+ uint8 msg = CanUseItem(pItem , not_loading);
+ if (msg != EQUIP_ERR_OK)
return msg;
- if( !swap && GetItemByPos( INVENTORY_SLOT_BAG_0, eslot ) )
+ if (!swap && GetItemByPos(INVENTORY_SLOT_BAG_0, eslot))
return EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE;
// if swap ignore item (equipped also)
- if(uint8 res2 = CanEquipUniqueItem(pItem, swap ? eslot : NULL_SLOT))
+ if (uint8 res2 = CanEquipUniqueItem(pItem, swap ? eslot : NULL_SLOT))
return res2;
// check unique-equipped special item classes
@@ -9888,19 +9888,16 @@ uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bo
{
for(int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
{
- if( Item* pBag = GetItemByPos( INVENTORY_SLOT_BAG_0, i ) )
+ if (Item* pBag = GetItemByPos(INVENTORY_SLOT_BAG_0, i))
{
- if( pBag != pItem )
+ if (pBag != pItem)
{
- if( ItemPrototype const* pBagProto = pBag->GetProto() )
+ if (ItemPrototype const* pBagProto = pBag->GetProto())
{
- if( pBagProto->Class==pProto->Class && (!swap || pBag->GetSlot() != eslot ) )
- {
- if(pBagProto->SubClass == ITEM_SUBCLASS_AMMO_POUCH)
- return EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH;
- else
- return EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER;
- }
+ if (pBagProto->Class==pProto->Class && (!swap || pBag->GetSlot() != eslot))
+ return (pBagProto->SubClass == ITEM_SUBCLASS_AMMO_POUCH)
+ ? EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH
+ : EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER;
}
}
}
@@ -9909,25 +9906,25 @@ uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bo
uint32 type = pProto->InventoryType;
- if(eslot == EQUIPMENT_SLOT_OFFHAND)
+ if (eslot == EQUIPMENT_SLOT_OFFHAND)
{
if (type == INVTYPE_WEAPON || type == INVTYPE_WEAPONOFFHAND)
{
- if(!CanDualWield())
+ if (!CanDualWield())
return EQUIP_ERR_CANT_DUAL_WIELD;
}
else if (type == INVTYPE_2HWEAPON)
{
- if(!CanDualWield() || !CanTitanGrip())
+ if (!CanDualWield() || !CanTitanGrip())
return EQUIP_ERR_CANT_DUAL_WIELD;
}
- if(IsTwoHandUsed())
+ if (IsTwoHandUsed())
return EQUIP_ERR_CANT_EQUIP_WITH_TWOHANDED;
}
// equip two-hand weapon case (with possible unequip 2 items)
- if( type == INVTYPE_2HWEAPON )
+ if (type == INVTYPE_2HWEAPON)
{
if (eslot == EQUIPMENT_SLOT_OFFHAND)
{
@@ -9942,9 +9939,9 @@ uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bo
// offhand item must can be stored in inventory for offhand item and it also must be unequipped
Item *offItem = GetItemByPos( INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND );
ItemPosCountVec off_dest;
- if( offItem && (!not_loading ||
+ if (offItem && (!not_loading ||
CanUnequipItem(uint16(INVENTORY_SLOT_BAG_0) << 8 | EQUIPMENT_SLOT_OFFHAND,false) != EQUIP_ERR_OK ||
- CanStoreItem( NULL_BAG, NULL_SLOT, off_dest, offItem, false ) != EQUIP_ERR_OK ) )
+ CanStoreItem( NULL_BAG, NULL_SLOT, off_dest, offItem, false ) != EQUIP_ERR_OK ))
return swap ? EQUIP_ERR_ITEMS_CANT_BE_SWAPPED : EQUIP_ERR_INVENTORY_FULL;
}
}
@@ -9952,10 +9949,8 @@ uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bo
return EQUIP_ERR_OK;
}
}
- if( !swap )
- return EQUIP_ERR_ITEM_NOT_FOUND;
- else
- return EQUIP_ERR_ITEMS_CANT_BE_SWAPPED;
+
+ return !swap ? EQUIP_ERR_ITEM_NOT_FOUND : EQUIP_ERR_ITEMS_CANT_BE_SWAPPED;
}
uint8 Player::CanUnequipItem( uint16 pos, bool swap ) const
@@ -10174,38 +10169,49 @@ uint8 Player::CanBankItem( uint8 bag, uint8 slot, ItemPosCountVec &dest, Item *p
uint8 Player::CanUseItem( Item *pItem, bool not_loading ) const
{
- if( pItem )
+ if (pItem)
{
sLog.outDebug( "STORAGE: CanUseItem item = %u", pItem->GetEntry());
- if( !isAlive() && not_loading )
+
+ if (!isAlive() && not_loading)
return EQUIP_ERR_YOU_ARE_DEAD;
- //if( isStunned() )
+
+ //if (isStunned())
// return EQUIP_ERR_YOU_ARE_STUNNED;
+
ItemPrototype const *pProto = pItem->GetProto();
- if( pProto )
+ if (pProto)
{
- if( pItem->IsBindedNotWith(GetGUID()) )
+ if (pItem->IsBindedNotWith(GetGUID()))
return EQUIP_ERR_DONT_OWN_THAT_ITEM;
- if( (pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0 )
+
+ if ((pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0)
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
- if( pItem->GetSkill() != 0 )
+
+ if (pItem->GetSkill() != 0)
{
- if( GetSkillValue( pItem->GetSkill() ) == 0 )
+ if (GetSkillValue( pItem->GetSkill() ) == 0)
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
}
- if( pProto->RequiredSkill != 0 )
+
+ if (pProto->RequiredSkill != 0)
{
- if( GetSkillValue( pProto->RequiredSkill ) == 0 )
+ if (GetSkillValue( pProto->RequiredSkill ) == 0)
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
- else if( GetSkillValue( pProto->RequiredSkill ) < pProto->RequiredSkillRank )
+
+ if (GetSkillValue( pProto->RequiredSkill ) < pProto->RequiredSkillRank)
return EQUIP_ERR_ERR_CANT_EQUIP_SKILL;
}
- if( pProto->RequiredSpell != 0 && !HasSpell( pProto->RequiredSpell ) )
+
+ if (pProto->RequiredSpell != 0 && !HasSpell(pProto->RequiredSpell))
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
- if( pProto->RequiredReputationFaction && uint32(GetReputationRank(pProto->RequiredReputationFaction)) < pProto->RequiredReputationRank )
+
+ if (pProto->RequiredReputationFaction && uint32(GetReputationRank(pProto->RequiredReputationFaction)) < pProto->RequiredReputationRank)
return EQUIP_ERR_CANT_EQUIP_REPUTATION;
- if( getLevel() < pProto->RequiredLevel )
+
+ if (getLevel() < pProto->RequiredLevel)
return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
+
return EQUIP_ERR_OK;
}
}