forked from mirror/openmw-tes3mp
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;
|
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
|
namespace MWWorld
|
||||||
|
@ -436,7 +460,7 @@ namespace MWWorld
|
||||||
// Added by tes3mp
|
// Added by tes3mp
|
||||||
Ptr CellStore::searchByRefNum (ESM::RefNum refNum)
|
Ptr CellStore::searchByRefNum (ESM::RefNum refNum)
|
||||||
{
|
{
|
||||||
SearchByRefNumVisitor searchVisitor(refNum);
|
SearchByRefNumCustomVisitor<MWWorld::Ptr> searchVisitor(refNum);
|
||||||
forEach(searchVisitor);
|
forEach(searchVisitor);
|
||||||
return searchVisitor.mFound;
|
return searchVisitor.mFound;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue