diff --git a/NIF_Blocks.cpp b/NIF_Blocks.cpp index 08cf441c3d0a1d328015e866a8caec66056865f2..3ec8e620d57328a1fa4332bc5a8f5498bd23f2af 100644 --- a/NIF_Blocks.cpp +++ b/NIF_Blocks.cpp @@ -52,7 +52,7 @@ extern string current_file; * ABlock methods **********************************************************/ -ABlock::ABlock() : _ref_count(0), _block_num(-1) { +ABlock::ABlock() : _block_num(-1), _ref_count(0) { //Temporary to test reference counting blocks_in_memory++; } @@ -1080,7 +1080,7 @@ void AShapeData::Write( ofstream& out, unsigned int version ) const { WriteUShort( ushort(uv_sets.size()), out ); } // hasUVs does not exist after version 4.0.0.2 - bool hasUVs = true; + //bool hasUVs = true; if ( version <= VER_4_0_0_2 ) { //WriteBool( uv_sets.size() > 0, out, version ); // NifTexture bug workaround: @@ -1546,7 +1546,7 @@ void NiTriShapeData::Read( ifstream& in, unsigned int version ){ AShapeData::Read( in, version ); short numTriangles = ReadUShort( in ); - int numVertexIndices = ReadUInt( in ); + ReadUInt( in ); // numTriangles * 3, we can throw this away //From version 10.1.0.0 on there is a bool to check whether or not there are any triangles //We already know the answer to this from the numTriangles count, don't we? @@ -2007,7 +2007,6 @@ void NiSkinData::Write( ofstream& out, unsigned int version ) const { Bone bone; // temporary value map<IBlock *, Bone >::const_iterator it; - int num = 0; for( it = bone_map.begin(); it != bone_map.end(); ++it ) { //Calculae offset for this bone (data is not stored) CalculateBoneOffset( par_node, it->first, bone ); @@ -3994,6 +3993,9 @@ void NiPixelData::SetColors( const vector<Color4> & new_pixels, bool generate_mi // cin.get(); //#endif break; + case PX_FMT_PAL8: + throw runtime_error("The SetColors function only supports the PX_FMT_RGB8 and PX_FMT_RGBA8 pixel formats."); + break; } } } diff --git a/NIF_IO.h b/NIF_IO.h index f002330d68a3c4415b1229a7e8f56d5049ef7165..1c1573d857d7db2e048b9f3c22ad1f2b6a6f830c 100644 --- a/NIF_IO.h +++ b/NIF_IO.h @@ -319,7 +319,7 @@ public: nifIndex(){} ~nifIndex() {}; uint GetIndex() const { return _index; } - uint SetIndex( int index ) { + void SetIndex( int index ) { _index = index; } void Read( ifstream &in ) { diff --git a/SConstruct b/SConstruct index 2fb870292557793ada38f2f38dabac4d4b86de77..8afcecf1ac9e7365437b2ccd8c68e667e4278249 100644 --- a/SConstruct +++ b/SConstruct @@ -6,12 +6,12 @@ if sys.platform == 'linux2' or sys.platform == 'linux-i386': python_lib = ['python%d.%d' % sys.version_info[0:2]] python_libpath = [sysconfig.get_python_lib (0, 1) + '/config'] python_include = [sysconfig.get_python_inc ()] - cppflags = '-fPIC' + cppflags = '-fPIC -Wall' elif sys.platform == 'cygwin': python_lib = ['python%d.%d' % sys.version_info[0:2]] python_libpath = [sysconfig.get_python_lib (0, 1) + '/config'] python_include = [sysconfig.get_python_inc ()] - cppflags = '' + cppflags = '-Wall' elif sys.platform == 'win32': python_include = [sysconfig.get_python_inc()] python_libpath = [sysconfig.get_python_lib(1, 1) + '/../libs'] diff --git a/nif_attrs.h b/nif_attrs.h index 2c3570c0d7d2c237658c6bb5b9cc818640dc6f78..2c2d8494cea9d15d3aeff45b10ff2966b188b8fb 100644 --- a/nif_attrs.h +++ b/nif_attrs.h @@ -102,8 +102,8 @@ protected: class lnk_ref : public blk_ref { public: lnk_ref ( IBlock * owner) : _owner(owner) { /*cout << "Constructor " << endl;*/ InitLink(); } - lnk_ref( IBlock * owner, int index ) : _owner(owner), blk_ref(index) { /*cout << "Constructor " << endl;*/ InitLink(); } - lnk_ref( IBlock * owner, blk_ref block ) : _owner(owner), blk_ref(block) { /*cout << "Constructor " << endl;*/ InitLink(); } + lnk_ref( IBlock * owner, int index ) : blk_ref(index), _owner(owner) { /*cout << "Constructor " << endl;*/ InitLink(); } + lnk_ref( IBlock * owner, blk_ref block ) : blk_ref(block), _owner(owner) { /*cout << "Constructor " << endl;*/ InitLink(); } //Copy Constructors lnk_ref( const lnk_ref & rh ) { @@ -510,7 +510,7 @@ public: } } void WriteAttr( ofstream& out, unsigned int version ) const { - ISkinInstInternal * data = (ISkinInstInternal*)_owner->QueryInterface( SkinInstInternal ); + //ISkinInstInternal * data = (ISkinInstInternal*)_owner->QueryInterface( SkinInstInternal ); blk_ref data_blk = _owner->GetAttr("Data")->asLink(); if ( data_blk.is_null() == false ) { //Get Bone data from data block diff --git a/niflib.cpp b/niflib.cpp index 12dbaf2ce7436fbdc5118077e088718773d25bcb..661a2aa64276464cf5315173f7eefd6d5794e6ac 100644 --- a/niflib.cpp +++ b/niflib.cpp @@ -153,7 +153,8 @@ vector<blk_ref> ReadNifList( string const & file_name ) { blockTypeIndex[i] = ReadUShort( in ); } - uint unknownInt2 = ReadUInt( in ); + //uint unknownInt2 = + ReadUInt( in ); ////Output //cout << endl << endl @@ -262,15 +263,16 @@ vector<blk_ref> ReadNifList( string const & file_name ) { //cout << endl; //--Read Footer--// - uint unknownInt = ReadUInt( in ); - uint unknownInt2 = ReadUInt( in ); - + uint unknownCount = ReadUInt( in ); + for (uint i=0; i < unknownCount; i++) ReadUInt( in ); // throw away //Output //cout << "====[ NiFooter ]====" << endl << - // "Unknown Int 1: " << Hex(unknownInt) << endl << - // "Unknown Int 2: " << Hex(unknownInt2) << endl; - + // "Unknown Count: " << Hex(unknownCount) << endl; + ReadByte( in ); // this should fail, and trigger the in.eof() flag + if ( ! in.eof() ) + throw runtime_error("End of file not reached. This NIF may be corrupt or improperly supported."); + //--Close File--// in.close();