mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-04 13:45:34 +00:00
Porting code to ConstContainerStoreIterator #1
This commit is contained in:
parent
ecbde7b11e
commit
9963601484
7 changed files with 40 additions and 29 deletions
|
@ -135,7 +135,7 @@ namespace MWClass
|
||||||
const std::string trapActivationSound = "Disarm Trap Fail";
|
const std::string trapActivationSound = "Disarm Trap Fail";
|
||||||
|
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
|
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 isLocked = ptr.getCellRef().getLockLevel() > 0;
|
||||||
bool isTrapped = !ptr.getCellRef().getTrap().empty();
|
bool isTrapped = !ptr.getCellRef().getTrap().empty();
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace MWClass
|
||||||
const std::string lockedSound = "LockedDoor";
|
const std::string lockedSound = "LockedDoor";
|
||||||
const std::string trapActivationSound = "Disarm Trap Fail";
|
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 isLocked = ptr.getCellRef().getLockLevel() > 0;
|
||||||
bool isTrapped = !ptr.getCellRef().getTrap().empty();
|
bool isTrapped = !ptr.getCellRef().getTrap().empty();
|
||||||
|
@ -130,7 +130,7 @@ namespace MWClass
|
||||||
// make key id lowercase
|
// make key id lowercase
|
||||||
std::string keyId = ptr.getCellRef().getKey();
|
std::string keyId = ptr.getCellRef().getKey();
|
||||||
Misc::StringUtils::lowerCaseInPlace(keyId);
|
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();
|
std::string refId = it->getCellRef().getRefId();
|
||||||
Misc::StringUtils::lowerCaseInPlace(refId);
|
Misc::StringUtils::lowerCaseInPlace(refId);
|
||||||
|
|
|
@ -44,10 +44,10 @@ void MerchantRepair::startRepair(const MWWorld::Ptr &actor)
|
||||||
MWWorld::Ptr player = MWMechanics::getPlayer();
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
||||||
int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId);
|
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;
|
int categories = MWWorld::ContainerStore::Type_Weapon | MWWorld::ContainerStore::Type_Armor;
|
||||||
for (MWWorld::ContainerStoreIterator iter (store.begin(categories));
|
for (MWWorld::ConstContainerStoreIterator iter (store.cbegin(categories));
|
||||||
iter!=store.end(); ++iter)
|
iter!=store.cend(); ++iter)
|
||||||
{
|
{
|
||||||
if (iter->getClass().hasItemHealth(*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);
|
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;
|
const ESM::Light* light = iter->get<ESM::Light>()->mBase;
|
||||||
if (!(light->mData.mFlags & ESM::Light::Carry))
|
if (!(light->mData.mFlags & ESM::Light::Carry))
|
||||||
|
|
|
@ -140,7 +140,7 @@ namespace MWScript
|
||||||
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore (ptr);
|
MWWorld::ContainerStore& store = ptr.getClass().getContainerStore (ptr);
|
||||||
|
|
||||||
std::string itemName;
|
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))
|
if (::Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), item))
|
||||||
itemName = iter->getClass().getName(*iter);
|
itemName = iter->getClass().getName(*iter);
|
||||||
|
|
||||||
|
@ -316,9 +316,9 @@ namespace MWScript
|
||||||
runtime.pop();
|
runtime.pop();
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore (ptr);
|
const MWWorld::InventoryStore& invStore = ptr.getClass().getInventoryStore (ptr);
|
||||||
for (MWWorld::ContainerStoreIterator it = invStore.begin(MWWorld::ContainerStore::Type_Miscellaneous);
|
for (MWWorld::ConstContainerStoreIterator it = invStore.cbegin(MWWorld::ContainerStore::Type_Miscellaneous);
|
||||||
it != invStore.end(); ++it)
|
it != invStore.cend(); ++it)
|
||||||
{
|
{
|
||||||
if (::Misc::StringUtils::ciEqual(it->getCellRef().getSoul(), name))
|
if (::Misc::StringUtils::ciEqual(it->getCellRef().getSoul(), name))
|
||||||
count += it->getRefData().getCount();
|
count += it->getRefData().getCount();
|
||||||
|
|
|
@ -117,16 +117,6 @@ MWWorld::ContainerStore::ContainerStore() : mListener(NULL), mCachedWeight (0),
|
||||||
|
|
||||||
MWWorld::ContainerStore::~ContainerStore() {}
|
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
|
MWWorld::ConstContainerStoreIterator MWWorld::ContainerStore::cbegin (int mask) const
|
||||||
{
|
{
|
||||||
return ConstContainerStoreIterator (mask, this);
|
return ConstContainerStoreIterator (mask, this);
|
||||||
|
@ -137,6 +127,26 @@ MWWorld::ConstContainerStoreIterator MWWorld::ContainerStore::cend() const
|
||||||
return ConstContainerStoreIterator (this);
|
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 MWWorld::ContainerStore::count(const std::string &id)
|
||||||
{
|
{
|
||||||
int total=0;
|
int total=0;
|
||||||
|
@ -199,7 +209,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::restack(const MWWorld::
|
||||||
return retval;
|
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& cls1 = ptr1.getClass();
|
||||||
const MWWorld::Class& cls2 = ptr2.getClass();
|
const MWWorld::Class& cls2 = ptr2.getClass();
|
||||||
|
|
|
@ -119,13 +119,13 @@ namespace MWWorld
|
||||||
|
|
||||||
virtual ContainerStore* clone() { return new ContainerStore(*this); }
|
virtual ContainerStore* clone() { return new ContainerStore(*this); }
|
||||||
|
|
||||||
ContainerStoreIterator begin (int mask = Type_All);
|
|
||||||
|
|
||||||
ContainerStoreIterator end();
|
|
||||||
|
|
||||||
ConstContainerStoreIterator cbegin (int mask = Type_All) const;
|
ConstContainerStoreIterator cbegin (int mask = Type_All) const;
|
||||||
|
|
||||||
ConstContainerStoreIterator cend() 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);
|
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)
|
///< Add the item pointed to by \a ptr to this container. (Stacks automatically if needed)
|
||||||
|
@ -176,7 +176,7 @@ namespace MWWorld
|
||||||
|
|
||||||
public:
|
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
|
///< @return true if the two specified objects can stack with each other
|
||||||
|
|
||||||
void fill (const ESM::InventoryList& items, const std::string& owner);
|
void fill (const ESM::InventoryList& items, const std::string& owner);
|
||||||
|
|
Loading…
Reference in a new issue