diff --git a/NIF_IO.cpp b/NIF_IO.cpp index 39881899215fc046162166ba3055c7cf2fa68691..f74e1438d97e4cab981f05b51a9fb70f9d3bbc5f 100644 --- a/NIF_IO.cpp +++ b/NIF_IO.cpp @@ -625,3 +625,8 @@ void StreamQuatKey( Key<Quaternion> const & key, ostream& file, KeyType type ) { WriteFloat( key.continuity, file); } } + +//Byte +ostream & operator<<( ostream & out, byte const & val ) { + return out << uint(val); +} diff --git a/NIF_IO.h b/NIF_IO.h index e632404cb0cd0016b556b51b068c7aef639c88e8..027fbcb3dfb7a62282840ea21890110c9d8153ff 100644 --- a/NIF_IO.h +++ b/NIF_IO.h @@ -52,7 +52,7 @@ enum ExportOptions { }; -//--Non-mathamatical Basic Types--// +//--Non-mathematical Basic Types--// typedef unsigned char byte; typedef unsigned short ushort; @@ -434,4 +434,7 @@ void StreamQuatKey( Key<Quaternion> const & key, ostream& file, uint version, Ke //a debug string for information that is not understood string HexString( const byte * src, uint len ); +//Byte +ostream & operator<<( ostream & out, byte const & val ); + #endif diff --git a/niflib.cpp b/niflib.cpp index 6baf9f3fcb846f1a932573a43455cf94a37691e6..21b9aff49c489a325c0b8781ec12e64a82cab72b 100644 --- a/niflib.cpp +++ b/niflib.cpp @@ -1,6 +1,8 @@ /* Copyright (c) 2006, NIF File Format Library and Tools All rights reserved. Please see niflib.h for licence. */ +#define DEBUG // this will produce lot's of output + #include "niflib.h" #include "obj/NiAVObject.h" #include "obj/NiNode.h" @@ -146,9 +148,9 @@ vector<NiObjectRef> ReadNifList( istream & in ) { uint version = ReadUInt( in ); //There is an unknown Byte here from version 20.0.0.4 on - byte unknownByte; + byte endianType; if ( version >= VER_20_0_0_4 ) { - unknownByte = ReadByte( in ); + endianType = ReadByte( in ); } //There is an Unknown Int here from version 10.1.0.0 on @@ -185,35 +187,40 @@ vector<NiObjectRef> ReadNifList( istream & in ) { blockTypeIndex[i] = ReadUShort( in ); } - //uint unknownInt2 = + uint unknownInt2 = ReadUInt( in ); - ////Output + //Output +#ifdef DEBUG cout << endl << endl << "====[ " << "File Header ]====" << endl << "Header: " << header_string << endl << "Version: " << version << endl + << "Endian Type: " << endianType << endl << "User Version: " << userVersion << endl - << "Number of Blocks: " << int(numBlocks) << endl + << "Number of Blocks: " << numBlocks << endl << "Block Types: " << uint(blockTypes.size()) << endl; - //for ( uint i = 0; i < blockTypes.size(); ++i ) { - // cout << " " << i << ": " << blockTypes[i] << endl; - //} + for ( uint i = 0; i < blockTypes.size(); ++i ) { + cout << " " << i << ": " << blockTypes[i] << endl; + } - //cout << "Block Type Indices: " << numBlocks << endl; - //for ( uint i = 0; i < blockTypeIndex.size(); ++i ) { - // cout << " " << i + 1 << ": " << blockTypeIndex[i] << endl; - //} + cout << "Block Type Indices: " << numBlocks << endl; + for ( uint i = 0; i < blockTypeIndex.size(); ++i ) { + cout << " " << i + 1 << ": " << blockTypeIndex[i] << "(" << blockTypes[blockTypeIndex[i]] << ")" << endl; + } - //cout << "Unknown Int 2: " << unknownInt2 << endl; + cout << "Unknown Int 2: " << unknownInt2 << endl; +#endif } else { - ////Output - //cout << endl << endl - // << "====[ " << "File Header ]====" << endl - // << "Header: " << header_string << endl - // << "Version: " << Hex(version) << endl - // << "Number of Blocks: " << int(numBlocks) << endl; +#ifdef DEBUG + //Output + cout << endl << endl + << "====[ " << "File Header ]====" << endl + << "Header: " << header_string << endl + << "Version: " << version << endl + << "Number of Blocks: " << numBlocks << endl; +#endif } @@ -288,7 +295,7 @@ vector<NiObjectRef> ReadNifList( istream & in ) { //blocks[i]->SetBlockNum(i); blocks[i]->Read( in, link_stack, version ); - //cout << endl << blocks[i]->asString() << endl; + cout << endl << blocks[i]->asString() << endl; } //cout << endl;