From 40f1db2d8689a8d2242f9448e2a453bc385ed042 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sat, 22 Oct 2016 17:47:21 +0300 Subject: [PATCH] Create SearchByRefNumCustomVisitor in CellStore that returns entire Ptr --- apps/openmw/mwworld/cellstore.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index c3f2dca42..6be2075c4 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -168,6 +168,30 @@ namespace return true; } }; + + // Added by tes3mp + template + 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 searchVisitor(refNum); forEach(searchVisitor); return searchVisitor.mFound; }