diff --git a/apps/openmw/mwclass/actor.cpp b/apps/openmw/mwclass/actor.cpp index d46729c1d..e3e924649 100644 --- a/apps/openmw/mwclass/actor.cpp +++ b/apps/openmw/mwclass/actor.cpp @@ -39,8 +39,8 @@ namespace MWClass void Actor::block(const MWWorld::Ptr &ptr) const { - MWWorld::InventoryStore& inv = getInventoryStore(ptr); - MWWorld::ContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft); + const MWWorld::InventoryStore& inv = getInventoryStore(ptr); + MWWorld::ConstContainerStoreIterator shield = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft); if (shield == inv.end()) return; diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 75560dbcb..aeae43f73 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -295,7 +295,7 @@ namespace MWClass std::pair 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) 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(*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()) return std::make_pair(1,""); diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 0be61ef51..8c663474f 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -194,10 +194,10 @@ namespace MWClass // FIXME: use const version of InventoryStore functions once they are available 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) { - MWWorld::ContainerStoreIterator equipped = invStore.getSlot(slot); + MWWorld::ConstContainerStoreIterator equipped = invStore.getSlot(slot); if (equipped != invStore.end()) { model = equipped->getClass().getModel(*equipped); diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 794832733..fd3049f7c 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -215,6 +215,11 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSlot (int slot) return mSlots[slot]; } +MWWorld::ConstContainerStoreIterator MWWorld::InventoryStore::getSlot (int slot) const +{ + return const_cast(this)->getSlot (slot); +} + bool MWWorld::InventoryStore::canActorAutoEquip(const MWWorld::Ptr& actor, const MWWorld::Ptr& item) { if (!Settings::Manager::getBool("prevent merchant equipping", "Game")) diff --git a/apps/openmw/mwworld/inventorystore.hpp b/apps/openmw/mwworld/inventorystore.hpp index f625e4cd1..93350e7c7 100644 --- a/apps/openmw/mwworld/inventorystore.hpp +++ b/apps/openmw/mwworld/inventorystore.hpp @@ -155,6 +155,7 @@ namespace MWWorld /// \note if no item selected, return end() iterator ContainerStoreIterator getSlot (int slot); + ConstContainerStoreIterator getSlot(int slot) const; void unequipAll(const MWWorld::Ptr& actor); ///< Unequip all currently equipped items.