Create SearchByRefNumCustomVisitor in CellStore that returns entire Ptr

This commit is contained in:
David Cernat 2016-10-22 17:47:21 +03:00
parent b3d6dad0c5
commit 40f1db2d86

View file

@ -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;
}