From 17715933b574679c966ec4e29bb7d7acf72ed62c Mon Sep 17 00:00:00 2001 From: David Cernat Date: Wed, 23 Mar 2022 09:49:57 +0200 Subject: [PATCH] [Client] Add actorsOnly argument to CellStore's exact object search --- apps/openmw/mwworld/cellstore.cpp | 17 +++++++++++------ apps/openmw/mwworld/cellstore.hpp | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index 27b26ed5d..7b2791773 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -606,8 +606,10 @@ namespace MWWorld const unsigned int mRefNumToFind; const unsigned int mMpNumToFind; const std::string mRefIdToFind; + const bool mActorsOnly; public: - SearchExactVisitor(const unsigned int refNum, const unsigned int mpNum, const std::string refId) : mRefNumToFind(refNum), mMpNumToFind(mpNum), mRefIdToFind(refId) {} + SearchExactVisitor(const unsigned int refNum, const unsigned int mpNum, const std::string refId, const bool actorsOnly) : + mRefNumToFind(refNum), mMpNumToFind(mpNum), mRefIdToFind(refId), mActorsOnly(actorsOnly) {} Ptr mFound; @@ -615,10 +617,13 @@ namespace MWWorld { if (ptr.getCellRef().getRefNum().mIndex == mRefNumToFind && ptr.getCellRef().getMpNum() == mMpNumToFind) { - if (mRefIdToFind.empty() || Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), mRefIdToFind)) + if (!mActorsOnly || ptr.getClass().isActor()) { - mFound = ptr; - return false; + if (mRefIdToFind.empty() || Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), mRefIdToFind)) + { + mFound = ptr; + return false; + } } } return true; @@ -633,13 +638,13 @@ namespace MWWorld Allow the searching of objects by their reference numbers */ - Ptr CellStore::searchExact (const unsigned int refNum, const unsigned int mpNum, const std::string refId) + Ptr CellStore::searchExact (const unsigned int refNum, const unsigned int mpNum, const std::string refId, bool actorsOnly) { // Ensure that all objects searched for have a valid reference number if (refNum == 0 && mpNum == 0) return 0; - SearchExactVisitor searchVisitor(refNum, mpNum, refId); + SearchExactVisitor searchVisitor(refNum, mpNum, refId, actorsOnly); forEach(searchVisitor); return searchVisitor.mFound; } diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index b5179e676..3e901f4b8 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -265,7 +265,7 @@ namespace MWWorld Allow the searching of objects by their reference numbers and, optionally, their refIds */ - Ptr searchExact (unsigned int refNum, unsigned int mpNum, std::string refId = ""); + Ptr searchExact (unsigned int refNum, unsigned int mpNum, std::string refId = "", bool actorsOnly = false); /* End of tes3mp addition */