diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 4336ccbc0..5e3f6739d 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -184,6 +184,16 @@ namespace MWBase virtual MWWorld::Ptr searchPtrViaActorId (int actorId) = 0; ///< Search is limited to the active cells. + /* + Start of tes3mp addition + + Make it possible to find a Ptr in any active cell based on its refNumIndex and mpNum + */ + virtual MWWorld::Ptr searchPtrViaRefIndex(int refNumIndex, int mpNum) = 0; + /* + End of tes3mp addition + */ + virtual MWWorld::Ptr findContainer (const MWWorld::ConstPtr& ptr) = 0; ///< Return a pointer to a liveCellRef which contains \a ptr. /// \note Search is limited to the active cells. diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index c0fbb2305..cf91ca57b 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -729,6 +729,30 @@ namespace MWWorld return mWorldScene->searchPtrViaActorId (actorId); } + /* + Start of tes3mp addition + + Make it possible to find a Ptr in any active cell based on its refNumIndex and mpNum + */ + Ptr World::searchPtrViaRefIndex(int refNumIndex, int mpNum) + { + for (Scene::CellStoreCollection::const_iterator iter(mWorldScene->getActiveCells().begin()); + iter != mWorldScene->getActiveCells().end(); ++iter) + { + CellStore* cellStore = *iter; + + MWWorld::Ptr ptrFound = cellStore->searchExact(refNumIndex, mpNum); + + if (ptrFound) + return ptrFound; + } + + return nullptr; + } + /* + End of tes3mp addition + */ + struct FindContainerVisitor { ConstPtr mContainedPtr; diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index ab6c3f04a..223cd777f 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -291,6 +291,16 @@ namespace MWWorld Ptr searchPtrViaActorId (int actorId) override; ///< Search is limited to the active cells. + /* + Start of tes3mp addition + + Make it possible to find a Ptr in any active cell based on its refNumIndex and mpNum + */ + Ptr searchPtrViaRefIndex(int refNumIndex, int mpNum) override; + /* + End of tes3mp addition + */ + MWWorld::Ptr findContainer (const MWWorld::ConstPtr& ptr) override; ///< Return a pointer to a liveCellRef which contains \a ptr. /// \note Search is limited to the active cells.