diff --git a/include/NIF_IO.h b/include/NIF_IO.h index 773f196fa60b91c6bd6e583930baa24a6dbba7cc..5f3e31bf447e4c46bdf72ba124f06b0c7e2d82ff 100644 --- a/include/NIF_IO.h +++ b/include/NIF_IO.h @@ -200,6 +200,12 @@ void NifStream( IndexString & val, istream& in, const NifInfo & info ); void NifStream( IndexString const & val, ostream& out, const NifInfo & info ); ostream & operator<<( ostream & out, IndexString const & val ); +//Char8String +void NifStream( Char8String & val, istream& in, const NifInfo & info ); +void NifStream( Char8String const & val, ostream& out, const NifInfo & info ); +ostream & operator<<( ostream & out, Char8String const & val ); + + //--Templates--// void NifStream( Key<Quaternion> & key, istream& file, const NifInfo & info, KeyType type ); diff --git a/include/nif_basic_types.h b/include/nif_basic_types.h index b987dfacbfc2c187171617bc120cc36c5772bd96..fb8af131781f591bcd66cba825c0054fd61cecbd 100644 --- a/include/nif_basic_types.h +++ b/include/nif_basic_types.h @@ -33,6 +33,16 @@ struct IndexString : public std::string { operator std::string &() { return *this; } }; +struct Char8String : public std::string { + Char8String() {} + Char8String( const Char8String & ref ) : std::string((std::string const &)ref) {} + Char8String( const std::string & ref ) : std::string(ref) {} + Char8String& operator=( const Char8String & ref ) { assign((std::string const &)ref); return *this; } + Char8String& operator=( const std::string & ref ) { assign(ref); return *this; } + operator std::string const &() const { return *this; } + operator std::string &() { return *this; } +}; + //--Non-mathematical Basic Types--// #ifndef byte typedef unsigned char byte; diff --git a/include/obj/bhkBoxShape.h b/include/obj/bhkBoxShape.h index c2d156debdf0e8e3d07431f42b8e6530d55d507f..bb8190e4f7058dbfaf03324513d06264e2a302da 100644 --- a/include/obj/bhkBoxShape.h +++ b/include/obj/bhkBoxShape.h @@ -69,13 +69,7 @@ public: //--END CUSTOM CODE--// protected: /*! Unknown. */ - unsigned short unknownShort1; - /*! Unknown. */ - unsigned short unknownShort2; - /*! Unknown. */ - unsigned short unknownShort3; - /*! Unknown. */ - unsigned short unknownShort4; + Char8String unknownString; /*! Looks like this could be the box size. */ Vector3 dimensions; /*! The smallest of the three sizes. Might be used for optimization. */ diff --git a/include/obj/bhkCapsuleShape.h b/include/obj/bhkCapsuleShape.h index 264cf833d61de316a312941e15bef7372849edb2..4498c08d35f918d7e502ff2b8fd41f05a08e1660 100644 --- a/include/obj/bhkCapsuleShape.h +++ b/include/obj/bhkCapsuleShape.h @@ -117,13 +117,7 @@ public: //--END CUSTOM CODE--// protected: /*! Unknown. */ - unsigned short unknownShort1; - /*! Unknown. */ - unsigned short unknownShort2; - /*! Unknown. */ - unsigned short unknownShort3; - /*! Unknown. */ - unsigned short unknownShort4; + Char8String unknownString; /*! First point on the capsule's axis. */ Vector3 firstPoint; /*! Matches first capsule radius. */ diff --git a/src/NIF_IO.cpp b/src/NIF_IO.cpp index 615b1e22abb754081ee5bc9e0f3f21fb84cc4e23..7787b0dc5276b9c7b7ccede355585fdda24f196d 100644 --- a/src/NIF_IO.cpp +++ b/src/NIF_IO.cpp @@ -803,4 +803,24 @@ std::streampos NifStreamBuf::seekpos(std::streampos offset, std::ios_base::openm return (pos >= 0 && pos < size) ? (streampos(-1)) : pos; } +void NifStream( Char8String & val, istream& in, const NifInfo & info ) { + val.resize(8, '\x0'); + for (int i=0; i<8; ++i) + in.read( &val[i], 1 ); +} + +void NifStream( Char8String const & val, ostream& out, const NifInfo & info ) { + size_t i = 0, n = std::min<size_t>(8, val.size()); + for (i=0;i<n;++i) + out.write( &val[i], 1 ); + for (;i<8;++i) + out.write( "\x0", 1 ); +} + +ostream & operator<<( ostream & out, Char8String const & val ) { + out << static_cast<string const &>(val); + return out; +} + + } \ No newline at end of file diff --git a/src/obj/NiTextKeyExtraData.cpp b/src/obj/NiTextKeyExtraData.cpp index edb80ba4e812718d925d64fcbbdfa1a897d71416..45f53075e017bd12428b23dd4eeb02201d99da12 100644 --- a/src/obj/NiTextKeyExtraData.cpp +++ b/src/obj/NiTextKeyExtraData.cpp @@ -46,17 +46,9 @@ void NiTextKeyExtraData::Read( istream& in, list<unsigned int> & link_stack, con NifStream( unknownInt1, in, info ); }; NifStream( numTextKeys, in, info ); - if ( info.version >= 0x14010003 ) { textKeys.resize(numTextKeys); - for (unsigned int i2 = 0; i2 < textKeys.size(); i2++) { - NifStream( textKeys[i2], in, info, 1 ); - }; - }; - if ( info.version <= 0x14000005 ) { - textKeys.resize(numTextKeys); - for (unsigned int i2 = 0; i2 < textKeys.size(); i2++) { - NifStream( textKeys[i2], in, info, 1 ); - }; + for (unsigned int i1 = 0; i1 < textKeys.size(); i1++) { + NifStream( textKeys[i1], in, info, 1 ); }; //--BEGIN POST-READ CUSTOM CODE--// diff --git a/src/obj/bhkBoxShape.cpp b/src/obj/bhkBoxShape.cpp index 31624002b8abbaf4bd62a75bca8e2ed958c0e41b..ba8f695d6a3d1f22cd539ce3436617a8f03c3871 100644 --- a/src/obj/bhkBoxShape.cpp +++ b/src/obj/bhkBoxShape.cpp @@ -19,7 +19,7 @@ using namespace Niflib; //Definition of TYPE constant const Type bhkBoxShape::TYPE("bhkBoxShape", &bhkConvexShape::TYPE ); -bhkBoxShape::bhkBoxShape() : unknownShort1((unsigned short)0), unknownShort2((unsigned short)0), unknownShort3((unsigned short)0), unknownShort4((unsigned short)0), minimumSize(0.0f) { +bhkBoxShape::bhkBoxShape() : minimumSize(0.0f) { //--BEGIN CONSTRUCTOR CUSTOM CODE--// //--END CUSTOM CODE--// } @@ -42,10 +42,7 @@ void bhkBoxShape::Read( istream& in, list<unsigned int> & link_stack, const NifI //--END CUSTOM CODE--// bhkConvexShape::Read( in, link_stack, info ); - NifStream( unknownShort1, in, info ); - NifStream( unknownShort2, in, info ); - NifStream( unknownShort3, in, info ); - NifStream( unknownShort4, in, info ); + NifStream( unknownString, in, info ); NifStream( dimensions, in, info ); NifStream( minimumSize, in, info ); @@ -58,10 +55,7 @@ void bhkBoxShape::Write( ostream& out, const map<NiObjectRef,unsigned int> & lin //--END CUSTOM CODE--// bhkConvexShape::Write( out, link_map, info ); - NifStream( unknownShort1, out, info ); - NifStream( unknownShort2, out, info ); - NifStream( unknownShort3, out, info ); - NifStream( unknownShort4, out, info ); + NifStream( unknownString, out, info ); NifStream( dimensions, out, info ); NifStream( minimumSize, out, info ); @@ -76,10 +70,7 @@ std::string bhkBoxShape::asString( bool verbose ) const { stringstream out; unsigned int array_output_count = 0; out << bhkConvexShape::asString(); - out << " Unknown Short 1: " << unknownShort1 << endl; - out << " Unknown Short 2: " << unknownShort2 << endl; - out << " Unknown Short 3: " << unknownShort3 << endl; - out << " Unknown Short 4: " << unknownShort4 << endl; + out << " Unknown String: " << unknownString << endl; out << " Dimensions: " << dimensions << endl; out << " Minimum Size: " << minimumSize << endl; return out.str(); diff --git a/src/obj/bhkCapsuleShape.cpp b/src/obj/bhkCapsuleShape.cpp index a89209830781f49fa7383e71896f8e0ba16b9179..a068ddfae6e20f39b80c0a42c2b951c89f5d8a5b 100644 --- a/src/obj/bhkCapsuleShape.cpp +++ b/src/obj/bhkCapsuleShape.cpp @@ -19,7 +19,7 @@ using namespace Niflib; //Definition of TYPE constant const Type bhkCapsuleShape::TYPE("bhkCapsuleShape", &bhkConvexShape::TYPE ); -bhkCapsuleShape::bhkCapsuleShape() : unknownShort1((unsigned short)0), unknownShort2((unsigned short)0), unknownShort3((unsigned short)0), unknownShort4((unsigned short)0), radius1(0.0f), radius2(0.0f) { +bhkCapsuleShape::bhkCapsuleShape() : radius1(0.0f), radius2(0.0f) { //--BEGIN CONSTRUCTOR CUSTOM CODE--// //--END CUSTOM CODE--// } @@ -42,10 +42,7 @@ void bhkCapsuleShape::Read( istream& in, list<unsigned int> & link_stack, const //--END CUSTOM CODE--// bhkConvexShape::Read( in, link_stack, info ); - NifStream( unknownShort1, in, info ); - NifStream( unknownShort2, in, info ); - NifStream( unknownShort3, in, info ); - NifStream( unknownShort4, in, info ); + NifStream( unknownString, in, info ); NifStream( firstPoint, in, info ); NifStream( radius1, in, info ); NifStream( secondPoint, in, info ); @@ -60,10 +57,7 @@ void bhkCapsuleShape::Write( ostream& out, const map<NiObjectRef,unsigned int> & //--END CUSTOM CODE--// bhkConvexShape::Write( out, link_map, info ); - NifStream( unknownShort1, out, info ); - NifStream( unknownShort2, out, info ); - NifStream( unknownShort3, out, info ); - NifStream( unknownShort4, out, info ); + NifStream( unknownString, out, info ); NifStream( firstPoint, out, info ); NifStream( radius1, out, info ); NifStream( secondPoint, out, info ); @@ -80,10 +74,7 @@ std::string bhkCapsuleShape::asString( bool verbose ) const { stringstream out; unsigned int array_output_count = 0; out << bhkConvexShape::asString(); - out << " Unknown Short 1: " << unknownShort1 << endl; - out << " Unknown Short 2: " << unknownShort2 << endl; - out << " Unknown Short 3: " << unknownShort3 << endl; - out << " Unknown Short 4: " << unknownShort4 << endl; + out << " Unknown String: " << unknownString << endl; out << " First Point: " << firstPoint << endl; out << " Radius 1: " << radius1 << endl; out << " Second Point: " << secondPoint << endl;