1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 21:23:52 +00:00

Porting more ContainerStoreIterator usage to const version

This commit is contained in:
Rafael Moura 2017-02-26 21:24:51 +00:00
parent 9963601484
commit 05cc69f6f1
5 changed files with 12 additions and 6 deletions

View file

@ -39,8 +39,8 @@ namespace MWClass
void Actor::block(const MWWorld::Ptr &ptr) const void Actor::block(const MWWorld::Ptr &ptr) const
{ {
MWWorld::InventoryStore& inv = getInventoryStore(ptr); const MWWorld::InventoryStore& inv = getInventoryStore(ptr);
MWWorld::ContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft); MWWorld::ConstContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
if (shield == inv.end()) if (shield == inv.end())
return; return;

View file

@ -295,7 +295,7 @@ namespace MWClass
std::pair<int, std::string> Armor::canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const std::pair<int, std::string> Armor::canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const
{ {
MWWorld::InventoryStore& invStore = npc.getClass().getInventoryStore(npc); const MWWorld::InventoryStore& invStore = npc.getClass().getInventoryStore(npc);
if (ptr.getCellRef().getCharge() == 0) if (ptr.getCellRef().getCharge() == 0)
return std::make_pair(0, "#{sInventoryMessage1}"); return std::make_pair(0, "#{sInventoryMessage1}");
@ -332,7 +332,7 @@ namespace MWClass
// If equipping a shield, check if there's a twohanded weapon conflicting with it // 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::ConstContainerStoreIterator weapon = invStore.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
if(weapon == invStore.end()) if(weapon == invStore.end())
return std::make_pair(1,""); return std::make_pair(1,"");

View file

@ -194,10 +194,10 @@ namespace MWClass
// FIXME: use const version of InventoryStore functions once they are available // FIXME: use const version of InventoryStore functions once they are available
if (ptr.getClass().hasInventoryStore(ptr)) if (ptr.getClass().hasInventoryStore(ptr))
{ {
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr); const MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore(ptr);
for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot) for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot)
{ {
MWWorld::ContainerStoreIterator equipped = invStore.getSlot(slot); MWWorld::ConstContainerStoreIterator equipped = invStore.getSlot(slot);
if (equipped != invStore.end()) if (equipped != invStore.end())
{ {
model = equipped->getClass().getModel(*equipped); model = equipped->getClass().getModel(*equipped);

View file

@ -215,6 +215,11 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSlot (int slot)
return mSlots[slot]; return mSlots[slot];
} }
MWWorld::ConstContainerStoreIterator MWWorld::InventoryStore::getSlot (int slot) const
{
return const_cast<InventoryStore*>(this)->getSlot (slot);
}
bool MWWorld::InventoryStore::canActorAutoEquip(const MWWorld::Ptr& actor, const MWWorld::Ptr& item) bool MWWorld::InventoryStore::canActorAutoEquip(const MWWorld::Ptr& actor, const MWWorld::Ptr& item)
{ {
if (!Settings::Manager::getBool("prevent merchant equipping", "Game")) if (!Settings::Manager::getBool("prevent merchant equipping", "Game"))

View file

@ -155,6 +155,7 @@ namespace MWWorld
/// \note if no item selected, return end() iterator /// \note if no item selected, return end() iterator
ContainerStoreIterator getSlot (int slot); ContainerStoreIterator getSlot (int slot);
ConstContainerStoreIterator getSlot(int slot) const;
void unequipAll(const MWWorld::Ptr& actor); void unequipAll(const MWWorld::Ptr& actor);
///< Unequip all currently equipped items. ///< Unequip all currently equipped items.