From c6abad8e764edab5ab96d46fedb06575396393ee Mon Sep 17 00:00:00 2001 From: Amorilia <amorilia@users.sourceforge.net> Date: Tue, 30 May 2006 00:52:45 +0000 Subject: [PATCH] Fixed something I broke on last commit + another update to XML in ByteArray: niflyze now reads Oblivion files :-) --- NIF_IO.cpp | 4 +++- SConstruct | 4 ++++ niflib.cpp | 16 ++++++++-------- xml_extract.h | 8 ++++---- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/NIF_IO.cpp b/NIF_IO.cpp index 3f706471..39881899 100644 --- a/NIF_IO.cpp +++ b/NIF_IO.cpp @@ -119,8 +119,10 @@ float ReadFloat( istream &in ){ string ReadString( istream &in ) { uint len = ReadUInt( in ); string out; + if ( len > 3000 ) + throw runtime_error("String too long. Not a NIF file or unsupported format?"); if ( len > 0 ) { - out.resize( len ); + out.resize(len); in.read( (char*)&out[0], len ); } return out; diff --git a/SConstruct b/SConstruct index 2b034b68..a1fad259 100644 --- a/SConstruct +++ b/SConstruct @@ -31,6 +31,10 @@ else: env = Environment(ENV = os.environ) +# force MD5 signatures to check for rebuilds + +SourceSignatures('MD5') + # detect SWIG try: env['SWIG'] diff --git a/niflib.cpp b/niflib.cpp index 5e9dee31..6baf9f3f 100644 --- a/niflib.cpp +++ b/niflib.cpp @@ -189,13 +189,13 @@ vector<NiObjectRef> ReadNifList( istream & in ) { ReadUInt( in ); ////Output - //cout << endl << endl - // << "====[ " << "File Header ]====" << endl - // << "Header: " << header_string << endl - // << "Version: " << Hex(version) << endl - // << "Unknown Int 1: " << unknownInt1 << endl - // << "Number of Blocks: " << int(numBlocks) << endl - // << "Block Types: " << uint(blockTypes.size()) << endl; + cout << endl << endl + << "====[ " << "File Header ]====" << endl + << "Header: " << header_string << endl + << "Version: " << version << endl + << "User Version: " << userVersion << endl + << "Number of Blocks: " << int(numBlocks) << endl + << "Block Types: " << uint(blockTypes.size()) << endl; //for ( uint i = 0; i < blockTypes.size(); ++i ) { // cout << " " << i << ": " << blockTypes[i] << endl; @@ -267,7 +267,7 @@ vector<NiObjectRef> ReadNifList( istream & in ) { } } - //cout << endl << i << ": " << blockName; + cout << endl << i << ": " << blockName; //Create Block of the type that was found blocks[i] = CreateBlock(blockName); diff --git a/xml_extract.h b/xml_extract.h index bfcafe85..fe189e3f 100644 --- a/xml_extract.h +++ b/xml_extract.h @@ -4552,7 +4552,7 @@ ByteArray binaryData; \ #define NI_BINARY_EXTRA_DATA_READ \ NiExtraData::Read( in, link_stack, version ); \ NifStream( binaryData.dataSize, in, version ); \ -if ( version >= 0x14000004 ) { \ +if ( ( version >= 0x14000004 ) && ( version <= 0x14000004 ) ) { \ NifStream( binaryData.unknownInt, in, version ); \ }; \ binaryData.data.resize(binaryData.dataSize); \ @@ -4563,7 +4563,7 @@ for (uint i0 = 0; i0 < binaryData.dataSize; i0++) { \ #define NI_BINARY_EXTRA_DATA_WRITE \ NiExtraData::Write( out, link_map, version ); \ NifStream( binaryData.dataSize, out, version ); \ -if ( version >= 0x14000004 ) { \ +if ( ( version >= 0x14000004 ) && ( version <= 0x14000004 ) ) { \ NifStream( binaryData.unknownInt, out, version ); \ }; \ for (uint i0 = 0; i0 < binaryData.dataSize; i0++) { \ @@ -8714,7 +8714,7 @@ for (uint i0 = 0; i0 < numMipmaps; i0++) { \ NifStream( mipmaps[i0].offset, in, version ); \ }; \ NifStream( pixelData.dataSize, in, version ); \ -if ( version >= 0x14000004 ) { \ +if ( ( version >= 0x14000004 ) && ( version <= 0x14000004 ) ) { \ NifStream( pixelData.unknownInt, in, version ); \ }; \ pixelData.data.resize(pixelData.dataSize); \ @@ -8752,7 +8752,7 @@ for (uint i0 = 0; i0 < numMipmaps; i0++) { \ NifStream( mipmaps[i0].offset, out, version ); \ }; \ NifStream( pixelData.dataSize, out, version ); \ -if ( version >= 0x14000004 ) { \ +if ( ( version >= 0x14000004 ) && ( version <= 0x14000004 ) ) { \ NifStream( pixelData.unknownInt, out, version ); \ }; \ for (uint i0 = 0; i0 < pixelData.dataSize; i0++) { \ -- GitLab