diff --git a/include/niflib.h b/include/niflib.h index f23354333d256228f41274ecff4dcd48e879974d..a14357d97febbe9043193cec00b61f8a8c8aa701 100644 --- a/include/niflib.h +++ b/include/niflib.h @@ -121,7 +121,7 @@ NIFLIB_API list<Ref<NiObject> > ProcessMissingLinkStack( * \param info Optionally, a NifInfo structure pointer can be passed in, and it will be filled with information from the header of the NIF file. * \return All the NIF objects read from the stream. */ -NIFLIB_API vector<Ref<NiObject> > ReadNifList( istream & in, const list<Ref<NiObject> > & missing_link_stack, NifInfo * info ); +NIFLIB_API vector<Ref<NiObject> > ReadNifList( istream & in, list<Ref<NiObject> > & missing_link_stack, NifInfo * info ); /*! * Reads the given file by file name and returns a vector of object references diff --git a/src/niflib.cpp b/src/niflib.cpp index 033551921072da21f15fda1e64c2ed61b1a5d04a..9c57398514b8a473510a1351b3096ffabb83c3e1 100644 --- a/src/niflib.cpp +++ b/src/niflib.cpp @@ -123,7 +123,7 @@ vector<NiObjectRef> ReadNifList( istream & in, NifInfo * info ) { return ReadNifList(in, missing_link_stack, info); } -vector<NiObjectRef> ReadNifList( istream & in, const list<NiObjectRef> & missing_link_stack, NifInfo * info ) { +vector<NiObjectRef> ReadNifList( istream & in, list<NiObjectRef> & missing_link_stack, NifInfo * info ) { //Ensure that objects are registered if ( g_objects_registered == false ) { @@ -410,6 +410,14 @@ NiObjectRef _ProcessMissingLinkStackHelper(NiObjectRef root, NiObject *obj) { if (!(rootnode->GetName().empty()) && rootnode->GetName() == objnode->GetName()) { return StaticCast<NiObject>(rootnode); } + } else if (root != NULL) { + list<NiObjectRef> children = root->GetRefs(); + for (list<NiObjectRef>::iterator child = children.begin(); child != children.end(); ++child) { + NiObjectRef result = _ProcessMissingLinkStackHelper(*child, obj); + if (result != NULL) { + return result; + } + } } // nothing found return NiObjectRef();