make Ptr a bit more pointer-like

This commit is contained in:
Marc Zinnschlag 2014-02-23 18:17:41 +01:00
parent b72c1c2c58
commit f220867144
3 changed files with 14 additions and 18 deletions

View file

@ -342,26 +342,14 @@ namespace MWWorld
Ptr CellStore::searchInContainer (const std::string& id)
{
{
Ptr ptr = searchInContainerList (mContainers, id);
if (!ptr.isEmpty())
if (Ptr ptr = searchInContainerList (mContainers, id))
return ptr;
}
{
Ptr ptr = searchInContainerList (mCreatures, id);
if (!ptr.isEmpty())
if (Ptr ptr = searchInContainerList (mCreatures, id))
return ptr;
}
{
Ptr ptr = searchInContainerList (mNpcs, id);
if (!ptr.isEmpty())
if (Ptr ptr = searchInContainerList (mNpcs, id))
return ptr;
}
return Ptr();
}

View file

@ -55,3 +55,8 @@ MWWorld::ContainerStore *MWWorld::Ptr::getContainerStore() const
{
return mContainerStore;
}
MWWorld::Ptr::operator const void *()
{
return mRef;
}

View file

@ -74,6 +74,9 @@ namespace MWWorld
ContainerStore *getContainerStore() const;
///< May return a 0-pointer, if reference is not in a container.
operator const void *();
///< Return a 0-pointer, if Ptr is empty; return a non-0-pointer, if Ptr is not empty
};
inline bool operator== (const Ptr& left, const Ptr& right)