diff --git a/include/niflib.h b/include/niflib.h index db1eab657820005f02fc84f1c5ae0fc904007bfd..75ea807275ad17226a58c333955fba6002f20e38 100644 --- a/include/niflib.h +++ b/include/niflib.h @@ -204,9 +204,10 @@ NIFLIB_API void WriteFileGroup( string const & file_name, NiObject * root_object * \param[in] root The root object to start from when cloning the NIF data. All referenced objects will be included in the new tree. * \param[in] version The version of the NIF format to use when writing a file. Default is version 4.0.0.2. * \param[in] user_version The user version of the NIF format to use when writing a file. Default is user version 0. + * \param[in] target_root The root of the nif tree in which the cloned tree will be embedded. If specified, missing links will be resolved to that tree. * \return The root of the new cloned tree. */ -NIFLIB_API Ref<NiObject> CloneNifTree( NiObject * root, unsigned version = 0xFFFFFFFF, unsigned user_version = 0 ); +NIFLIB_API Ref<NiObject> CloneNifTree( NiObject * root, unsigned version = 0xFFFFFFFF, unsigned user_version = 0, NiObject * target_root = NULL ); //TODO: Figure out how to fix this to work with the new system diff --git a/include/obj/NiObject.h b/include/obj/NiObject.h index 7553cad1e1e44a652cb07ab4d29d64beb4ed7d42..bcf0569c962663637d119809daf40b1a22468eaa 100644 --- a/include/obj/NiObject.h +++ b/include/obj/NiObject.h @@ -74,9 +74,10 @@ public: * if you need to clone an obsolete piece of information. * \param[in] version The version number to use in the memory streaming operation. Default is the highest version availiable. * \param[in] user_version The game-specific version number extention. + * \param[in] target_root The root of the nif tree in which the cloned object will be embedded. If specified, missing links will be resolved to that tree. * \return A cloned copy of this object as a new object. */ - NIFLIB_API Ref<NiObject> Clone( unsigned int version = 0xFFFFFFFF, unsigned int user_version = 0 ); + NIFLIB_API Ref<NiObject> Clone( unsigned int version = 0xFFFFFFFF, unsigned int user_version = 0, NiObject *target_root = NULL ); public: /*! Block number in the nif file. Only set when you read diff --git a/src/niflib.cpp b/src/niflib.cpp index b9c233c0b0dfb7c5202714a217da6d013e11eee4..e8700930f0ae4882bf23c550933ab6877fd1a270 100644 --- a/src/niflib.cpp +++ b/src/niflib.cpp @@ -1295,7 +1295,7 @@ string FormatVersionString(unsigned version) { } -Ref<NiObject> CloneNifTree( NiObject * root, unsigned version, unsigned user_version ) { +Ref<NiObject> CloneNifTree( NiObject *root, unsigned version, unsigned user_version, NiObject *target_root ) { //Create a string stream to temporarily hold the state-save of this tree stringstream tmp; diff --git a/src/obj/NiObject.cpp b/src/obj/NiObject.cpp index deb2fb2f8165a33bdb37205dd8f7418076c34899..1e567628e525e8ef35199f1b648b1fc1e93272e3 100644 --- a/src/obj/NiObject.cpp +++ b/src/obj/NiObject.cpp @@ -96,7 +96,7 @@ std::list<NiObject *> NiObject::GetPtrs() const { //--BEGIN MISC CUSTOM CODE--// -NiObjectRef NiObject::Clone( unsigned int version, unsigned int user_version ) { +NiObjectRef NiObject::Clone( unsigned int version, unsigned int user_version, NiObject *target_root ) { //Create a string stream to temporarily hold the state-save of this object stringstream tmp;