From c4b12611aeec6b64bf095eb9f99c2954acb37423 Mon Sep 17 00:00:00 2001
From: Tazpn <tazpn@users.sourceforge.net>
Date: Sun, 21 Dec 2008 02:26:25 +0000
Subject: [PATCH] niflib:  Fix issue with changes for new condition engine
 regarding userversion == 0.

---
 include/obj/NiGeometryData.h    | 3 +++
 src/obj/NiBoneLODController.cpp | 6 +++---
 src/obj/NiGeometryData.cpp      | 9 +++++++++
 src/obj/NiMorphData.cpp         | 4 ++--
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/include/obj/NiGeometryData.h b/include/obj/NiGeometryData.h
index 1740a4e9..42fcc084 100644
--- a/include/obj/NiGeometryData.h
+++ b/include/obj/NiGeometryData.h
@@ -63,6 +63,9 @@ protected:
 	vector<int > vertexIndices;
 public:
 
+	NIFLIB_API string GetName();
+	NIFLIB_API void SetName( const string & new_name );
+
 	//--Counts--//
 
 	/*! 
diff --git a/src/obj/NiBoneLODController.cpp b/src/obj/NiBoneLODController.cpp
index 240da183..d54a6477 100644
--- a/src/obj/NiBoneLODController.cpp
+++ b/src/obj/NiBoneLODController.cpp
@@ -63,7 +63,7 @@ void NiBoneLODController::Read( istream& in, list<unsigned int> & link_stack, co
 			link_stack.push_back( block_num );
 		};
 	};
-	if ( info.version >= 0x04020200 ) {
+	if ( ( info.version >= 0x04020200 ) && ( info.userVersion == 0 ) ) {
 		NifStream( numShapeGroups, in, info );
 		shapeGroups1.resize(numShapeGroups);
 		for (unsigned int i2 = 0; i2 < shapeGroups1.size(); i2++) {
@@ -114,7 +114,7 @@ void NiBoneLODController::Write( ostream& out, const map<NiObjectRef,unsigned in
 			}
 		};
 	};
-	if ( info.version >= 0x04020200 ) {
+	if ( ( info.version >= 0x04020200 ) && ( info.userVersion == 0 ) ) {
 		NifStream( numShapeGroups, out, info );
 		for (unsigned int i2 = 0; i2 < shapeGroups1.size(); i2++) {
 			shapeGroups1[i2].numLinkPairs = (unsigned int)(shapeGroups1[i2].linkPairs.size());
@@ -240,7 +240,7 @@ void NiBoneLODController::FixLinks( const map<unsigned int,NiObjectRef> & object
 			nodeGroups[i1].nodes[i2] = FixLink<NiNode>( objects, link_stack, info );
 		};
 	};
-	if ( info.version >= 0x04020200 ) {
+	if ( ( info.version >= 0x04020200 ) && ( info.userVersion == 0 ) ) {
 		for (unsigned int i2 = 0; i2 < shapeGroups1.size(); i2++) {
 			for (unsigned int i3 = 0; i3 < shapeGroups1[i2].linkPairs.size(); i3++) {
 				shapeGroups1[i2].linkPairs[i3].shape = FixLink<NiTriBasedGeom>( objects, link_stack, info );
diff --git a/src/obj/NiGeometryData.cpp b/src/obj/NiGeometryData.cpp
index 9bf10152..25ff5316 100644
--- a/src/obj/NiGeometryData.cpp
+++ b/src/obj/NiGeometryData.cpp
@@ -408,6 +408,15 @@ static void CalcCenteredSphere(const vector<Vector3>& vertices, Vector3& center,
 	}
 }
 
+
+string NiGeometryData::GetName() {
+	return name;
+}
+
+void NiGeometryData::SetName( const string & new_name ) {
+	name = new_name;
+}
+
 int NiGeometryData::GetVertexCount() const {
 	return int(vertices.size());
 }
diff --git a/src/obj/NiMorphData.cpp b/src/obj/NiMorphData.cpp
index 29d794c6..09322294 100644
--- a/src/obj/NiMorphData.cpp
+++ b/src/obj/NiMorphData.cpp
@@ -62,7 +62,7 @@ void NiMorphData::Read( istream& in, list<unsigned int> & link_stack, const NifI
 		if ( ( info.version >= 0x0A01006A ) && ( info.version <= 0x0A020000 ) ) {
 			NifStream( morphs[i1].unknownInt, in, info );
 		};
-		if ( ( info.version >= 0x14000004 ) && ( info.version <= 0x14010003 ) ) {
+		if ( ( info.version >= 0x14000004 ) && ( info.version <= 0x14010003 ) && ( info.userVersion == 0 ) ) {
 			NifStream( morphs[i1].unknownInt, in, info );
 		};
 		morphs[i1].vectors.resize(numVertices);
@@ -99,7 +99,7 @@ void NiMorphData::Write( ostream& out, const map<NiObjectRef,unsigned int> & lin
 		if ( ( info.version >= 0x0A01006A ) && ( info.version <= 0x0A020000 ) ) {
 			NifStream( morphs[i1].unknownInt, out, info );
 		};
-		if ( ( info.version >= 0x14000004 ) && ( info.version <= 0x14010003 ) ) {
+		if ( ( info.version >= 0x14000004 ) && ( info.version <= 0x14010003 ) && ( info.userVersion == 0 ) ) {
 			NifStream( morphs[i1].unknownInt, out, info );
 		};
 		for (unsigned int i2 = 0; i2 < morphs[i1].vectors.size(); i2++) {
-- 
GitLab