mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 13:56:38 +00:00 
			
		
		
		
	Porting more ContainerStoreIterator usage to const version
This commit is contained in:
		
							parent
							
								
									9963601484
								
							
						
					
					
						commit
						05cc69f6f1
					
				
					 5 changed files with 12 additions and 6 deletions
				
			
		|  | @ -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; | ||||
| 
 | ||||
|  |  | |||
|  | @ -295,7 +295,7 @@ namespace MWClass | |||
| 
 | ||||
|     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) | ||||
|             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,""); | ||||
|  |  | |||
|  | @ -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); | ||||
|  |  | |||
|  | @ -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<InventoryStore*>(this)->getSlot (slot); | ||||
| } | ||||
| 
 | ||||
| bool MWWorld::InventoryStore::canActorAutoEquip(const MWWorld::Ptr& actor, const MWWorld::Ptr& item) | ||||
| { | ||||
|     if (!Settings::Manager::getBool("prevent merchant equipping", "Game")) | ||||
|  |  | |||
|  | @ -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.
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue