mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-06 03:45:35 +00:00
[Client] Add actorsOnly argument to CellStore's exact object search
This commit is contained in:
parent
a6dd76776f
commit
17715933b5
2 changed files with 12 additions and 7 deletions
|
@ -606,14 +606,18 @@ 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;
|
||||
|
||||
bool operator()(const Ptr& ptr)
|
||||
{
|
||||
if (ptr.getCellRef().getRefNum().mIndex == mRefNumToFind && ptr.getCellRef().getMpNum() == mMpNumToFind)
|
||||
{
|
||||
if (!mActorsOnly || ptr.getClass().isActor())
|
||||
{
|
||||
if (mRefIdToFind.empty() || Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), mRefIdToFind))
|
||||
{
|
||||
|
@ -621,6 +625,7 @@ namespace MWWorld
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue