From 877f8a18d3f49a8fa4f03888407ed46a9cc4a593 Mon Sep 17 00:00:00 2001 From: Shon Ferguson <shonferg@users.sourceforge.net> Date: Thu, 28 Sep 2006 17:21:48 +0000 Subject: [PATCH] Fixed strange bug. All files now load again, and Niflib is now destroying objects properly and reporting the right number of Objects from NiObject::NumObjectsInMemory. --- include/gen/obj_defines.h | 2 +- src/gen/Footer.cpp | 8 +++++++- src/gen/Header.cpp | 15 +++++++++++++-- src/niflib.cpp | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/include/gen/obj_defines.h b/include/gen/obj_defines.h index acd162ff..9fddef74 100644 --- a/include/gen/obj_defines.h +++ b/include/gen/obj_defines.h @@ -2057,7 +2057,7 @@ CompareMode function; \ #define NI_KEYFRAME_DATA_PARENT AKeyedData -#define NI_KEYFRAME_DATA_CONSTRUCT : numRotationKeys((uint)0), unknownFloat(0.0f) +#define NI_KEYFRAME_DATA_CONSTRUCT : numRotationKeys((uint)0), rotationType((KeyType)0), unknownFloat(0.0f) #define NI_LIGHT_COLOR_CONTROLLER_INCLUDE "NiTimeController.h" diff --git a/src/gen/Footer.cpp b/src/gen/Footer.cpp index 249bf618..21722373 100644 --- a/src/gen/Footer.cpp +++ b/src/gen/Footer.cpp @@ -34,14 +34,20 @@ void Footer::Write( ostream& out, map<NiObjectRef,uint> link_map, unsigned int v string Footer::asString( bool verbose ) const { stringstream out; + uint array_output_count = 0; numRoots = uint(roots.size()); out << " Num Roots: " << numRoots << endl; + array_output_count = 0; for (uint i1 = 0; i1 < roots.size(); i1++) { - if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { + if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; break; }; + if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { + break; + }; out << " Roots[" << i1 << "]: " << roots[i1] << endl; + array_output_count++; }; return out.str(); } diff --git a/src/gen/Header.cpp b/src/gen/Header.cpp index db066cab..3005a802 100644 --- a/src/gen/Header.cpp +++ b/src/gen/Header.cpp @@ -97,6 +97,7 @@ void Header::Write( ostream& out ) const { string Header::asString( bool verbose ) const { stringstream out; + uint array_output_count = 0; numBlockTypes = ushort(blockTypes.size()); numBlocks = uint(blockTypeIndex.size()); out << " Header String: " << headerString << endl; @@ -111,19 +112,29 @@ string Header::asString( bool verbose ) const { out << " Export Info 2: " << exportInfo2 << endl; }; out << " Num Block Types: " << numBlockTypes << endl; + array_output_count = 0; for (uint i1 = 0; i1 < blockTypes.size(); i1++) { - if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { + if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; break; }; + if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { + break; + }; out << " Block Types[" << i1 << "]: " << blockTypes[i1] << endl; + array_output_count++; }; + array_output_count = 0; for (uint i1 = 0; i1 < blockTypeIndex.size(); i1++) { - if ( !verbose && ( i1 > MAXARRAYDUMP ) ) { + if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { out << "<Data Truncated. Use verbose mode to see complete listing.>" << endl; break; }; + if ( !verbose && ( array_output_count > MAXARRAYDUMP ) ) { + break; + }; out << " Block Type Index[" << i1 << "]: " << blockTypeIndex[i1] << endl; + array_output_count++; }; out << " Unknown Int 2: " << unknownInt2 << endl; return out.str(); diff --git a/src/niflib.cpp b/src/niflib.cpp index 3f1e27bd..80f4de7e 100644 --- a/src/niflib.cpp +++ b/src/niflib.cpp @@ -2,7 +2,7 @@ All rights reserved. Please see niflib.h for licence. */ //#define DEBUG // this will produce lots of output -#define PRINT_OBJECT_NAMES +//#define PRINT_OBJECT_NAMES //#define PRINT_OBJECT_CONTENTS //#define DEBUG_LINK_PHASE //#define DEBUG_HEADER_FOOTER -- GitLab