putil: set max supported bam version independently from default version

This will allow us to support reading and writing higher-versioned .bam file than we are writing by default.  This allows us to make changes bumping the bam version to the release branch, since we currently guarantee that bam files written by Panda3D 1.x.y can be read by Panda3D 1.x.0 (using the default settings).
This commit is contained in:
rdb 2020-03-18 17:47:04 +01:00
parent b549133b3e
commit f1da4d4666
3 changed files with 9 additions and 8 deletions

View File

@ -32,6 +32,7 @@ static const unsigned short _bam_major_ver = 6;
// Bumped to major version 6 on 2006-02-11 to factor out PandaNode::CData. // Bumped to major version 6 on 2006-02-11 to factor out PandaNode::CData.
static const unsigned short _bam_first_minor_ver = 14; static const unsigned short _bam_first_minor_ver = 14;
static const unsigned short _bam_last_minor_ver = 44;
static const unsigned short _bam_minor_ver = 44; static const unsigned short _bam_minor_ver = 44;
// Bumped to minor version 14 on 2007-12-19 to change default ColorAttrib. // Bumped to minor version 14 on 2007-12-19 to change default ColorAttrib.
// Bumped to minor version 15 on 2008-04-09 to add TextureAttrib::_implicit_sort. // Bumped to minor version 15 on 2008-04-09 to add TextureAttrib::_implicit_sort.

View File

@ -107,7 +107,7 @@ init() {
// can't safely load the file. // can't safely load the file.
if (_file_major != _bam_major_ver || if (_file_major != _bam_major_ver ||
_file_minor < _bam_first_minor_ver || _file_minor < _bam_first_minor_ver ||
_file_minor > _bam_minor_ver) { _file_minor > _bam_last_minor_ver) {
bam_cat.error() bam_cat.error()
<< "Bam file is version " << _file_major << "." << _file_minor << "Bam file is version " << _file_major << "." << _file_minor
<< ".\n"; << ".\n";
@ -120,7 +120,7 @@ init() {
bam_cat.error() bam_cat.error()
<< "This program can only load version " << "This program can only load version "
<< _bam_major_ver << "." << _bam_first_minor_ver << " through " << _bam_major_ver << "." << _bam_first_minor_ver << " through "
<< _bam_major_ver << "." << _bam_minor_ver << " bams.\n"; << _bam_major_ver << "." << _bam_last_minor_ver << " bams.\n";
} }
return false; return false;

View File

@ -80,18 +80,18 @@ BamWriter(DatagramSink *target) :
_file_minor = 21; _file_minor = 21;
bam_version.set_string_value("6 21"); bam_version.set_string_value("6 21");
} else if (_file_major > _bam_major_ver || _file_minor > _bam_minor_ver) { } else if (_file_major > _bam_major_ver || _file_minor > _bam_last_minor_ver) {
util_cat.error() util_cat.error()
<< "bam-version is set to " << bam_version << ", but this version of " << "bam-version is set to " << bam_version << ", but this version of "
"Panda3D cannot produce .bam files newer than " << _bam_major_ver "Panda3D cannot produce .bam files newer than " << _bam_major_ver
<< "." << _bam_minor_ver << ". Set bam-version to a supported " << "." << _bam_last_minor_ver << ". Set bam-version to a supported "
"version or leave it blank to write version " << _bam_major_ver "version or leave it blank to write version " << _bam_major_ver
<< "." << _bam_minor_ver << " files.\n"; << "." << _bam_last_minor_ver << " files.\n";
_file_major = _bam_major_ver; _file_major = _bam_major_ver;
_file_minor = _bam_minor_ver; _file_minor = _bam_last_minor_ver;
bam_version.set_word(0, _bam_major_ver); bam_version.set_word(0, _bam_major_ver);
bam_version.set_word(1, _bam_minor_ver); bam_version.set_word(1, _bam_last_minor_ver);
} }
} else { } else {
_file_major = _bam_major_ver; _file_major = _bam_major_ver;
@ -157,7 +157,7 @@ init() {
_long_pta_id = false; _long_pta_id = false;
nassertr_always(_file_major == _bam_major_ver, false); nassertr_always(_file_major == _bam_major_ver, false);
nassertr_always(_file_minor <= _bam_minor_ver && _file_minor >= 21, false); nassertr_always(_file_minor <= _bam_last_minor_ver && _file_minor >= 21, false);
_file_endian = bam_endian; _file_endian = bam_endian;
_file_texture_mode = bam_texture_mode; _file_texture_mode = bam_texture_mode;