mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-05 18:19:41 +00:00
[Client] Add a new type of search to CellStore that also checks refIds
This commit is contained in:
parent
ca96827ec9
commit
646ffc7afe
2 changed files with 61 additions and 0 deletions
|
@ -624,6 +624,36 @@ namespace MWWorld
|
|||
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
|
||||
|
||||
|
@ -643,6 +673,26 @@ namespace MWWorld
|
|||
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
|
||||
|
||||
|
|
|
@ -269,6 +269,17 @@ namespace MWWorld
|
|||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue