Skip to content
Permalink
Browse files

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).
  • Loading branch information
rdb committed Mar 18, 2020
1 parent b549133 commit f1da4d46665e39b7007a909312754aa0c86bea92
Showing with 9 additions and 8 deletions.
  1. +1 −0 panda/src/putil/bam.h
  2. +2 −2 panda/src/putil/bamReader.cxx
  3. +6 −6 panda/src/putil/bamWriter.cxx
@@ -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.

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;
// 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.
@@ -107,7 +107,7 @@ init() {
// can't safely load the file.
if (_file_major != _bam_major_ver ||
_file_minor < _bam_first_minor_ver ||
_file_minor > _bam_minor_ver) {
_file_minor > _bam_last_minor_ver) {
bam_cat.error()
<< "Bam file is version " << _file_major << "." << _file_minor
<< ".\n";
@@ -120,7 +120,7 @@ init() {
bam_cat.error()
<< "This program can only load version "
<< _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;
@@ -80,18 +80,18 @@ BamWriter(DatagramSink *target) :
_file_minor = 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()
<< "bam-version is set to " << bam_version << ", but this version of "
"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
<< "." << _bam_minor_ver << " files.\n";
<< "." << _bam_last_minor_ver << " files.\n";

_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(1, _bam_minor_ver);
bam_version.set_word(1, _bam_last_minor_ver);
}
} else {
_file_major = _bam_major_ver;
@@ -157,7 +157,7 @@ init() {
_long_pta_id = 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_texture_mode = bam_texture_mode;

0 comments on commit f1da4d4

Please sign in to comment.
You can’t perform that action at this time.