mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-24 08:09:43 +00:00
Code cleanup for Class::canBeEquipped
This commit is contained in:
parent
79a440e94a
commit
b8ac37347c
3 changed files with 45 additions and 72 deletions
|
@ -294,11 +294,10 @@ namespace MWClass
|
||||||
// slots that this item can be equipped in
|
// slots that this item can be equipped in
|
||||||
std::pair<std::vector<int>, bool> slots_ = MWWorld::Class::get(ptr).getEquipmentSlots(ptr);
|
std::pair<std::vector<int>, bool> slots_ = MWWorld::Class::get(ptr).getEquipmentSlots(ptr);
|
||||||
|
|
||||||
std::string npcRace = npc.get<ESM::NPC>()->mBase->mRace;
|
if (slots_.first.empty())
|
||||||
|
return std::make_pair(0, "");
|
||||||
|
|
||||||
for (std::vector<int>::const_iterator slot=slots_.first.begin();
|
std::string npcRace = npc.get<ESM::NPC>()->mBase->mRace;
|
||||||
slot!=slots_.first.end(); ++slot)
|
|
||||||
{
|
|
||||||
|
|
||||||
// Beast races cannot equip shoes / boots, or full helms (head part vs hair part)
|
// Beast races cannot equip shoes / boots, or full helms (head part vs hair part)
|
||||||
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npcRace);
|
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npcRace);
|
||||||
|
@ -306,29 +305,19 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
std::vector<ESM::PartReference> parts = ptr.get<ESM::Armor>()->mBase->mParts.mParts;
|
std::vector<ESM::PartReference> parts = ptr.get<ESM::Armor>()->mBase->mParts.mParts;
|
||||||
|
|
||||||
if(*slot == MWWorld::InventoryStore::Slot_Helmet)
|
|
||||||
{
|
|
||||||
for(std::vector<ESM::PartReference>::iterator itr = parts.begin(); itr != parts.end(); ++itr)
|
for(std::vector<ESM::PartReference>::iterator itr = parts.begin(); itr != parts.end(); ++itr)
|
||||||
{
|
{
|
||||||
if((*itr).mPart == ESM::PRT_Head)
|
if((*itr).mPart == ESM::PRT_Head)
|
||||||
{
|
|
||||||
return std::make_pair(0, "#{sNotifyMessage13}");
|
return std::make_pair(0, "#{sNotifyMessage13}");
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*slot == MWWorld::InventoryStore::Slot_Boots)
|
|
||||||
{
|
|
||||||
for(std::vector<ESM::PartReference>::iterator itr = parts.begin(); itr != parts.end(); ++itr)
|
|
||||||
{
|
|
||||||
if((*itr).mPart == ESM::PRT_LFoot || (*itr).mPart == ESM::PRT_RFoot)
|
if((*itr).mPart == ESM::PRT_LFoot || (*itr).mPart == ESM::PRT_RFoot)
|
||||||
{
|
|
||||||
return std::make_pair(0, "#{sNotifyMessage14}");
|
return std::make_pair(0, "#{sNotifyMessage14}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for (std::vector<int>::const_iterator slot=slots_.first.begin();
|
||||||
|
slot!=slots_.first.end(); ++slot)
|
||||||
|
{
|
||||||
|
// If equipping a shield, check if there's a twohanded weapon conflicting with it
|
||||||
if(*slot == MWWorld::InventoryStore::Slot_CarriedLeft)
|
if(*slot == MWWorld::InventoryStore::Slot_CarriedLeft)
|
||||||
{
|
{
|
||||||
MWWorld::ContainerStoreIterator weapon = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
MWWorld::ContainerStoreIterator weapon = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||||
|
|
|
@ -235,11 +235,10 @@ namespace MWClass
|
||||||
// slots that this item can be equipped in
|
// slots that this item can be equipped in
|
||||||
std::pair<std::vector<int>, bool> slots_ = MWWorld::Class::get(ptr).getEquipmentSlots(ptr);
|
std::pair<std::vector<int>, bool> slots_ = MWWorld::Class::get(ptr).getEquipmentSlots(ptr);
|
||||||
|
|
||||||
std::string npcRace = npc.get<ESM::NPC>()->mBase->mRace;
|
if (slots_.first.empty())
|
||||||
|
return std::make_pair(0, "");
|
||||||
|
|
||||||
for (std::vector<int>::const_iterator slot=slots_.first.begin();
|
std::string npcRace = npc.get<ESM::NPC>()->mBase->mRace;
|
||||||
slot!=slots_.first.end(); ++slot)
|
|
||||||
{
|
|
||||||
|
|
||||||
// Beast races cannot equip shoes / boots, or full helms (head part vs hair part)
|
// Beast races cannot equip shoes / boots, or full helms (head part vs hair part)
|
||||||
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npcRace);
|
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npcRace);
|
||||||
|
@ -247,25 +246,15 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
std::vector<ESM::PartReference> parts = ptr.get<ESM::Clothing>()->mBase->mParts.mParts;
|
std::vector<ESM::PartReference> parts = ptr.get<ESM::Clothing>()->mBase->mParts.mParts;
|
||||||
|
|
||||||
if(*slot == MWWorld::InventoryStore::Slot_Helmet)
|
|
||||||
{
|
|
||||||
for(std::vector<ESM::PartReference>::iterator itr = parts.begin(); itr != parts.end(); ++itr)
|
for(std::vector<ESM::PartReference>::iterator itr = parts.begin(); itr != parts.end(); ++itr)
|
||||||
{
|
{
|
||||||
if((*itr).mPart == ESM::PRT_Head)
|
if((*itr).mPart == ESM::PRT_Head)
|
||||||
return std::make_pair(0, "#{sNotifyMessage13}");
|
return std::make_pair(0, "#{sNotifyMessage13}");
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*slot == MWWorld::InventoryStore::Slot_Boots)
|
|
||||||
{
|
|
||||||
for(std::vector<ESM::PartReference>::iterator itr = parts.begin(); itr != parts.end(); ++itr)
|
|
||||||
{
|
|
||||||
if((*itr).mPart == ESM::PRT_LFoot || (*itr).mPart == ESM::PRT_RFoot)
|
if((*itr).mPart == ESM::PRT_LFoot || (*itr).mPart == ESM::PRT_RFoot)
|
||||||
return std::make_pair(0, "#{sNotifyMessage15}");
|
return std::make_pair(0, "#{sNotifyMessage15}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return std::make_pair (1, "");
|
return std::make_pair (1, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -390,12 +390,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
std::pair<std::vector<int>, bool> slots_ = MWWorld::Class::get(ptr).getEquipmentSlots(ptr);
|
std::pair<std::vector<int>, bool> slots_ = MWWorld::Class::get(ptr).getEquipmentSlots(ptr);
|
||||||
|
|
||||||
// equip the item in the first free slot
|
if (slots_.first.empty())
|
||||||
for (std::vector<int>::const_iterator slot=slots_.first.begin();
|
return std::make_pair (0, "");
|
||||||
slot!=slots_.first.end(); ++slot)
|
|
||||||
{
|
|
||||||
if(*slot == MWWorld::InventoryStore::Slot_CarriedRight)
|
|
||||||
{
|
|
||||||
if(ptr.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::LongBladeTwoHand ||
|
if(ptr.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::LongBladeTwoHand ||
|
||||||
ptr.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::BluntTwoClose ||
|
ptr.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::BluntTwoClose ||
|
||||||
ptr.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::BluntTwoWide ||
|
ptr.get<ESM::Weapon>()->mBase->mData.mType == ESM::Weapon::BluntTwoWide ||
|
||||||
|
@ -406,11 +403,9 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
return std::make_pair (2, "");
|
return std::make_pair (2, "");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return std::make_pair(1, "");
|
return std::make_pair(1, "");
|
||||||
}
|
}
|
||||||
return std::make_pair (0, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::shared_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr) const
|
boost::shared_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue