forked from teamnwah/openmw-tes3coop
Create SearchByRefNumCustomVisitor in CellStore that returns entire Ptr
This commit is contained in:
parent
b3d6dad0c5
commit
40f1db2d86
1 changed files with 25 additions and 1 deletions
|
@ -168,6 +168,30 @@ namespace
|
|||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// Added by tes3mp
|
||||
template <typename PtrType>
|
||||
struct SearchByRefNumCustomVisitor
|
||||
{
|
||||
PtrType mFound;
|
||||
ESM::RefNum mRefNumToFind;
|
||||
|
||||
SearchByRefNumCustomVisitor(const ESM::RefNum& toFind)
|
||||
: mFound(NULL)
|
||||
, mRefNumToFind(toFind)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator()(const PtrType& ptr)
|
||||
{
|
||||
if (ptr.getCellRef().getRefNum() == mRefNumToFind)
|
||||
{
|
||||
mFound = ptr;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
|
@ -436,7 +460,7 @@ namespace MWWorld
|
|||
// Added by tes3mp
|
||||
Ptr CellStore::searchByRefNum (ESM::RefNum refNum)
|
||||
{
|
||||
SearchByRefNumVisitor searchVisitor(refNum);
|
||||
SearchByRefNumCustomVisitor<MWWorld::Ptr> searchVisitor(refNum);
|
||||
forEach(searchVisitor);
|
||||
return searchVisitor.mFound;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue