From 3fce3f2f5eeeff4f8e802f83b01d4aecf83e6948 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 6 Feb 2001 01:02:38 +0000 Subject: [PATCH] *** empty log message *** --- pandatool/src/eggbase/eggMultiBase.cxx | 10 ++++++- pandatool/src/eggbase/eggReader.cxx | 10 ++++++- pandatool/src/flt/fltHeader.cxx | 38 +++++++++++++++++++++++++- pandatool/src/flt/fltHeader.h | 1 + pandatool/src/flt/test_flt.cxx | 2 ++ pandatool/src/fltprogs/fltCopy.cxx | 2 ++ 6 files changed, 60 insertions(+), 3 deletions(-) diff --git a/pandatool/src/eggbase/eggMultiBase.cxx b/pandatool/src/eggbase/eggMultiBase.cxx index 7d2a4d64f5..ba9785c57c 100644 --- a/pandatool/src/eggbase/eggMultiBase.cxx +++ b/pandatool/src/eggbase/eggMultiBase.cxx @@ -100,7 +100,15 @@ append_command_comment(EggData &data) { EggData *EggMultiBase:: read_egg(const Filename &filename) { EggData *data = new EggData; - if (!data->read(filename)) { + + // First, we always try to resolve a filename from the current + // directory. This means a local filename will always be found + // before the model path is searched. + Filename local_filename = filename; + DSearchPath local_path("."); + local_filename.resolve_filename(local_path); + + if (!data->read(local_filename)) { // Failure reading. delete data; return (EggData *)NULL; diff --git a/pandatool/src/eggbase/eggReader.cxx b/pandatool/src/eggbase/eggReader.cxx index b23fd9bf35..5d16d31d2f 100644 --- a/pandatool/src/eggbase/eggReader.cxx +++ b/pandatool/src/eggbase/eggReader.cxx @@ -43,9 +43,17 @@ handle_args(ProgramBase::Args &args) { // Any separate egg files that are listed on the command line will // get implicitly loaded up into one big egg file. + DSearchPath local_path("."); + Args::const_iterator ai; for (ai = args.begin(); ai != args.end(); ++ai) { - if (!_data.read(*ai)) { + Filename filename = *ai; + // First, we always try to resolve a filename from the current + // directory. This means a local filename will always be found + // before the model path is searched. + filename.resolve_filename(local_path); + + if (!_data.read(filename)) { // Rather than returning false, we simply exit here, so the // ProgramBase won't try to tell the user how to run the program // just because we got a bad egg file. diff --git a/pandatool/src/flt/fltHeader.cxx b/pandatool/src/flt/fltHeader.cxx index ddd8be3c04..0bee30f49b 100644 --- a/pandatool/src/flt/fltHeader.cxx +++ b/pandatool/src/flt/fltHeader.cxx @@ -242,6 +242,42 @@ max_flt_version() { return 15.2; } +//////////////////////////////////////////////////////////////////// +// Function: FltHeader::check_version +// Access: Public +// Description: Verifies that the version number read from the header +// is an understand version number, and prints a warning +// to the user if this is not so--the reading may or may +// not succeed. Returns true if the version number is +// acceptable (and no warning is printed), or false if +// it is questionable (and a warning is printed). +//////////////////////////////////////////////////////////////////// +bool FltHeader:: +check_version() const { + double version = get_flt_version(); + + if (version < min_flt_version()) { + nout << "Warning! The version number of this file appears to be " + << version << ", which is older than " << min_flt_version() + << ", the oldest OpenFlight version understood by this program. " + "It is unlikely that this program will be able to read the file " + "correctly.\n"; + return false; + } + + if (version > max_flt_version()) { + nout << "Warning! The version number of this file appears to be " + << version << ", which is newer than " << max_flt_version() + << ", the newest OpenFlight version understood by this program. " + "Chances are good that the program will still be able to read it " + "correctly, but any features in the file that are specific to " + "the latest version of OpenFlight will not be understood.\n"; + return false; + } + + return true; +} + //////////////////////////////////////////////////////////////////// // Function: FltHeader::has_instance // Access: Public @@ -1111,7 +1147,7 @@ extract_record(FltRecordReader &reader) { // Undocumented additional padding. iterator.skip_bytes(4); - nassertr(iterator.get_remaining_size() == 0, true); + // nassertr(iterator.get_remaining_size() == 0, true); return true; } diff --git a/pandatool/src/flt/fltHeader.h b/pandatool/src/flt/fltHeader.h index a3b04ef914..d4cc4a0bbf 100644 --- a/pandatool/src/flt/fltHeader.h +++ b/pandatool/src/flt/fltHeader.h @@ -125,6 +125,7 @@ public: double get_flt_version() const; static double min_flt_version(); static double max_flt_version(); + bool check_version() const; // Accessors into the instance pool. diff --git a/pandatool/src/flt/test_flt.cxx b/pandatool/src/flt/test_flt.cxx index 2b8a37e5e5..9f15bbb4b7 100644 --- a/pandatool/src/flt/test_flt.cxx +++ b/pandatool/src/flt/test_flt.cxx @@ -49,6 +49,8 @@ main(int argc, char *argv[]) { FltError result = header->read_flt(filename); cerr << "Read result is " << result << "\n\n"; + cerr << "Version is " << header->get_flt_version() << "\n"; + header->check_version(); if (result == FE_ok) { //header->write(cerr); diff --git a/pandatool/src/fltprogs/fltCopy.cxx b/pandatool/src/fltprogs/fltCopy.cxx index 83121629f4..9af7a3b23b 100644 --- a/pandatool/src/fltprogs/fltCopy.cxx +++ b/pandatool/src/fltprogs/fltCopy.cxx @@ -108,6 +108,8 @@ copy_flt_file(const Filename &source, const Filename &dest, return false; } + header->check_version(); + // Now scan the flt file for nested references. Refs refs; Textures textures;