diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 324c5ea77..256c8b1d5 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -176,7 +176,7 @@ namespace MWBase ///< Return a pointer to a liveCellRef with the given name. /// \param activeOnly do non search inactive cells. - virtual MWWorld::Ptr searchPtr (const std::string& name, bool activeOnly) = 0; + virtual MWWorld::Ptr searchPtr (const std::string& name, bool activeOnly, bool searchInContainers = true) = 0; ///< Return a pointer to a liveCellRef with the given name. /// \param activeOnly do non search inactive cells. diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 0650c21a2..c98b44252 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -994,7 +994,7 @@ namespace MWMechanics } if (!cellref.getOwner().empty()) - victim = MWBase::Environment::get().getWorld()->searchPtr(cellref.getOwner(), true); + victim = MWBase::Environment::get().getWorld()->searchPtr(cellref.getOwner(), true, false); return (!isOwned && !isFactionOwned); } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index cd03137d7..1f6ffabd7 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -679,7 +679,7 @@ namespace MWWorld mLocalScripts.remove (ref); } - Ptr World::searchPtr (const std::string& name, bool activeOnly) + Ptr World::searchPtr (const std::string& name, bool activeOnly, bool searchInContainers) { Ptr ret; // the player is always in an active cell. @@ -706,11 +706,14 @@ namespace MWWorld return ret; } - for (CellStore* cellstore : mWorldScene->getActiveCells()) + if (searchInContainers) { - Ptr ptr = cellstore->searchInContainer(lowerCaseName); - if (!ptr.isEmpty()) - return ptr; + for (CellStore* cellstore : mWorldScene->getActiveCells()) + { + Ptr ptr = cellstore->searchInContainer(lowerCaseName); + if (!ptr.isEmpty()) + return ptr; + } } Ptr ptr = mPlayer->getPlayer().getClass() diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index adf60b360..dd915c8bd 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -285,7 +285,7 @@ namespace MWWorld ///< Return a pointer to a liveCellRef with the given name. /// \param activeOnly do non search inactive cells. - Ptr searchPtr (const std::string& name, bool activeOnly) override; + Ptr searchPtr (const std::string& name, bool activeOnly, bool searchInContainers = true) override; ///< Return a pointer to a liveCellRef with the given name. /// \param activeOnly do non search inactive cells.