[Client] Add a new type of search to CellStore that also checks refIds

pull/595/head
David Cernat 3 years ago
parent ca96827ec9
commit 646ffc7afe

@ -624,6 +624,36 @@ namespace MWWorld
End of tes3mp addition End of tes3mp addition
*/ */
/*
Start of tes3mp addition
A custom type of search visitor used to find objects by their reference numbers
while ensuring they have a certain refId
*/
class SearchExactPlusVisitor
{
const std::string mRefIdToFind;
const unsigned int mRefNumToFind;
const unsigned int mMpNumToFind;
public:
SearchExactPlusVisitor(const std::string refId, const unsigned int refNum, const unsigned int mpNum) : mRefIdToFind(refId), mRefNumToFind(refNum), mMpNumToFind(mpNum) {}
Ptr mFound;
bool operator()(const Ptr& ptr)
{
if (ptr.getCellRef().getRefNum().mIndex == mRefNumToFind && ptr.getCellRef().getMpNum() == mMpNumToFind && Misc::StringUtils::ciEqual(ptr.getCellRef().getRefId(), mRefIdToFind))
{
mFound = ptr;
return false;
}
return true;
}
};
/*
End of tes3mp addition
*/
/* /*
Start of tes3mp addition Start of tes3mp addition
@ -643,6 +673,26 @@ namespace MWWorld
End of tes3mp addition End of tes3mp addition
*/ */
/*
Start of tes3mp addition
Allow the searching of objects by their reference numbers while ensuring
they have a certain refId
*/
Ptr CellStore::searchExactPlus(const std::string refId, const unsigned int refNum, const unsigned int mpNum)
{
// Ensure that all objects searched for have a valid reference number
if (refNum == 0 && mpNum == 0)
return 0;
SearchExactPlusVisitor searchVisitor(refId, refNum, mpNum);
forEach(searchVisitor);
return searchVisitor.mFound;
}
/*
End of tes3mp addition
*/
/* /*
Start of tes3mp addition Start of tes3mp addition

@ -269,6 +269,17 @@ namespace MWWorld
End of tes3mp addition End of tes3mp addition
*/ */
/*
Start of tes3mp addition
Allow the searching of objects by their reference numbers while ensuring
they have a certain refId
*/
Ptr searchExactPlus (std::string refId, unsigned int refNum, unsigned int mpNum);
/*
End of tes3mp addition
*/
/* /*
Start of tes3mp addition Start of tes3mp addition

Loading…
Cancel
Save