From 1af8da3e04bd0adfd86beda0d8128113676560c3 Mon Sep 17 00:00:00 2001 From: Tazpn <tazpn@users.sourceforge.net> Date: Sat, 21 Jul 2007 05:18:10 +0000 Subject: [PATCH] Update from xml and miscellaneous fixes in python script for strings. --- include/NIF_IO.h | 6 ++++++ include/nif_basic_types.h | 10 ++++++++++ include/obj/bhkBoxShape.h | 8 +------- include/obj/bhkCapsuleShape.h | 8 +------- src/NIF_IO.cpp | 20 ++++++++++++++++++++ src/obj/NiTextKeyExtraData.cpp | 12 ++---------- src/obj/bhkBoxShape.cpp | 17 ++++------------- src/obj/bhkCapsuleShape.cpp | 17 ++++------------- 8 files changed, 48 insertions(+), 50 deletions(-) diff --git a/include/NIF_IO.h b/include/NIF_IO.h index 773f196f..5f3e31bf 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 b987dfac..fb8af131 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 c2d156de..bb8190e4 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 264cf833..4498c08d 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 615b1e22..7787b0dc 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 edb80ba4..45f53075 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 31624002..ba8f695d 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 a8920983..a068ddfa 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; -- GitLab