diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index ceb27274e..91bda79af 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -342,26 +342,14 @@ namespace MWWorld Ptr CellStore::searchInContainer (const std::string& id) { - { - Ptr ptr = searchInContainerList (mContainers, id); + if (Ptr ptr = searchInContainerList (mContainers, id)) + return ptr; - if (!ptr.isEmpty()) - return ptr; - } + if (Ptr ptr = searchInContainerList (mCreatures, id)) + return ptr; - { - Ptr ptr = searchInContainerList (mCreatures, id); - - if (!ptr.isEmpty()) - return ptr; - } - - { - Ptr ptr = searchInContainerList (mNpcs, id); - - if (!ptr.isEmpty()) - return ptr; - } + if (Ptr ptr = searchInContainerList (mNpcs, id)) + return ptr; return Ptr(); } diff --git a/apps/openmw/mwworld/ptr.cpp b/apps/openmw/mwworld/ptr.cpp index 67bfe4900..3920a3e79 100644 --- a/apps/openmw/mwworld/ptr.cpp +++ b/apps/openmw/mwworld/ptr.cpp @@ -55,3 +55,8 @@ MWWorld::ContainerStore *MWWorld::Ptr::getContainerStore() const { return mContainerStore; } + +MWWorld::Ptr::operator const void *() +{ + return mRef; +} \ No newline at end of file diff --git a/apps/openmw/mwworld/ptr.hpp b/apps/openmw/mwworld/ptr.hpp index 1212619d0..4529ae279 100644 --- a/apps/openmw/mwworld/ptr.hpp +++ b/apps/openmw/mwworld/ptr.hpp @@ -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)