From 3dd17c3ec46a0a12ee325e41b2018b312a2a71c7 Mon Sep 17 00:00:00 2001 From: Amorilia <amorilia@users.sourceforge.net> Date: Sat, 24 Sep 2011 17:09:41 +0100 Subject: [PATCH] Added target_root argument to clone functions. --- include/niflib.h | 3 ++- include/obj/NiObject.h | 3 ++- src/niflib.cpp | 2 +- src/obj/NiObject.cpp | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/niflib.h b/include/niflib.h index db1eab65..75ea8072 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 7553cad1..bcf0569c 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 b9c233c0..e8700930 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 deb2fb2f..1e567628 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; -- GitLab