diff --git a/pandatool/src/flt/config_flt.cxx b/pandatool/src/flt/config_flt.cxx index 25f2a62746..1df839bf17 100644 --- a/pandatool/src/flt/config_flt.cxx +++ b/pandatool/src/flt/config_flt.cxx @@ -33,6 +33,7 @@ #include Configure(config_flt); +NotifyCategoryDef(flt, ""); // Set this true to trigger an assertion failure (and core dump) // immediately when an error is detected on reading or writing a flt diff --git a/pandatool/src/flt/config_flt.h b/pandatool/src/flt/config_flt.h index 538004cb9e..05b9f47f3b 100644 --- a/pandatool/src/flt/config_flt.h +++ b/pandatool/src/flt/config_flt.h @@ -6,6 +6,12 @@ #ifndef CONFIG_FLT_H #define CONFIG_FLT_H +#include + +#include + +NotifyCategoryDecl(flt, EXPCL_MISC, EXPTP_MISC); + extern const bool flt_error_abort; #endif diff --git a/pandatool/src/flt/fltRecord.cxx b/pandatool/src/flt/fltRecord.cxx index 2dc7000792..d033c595a7 100644 --- a/pandatool/src/flt/fltRecord.cxx +++ b/pandatool/src/flt/fltRecord.cxx @@ -509,10 +509,8 @@ read_record_and_children(FltRecordReader &reader) { } // Skip to the next record. If that's the end, fine. - result = reader.advance(); - if (result == FE_end_of_file) { - return FE_ok; - } else if (result != FE_ok) { + result = reader.advance(true); + if (reader.eof() || result != FE_ok) { return result; } } diff --git a/pandatool/src/flt/fltRecordReader.cxx b/pandatool/src/flt/fltRecordReader.cxx index da4bf1a1ed..8ba6cc7913 100644 --- a/pandatool/src/flt/fltRecordReader.cxx +++ b/pandatool/src/flt/fltRecordReader.cxx @@ -96,7 +96,7 @@ get_record_length() const { // file has been reached. //////////////////////////////////////////////////////////////////// FltError FltRecordReader:: -advance() { +advance(bool ok_eof) { if (_state == S_eof) { assert(!flt_error_abort); return FE_end_of_file; @@ -118,6 +118,9 @@ advance() { if (_in.eof()) { _state = S_eof; + if (ok_eof) { + return FE_ok; + } assert(!flt_error_abort); return FE_end_of_file; @@ -133,7 +136,10 @@ advance() { _opcode = (FltOpcode)dgi.get_be_int16(); _record_length = dgi.get_be_uint16(); - // cerr << "Reading " << _opcode << " of length " << _record_length << "\n"; + if (flt_cat.is_debug()) { + flt_cat.debug() + << "Reading " << _opcode << " of length " << _record_length << "\n"; + } // And now read the full record based on the length. int length = _record_length - header_size; diff --git a/pandatool/src/flt/fltRecordReader.h b/pandatool/src/flt/fltRecordReader.h index 91783b2bcc..a60a54a563 100644 --- a/pandatool/src/flt/fltRecordReader.h +++ b/pandatool/src/flt/fltRecordReader.h @@ -32,7 +32,7 @@ public: const Datagram &get_datagram(); int get_record_length() const; - FltError advance(); + FltError advance(bool ok_eof = false); bool eof() const; bool error() const; diff --git a/pandatool/src/flt/fltRecordWriter.cxx b/pandatool/src/flt/fltRecordWriter.cxx index f5eb64edcf..27446b17f4 100644 --- a/pandatool/src/flt/fltRecordWriter.cxx +++ b/pandatool/src/flt/fltRecordWriter.cxx @@ -76,7 +76,11 @@ update_datagram() { //////////////////////////////////////////////////////////////////// FltError FltRecordWriter:: advance() { - // cerr << "Writing " << _opcode << " of length " << _datagram.get_length() << "\n"; + if (flt_cat.is_debug()) { + flt_cat.debug() + << "Writing " << _opcode << " of length " + << _datagram.get_length() << "\n"; + } // Build a mini-datagram to write the header. static const int header_size = 4;