Accept a ConstPtr in ContainerStore::stacks

This commit is contained in:
scrawl 2015-12-18 17:00:31 +01:00
parent 04f7a8f8eb
commit edde5bd065
5 changed files with 34 additions and 4 deletions

View file

@ -176,7 +176,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::restack(const MWWorld::
return retval;
}
bool MWWorld::ContainerStore::stacks(const Ptr& ptr1, const Ptr& ptr2)
bool MWWorld::ContainerStore::stacks(const ConstPtr& ptr1, const ConstPtr& ptr2)
{
const MWWorld::Class& cls1 = ptr1.getClass();
const MWWorld::Class& cls2 = ptr2.getClass();

View file

@ -149,7 +149,7 @@ namespace MWWorld
public:
virtual bool stacks (const Ptr& ptr1, const Ptr& ptr2);
virtual bool stacks (const ConstPtr& ptr1, const ConstPtr& ptr2);
///< @return true if the two specified objects can stack with each other
void fill (const ESM::InventoryList& items, const std::string& owner);

View file

@ -450,7 +450,7 @@ void MWWorld::InventoryStore::flagAsModified()
mRechargingItemsUpToDate = false;
}
bool MWWorld::InventoryStore::stacks(const Ptr& ptr1, const Ptr& ptr2)
bool MWWorld::InventoryStore::stacks(const ConstPtr& ptr1, const ConstPtr& ptr2)
{
bool canStack = MWWorld::ContainerStore::stacks(ptr1, ptr2);
if (!canStack)

View file

@ -167,7 +167,7 @@ namespace MWWorld
///< \attention This function is internal to the world model and should not be called from
/// outside.
virtual bool stacks (const Ptr& ptr1, const Ptr& ptr2);
virtual bool stacks (const ConstPtr& ptr1, const ConstPtr& ptr2);
///< @return true if the two specified objects can stack with each other
virtual int remove(const Ptr& item, int count, const Ptr& actor);

View file

@ -195,6 +195,36 @@ namespace MWWorld
{
return !(left>right);
}
inline bool operator== (const ConstPtr& left, const ConstPtr& right)
{
return left.mRef==right.mRef;
}
inline bool operator!= (const ConstPtr& left, const ConstPtr& right)
{
return !(left==right);
}
inline bool operator< (const ConstPtr& left, const ConstPtr& right)
{
return left.mRef<right.mRef;
}
inline bool operator>= (const ConstPtr& left, const ConstPtr& right)
{
return !(left<right);
}
inline bool operator> (const ConstPtr& left, const ConstPtr& right)
{
return right<left;
}
inline bool operator<= (const ConstPtr& left, const ConstPtr& right)
{
return !(left>right);
}
}
#endif