mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
Code style and cleanups in item equip checks.
This commit is contained in:
parent
bfe2e187a6
commit
167e8c86f6
1 changed files with 46 additions and 40 deletions
|
|
@ -9617,12 +9617,9 @@ uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bo
|
|||
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;
|
||||
}
|
||||
return (pBagProto->SubClass == ITEM_SUBCLASS_AMMO_POUCH)
|
||||
? EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH
|
||||
: EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9674,10 +9671,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
|
||||
|
|
@ -9899,35 +9894,46 @@ uint8 Player::CanUseItem( Item *pItem, bool not_loading ) const
|
|||
if (pItem)
|
||||
{
|
||||
sLog.outDebug( "STORAGE: CanUseItem item = %u", pItem->GetEntry());
|
||||
|
||||
if (!isAlive() && not_loading)
|
||||
return EQUIP_ERR_YOU_ARE_DEAD;
|
||||
|
||||
//if (isStunned())
|
||||
// return EQUIP_ERR_YOU_ARE_STUNNED;
|
||||
|
||||
ItemPrototype const *pProto = pItem->GetProto();
|
||||
if (pProto)
|
||||
{
|
||||
if (pItem->IsBindedNotWith(GetGUID()))
|
||||
return EQUIP_ERR_DONT_OWN_THAT_ITEM;
|
||||
|
||||
if ((pProto->AllowableClass & getClassMask()) == 0 || (pProto->AllowableRace & getRaceMask()) == 0)
|
||||
return EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM;
|
||||
|
||||
if (pItem->GetSkill() != 0)
|
||||
{
|
||||
if (GetSkillValue( pItem->GetSkill() ) == 0)
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
}
|
||||
|
||||
if (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))
|
||||
return EQUIP_ERR_NO_REQUIRED_PROFICIENCY;
|
||||
|
||||
if (pProto->RequiredReputationFaction && uint32(GetReputationRank(pProto->RequiredReputationFaction)) < pProto->RequiredReputationRank)
|
||||
return EQUIP_ERR_CANT_EQUIP_REPUTATION;
|
||||
|
||||
if (getLevel() < pProto->RequiredLevel)
|
||||
return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
|
||||
|
||||
return EQUIP_ERR_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue