mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 19: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 (ItemPrototype const* pBagProto = pBag->GetProto())
|
||||||
{
|
{
|
||||||
if (pBagProto->Class==pProto->Class && (!swap || pBag->GetSlot() != eslot))
|
if (pBagProto->Class==pProto->Class && (!swap || pBag->GetSlot() != eslot))
|
||||||
{
|
return (pBagProto->SubClass == ITEM_SUBCLASS_AMMO_POUCH)
|
||||||
if(pBagProto->SubClass == ITEM_SUBCLASS_AMMO_POUCH)
|
? EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH
|
||||||
return EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH;
|
: EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER;
|
||||||
else
|
|
||||||
return 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;
|
return EQUIP_ERR_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( !swap )
|
|
||||||
return EQUIP_ERR_ITEM_NOT_FOUND;
|
return !swap ? EQUIP_ERR_ITEM_NOT_FOUND : EQUIP_ERR_ITEMS_CANT_BE_SWAPPED;
|
||||||
else
|
|
||||||
return EQUIP_ERR_ITEMS_CANT_BE_SWAPPED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 Player::CanUnequipItem( uint16 pos, bool swap ) const
|
uint8 Player::CanUnequipItem( uint16 pos, bool swap ) const
|
||||||
|
|
@ -9899,35 +9894,46 @@ uint8 Player::CanUseItem( Item *pItem, bool not_loading ) const
|
||||||
if (pItem)
|
if (pItem)
|
||||||
{
|
{
|
||||||
sLog.outDebug( "STORAGE: CanUseItem item = %u", pItem->GetEntry());
|
sLog.outDebug( "STORAGE: CanUseItem item = %u", pItem->GetEntry());
|
||||||
|
|
||||||
if (!isAlive() && not_loading)
|
if (!isAlive() && not_loading)
|
||||||
return EQUIP_ERR_YOU_ARE_DEAD;
|
return EQUIP_ERR_YOU_ARE_DEAD;
|
||||||
|
|
||||||
//if (isStunned())
|
//if (isStunned())
|
||||||
// return EQUIP_ERR_YOU_ARE_STUNNED;
|
// return EQUIP_ERR_YOU_ARE_STUNNED;
|
||||||
|
|
||||||
ItemPrototype const *pProto = pItem->GetProto();
|
ItemPrototype const *pProto = pItem->GetProto();
|
||||||
if (pProto)
|
if (pProto)
|
||||||
{
|
{
|
||||||
if (pItem->IsBindedNotWith(GetGUID()))
|
if (pItem->IsBindedNotWith(GetGUID()))
|
||||||
return EQUIP_ERR_DONT_OWN_THAT_ITEM;
|
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;
|
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;
|
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;
|
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;
|
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;
|
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;
|
return EQUIP_ERR_CANT_EQUIP_REPUTATION;
|
||||||
|
|
||||||
if (getLevel() < pProto->RequiredLevel)
|
if (getLevel() < pProto->RequiredLevel)
|
||||||
return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
|
return EQUIP_ERR_CANT_EQUIP_LEVEL_I;
|
||||||
|
|
||||||
return EQUIP_ERR_OK;
|
return EQUIP_ERR_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue