mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-29 18:32:36 +00:00
Porting code to ConstContainerStoreIterator #1
This commit is contained in:
parent
ecbde7b11e
commit
9963601484
@ -135,7 +135,7 @@ namespace MWClass
|
||||
const std::string trapActivationSound = "Disarm Trap Fail";
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
||||
MWWorld::InventoryStore& invStore = player.getClass().getInventoryStore(player);
|
||||
const MWWorld::InventoryStore& invStore = player.getClass().getInventoryStore(player);
|
||||
|
||||
bool isLocked = ptr.getCellRef().getLockLevel() > 0;
|
||||
bool isTrapped = !ptr.getCellRef().getTrap().empty();
|
||||
|
@ -106,7 +106,7 @@ namespace MWClass
|
||||
const std::string lockedSound = "LockedDoor";
|
||||
const std::string trapActivationSound = "Disarm Trap Fail";
|
||||
|
||||
MWWorld::ContainerStore &invStore = actor.getClass().getContainerStore(actor);
|
||||
const MWWorld::ContainerStore &invStore = actor.getClass().getContainerStore(actor);
|
||||
|
||||
bool isLocked = ptr.getCellRef().getLockLevel() > 0;
|
||||
bool isTrapped = !ptr.getCellRef().getTrap().empty();
|
||||
@ -130,7 +130,7 @@ namespace MWClass
|
||||
// make key id lowercase
|
||||
std::string keyId = ptr.getCellRef().getKey();
|
||||
Misc::StringUtils::lowerCaseInPlace(keyId);
|
||||
for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it)
|
||||
for (MWWorld::ConstContainerStoreIterator it = invStore.cbegin(); it != invStore.cend(); ++it)
|
||||
{
|
||||
std::string refId = it->getCellRef().getRefId();
|
||||
Misc::StringUtils::lowerCaseInPlace(refId);
|
||||
|
@ -44,10 +44,10 @@ void MerchantRepair::startRepair(const MWWorld::Ptr &actor)
|
||||
MWWorld::Ptr player = MWMechanics::getPlayer();
|
||||
int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId);
|
||||
|
||||
MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
|
||||
const MWWorld::ContainerStore& store = player.getClass().getContainerStore(player);
|
||||
int categories = MWWorld::ContainerStore::Type_Weapon | MWWorld::ContainerStore::Type_Armor;
|
||||
for (MWWorld::ContainerStoreIterator iter (store.begin(categories));
|
||||
iter!=store.end(); ++iter)
|
||||
for (MWWorld::ConstContainerStoreIterator iter (store.cbegin(categories));
|
||||
iter!=store.cend(); ++iter)
|
||||
{
|
||||
if (iter->getClass().hasItemHealth(*iter))
|
||||
{
|
||||
|
@ -33,7 +33,8 @@ ActorAnimation::ActorAnimation(const MWWorld::Ptr& ptr, osg::ref_ptr<osg::Group>
|
||||
{
|
||||
MWWorld::ContainerStore& store = mPtr.getClass().getContainerStore(mPtr);
|
||||
|
||||
for (MWWorld::ContainerStoreIterator iter = store.begin(MWWorld::ContainerStore::Type_Light); iter != store.end(); ++iter)
|
||||
for (MWWorld::ConstContainerStoreIterator iter = store.cbegin(MWWorld::ContainerStore::Type_Light);
|
||||
iter != store.cend(); ++iter)
|
||||
{
|
||||
const ESM::Light* light = iter->get<ESM::Light>()->mBase;
|
||||
if (!(light->mData.mFlags & ESM::Light::Carry))
|
||||
|
@ -140,7 +140,7 @@ namespace MWScript
|
||||
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore (ptr);
|
||||
|
||||
std::string itemName;
|
||||
for (MWWorld::ContainerStoreIterator iter(store.begin()); iter != store.end(); ++iter)
|
||||
for (MWWorld::ConstContainerStoreIterator iter(store.cbegin()); iter != store.cend(); ++iter)
|
||||
if (::Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), item))
|
||||
itemName = iter->getClass().getName(*iter);
|
||||
|
||||
@ -316,9 +316,9 @@ namespace MWScript
|
||||
runtime.pop();
|
||||
|
||||
int count = 0;
|
||||
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore (ptr);
|
||||
for (MWWorld::ContainerStoreIterator it = invStore.begin(MWWorld::ContainerStore::Type_Miscellaneous);
|
||||
it != invStore.end(); ++it)
|
||||
const MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore (ptr);
|
||||
for (MWWorld::ConstContainerStoreIterator it = invStore.cbegin(MWWorld::ContainerStore::Type_Miscellaneous);
|
||||
it != invStore.cend(); ++it)
|
||||
{
|
||||
if (::Misc::StringUtils::ciEqual(it->getCellRef().getSoul(), name))
|
||||
count += it->getRefData().getCount();
|
||||
|
@ -117,16 +117,6 @@ MWWorld::ContainerStore::ContainerStore() : mListener(NULL), mCachedWeight (0),
|
||||
|
||||
MWWorld::ContainerStore::~ContainerStore() {}
|
||||
|
||||
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::begin (int mask)
|
||||
{
|
||||
return ContainerStoreIterator (mask, this);
|
||||
}
|
||||
|
||||
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::end()
|
||||
{
|
||||
return ContainerStoreIterator (this);
|
||||
}
|
||||
|
||||
MWWorld::ConstContainerStoreIterator MWWorld::ContainerStore::cbegin (int mask) const
|
||||
{
|
||||
return ConstContainerStoreIterator (mask, this);
|
||||
@ -137,6 +127,26 @@ MWWorld::ConstContainerStoreIterator MWWorld::ContainerStore::cend() const
|
||||
return ConstContainerStoreIterator (this);
|
||||
}
|
||||
|
||||
MWWorld::ConstContainerStoreIterator MWWorld::ContainerStore::begin (int mask) const
|
||||
{
|
||||
return cbegin(mask);
|
||||
}
|
||||
|
||||
MWWorld::ConstContainerStoreIterator MWWorld::ContainerStore::end() const
|
||||
{
|
||||
return cend();
|
||||
}
|
||||
|
||||
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::begin (int mask)
|
||||
{
|
||||
return ContainerStoreIterator (mask, this);
|
||||
}
|
||||
|
||||
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::end()
|
||||
{
|
||||
return ContainerStoreIterator (this);
|
||||
}
|
||||
|
||||
int MWWorld::ContainerStore::count(const std::string &id)
|
||||
{
|
||||
int total=0;
|
||||
@ -199,7 +209,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::restack(const MWWorld::
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool MWWorld::ContainerStore::stacks(const ConstPtr& ptr1, const ConstPtr& ptr2)
|
||||
bool MWWorld::ContainerStore::stacks(const ConstPtr& ptr1, const ConstPtr& ptr2) const
|
||||
{
|
||||
const MWWorld::Class& cls1 = ptr1.getClass();
|
||||
const MWWorld::Class& cls2 = ptr2.getClass();
|
||||
@ -800,7 +810,7 @@ void MWWorld::ContainerStore::readState (const ESM::InventoryState& inventory)
|
||||
|
||||
template<class PtrType>
|
||||
template<class T>
|
||||
void MWWorld::ContainerStoreIteratorBase<PtrType>::copy(const ContainerStoreIteratorBase<T>& src)
|
||||
void MWWorld::ContainerStoreIteratorBase<PtrType>::copy (const ContainerStoreIteratorBase<T>& src)
|
||||
{
|
||||
mType = src.mType;
|
||||
mMask = src.mMask;
|
||||
|
@ -119,13 +119,13 @@ namespace MWWorld
|
||||
|
||||
virtual ContainerStore* clone() { return new ContainerStore(*this); }
|
||||
|
||||
ContainerStoreIterator begin (int mask = Type_All);
|
||||
|
||||
ContainerStoreIterator end();
|
||||
|
||||
ConstContainerStoreIterator cbegin (int mask = Type_All) const;
|
||||
|
||||
ConstContainerStoreIterator cend() const;
|
||||
ConstContainerStoreIterator begin (int mask = Type_All) const;
|
||||
ConstContainerStoreIterator end() const;
|
||||
|
||||
ContainerStoreIterator begin (int mask = Type_All);
|
||||
ContainerStoreIterator end();
|
||||
|
||||
virtual ContainerStoreIterator add (const Ptr& itemPtr, int count, const Ptr& actorPtr, bool setOwner=false);
|
||||
///< Add the item pointed to by \a ptr to this container. (Stacks automatically if needed)
|
||||
@ -176,7 +176,7 @@ namespace MWWorld
|
||||
|
||||
public:
|
||||
|
||||
virtual bool stacks (const ConstPtr& ptr1, const ConstPtr& ptr2);
|
||||
virtual bool stacks (const ConstPtr& ptr1, const ConstPtr& ptr2) const;
|
||||
///< @return true if the two specified objects can stack with each other
|
||||
|
||||
void fill (const ESM::InventoryList& items, const std::string& owner);
|
||||
|
Loading…
x
Reference in New Issue
Block a user