diff --git a/direct/src/p3d/Packager.py b/direct/src/p3d/Packager.py index 13cb8b9db2..d80062c865 100644 --- a/direct/src/p3d/Packager.py +++ b/direct/src/p3d/Packager.py @@ -101,6 +101,11 @@ class Packager: if basename.resolveFilename(packager.executablePath): self.filename = basename + if ext in packager.textExtensions and not self.executable: + self.filename.setText() + else: + self.filename.setBinary() + # Convert the filename to an unambiguous filename for # searching. self.filename.makeTrueCase() @@ -1434,6 +1439,14 @@ class Packager: # Write the xml file to a temporary file on disk, so we # can add it to the multifile. filename = Filename.temporary('', 'p3d_', '.xml') + + # This should really be setText() for an xml file, but it + # doesn't really matter that much since tinyxml can read + # it either way; and if we use setBinary() it will remain + # compatible with older versions of the core API that + # didn't understand the SF_text flag. + filename.setBinary() + doc.SaveFile(filename.toOsSpecific()) # It's important not to compress this file: the core API @@ -1940,6 +1953,7 @@ class Packager: # Then write it out again, without the comments. tempFilename = Filename.temporary('', 'p3d_', '.prc') + tempFilename.setBinary() # Binary is more reliable for signing. temp = open(tempFilename.toOsSpecific(), 'w') for line in textLines: line = line.strip() @@ -1964,6 +1978,7 @@ class Packager: file.newName = file.newName[:-1] + 'e' preFilename = Filename.temporary('', 'p3d_', '.pre') + preFilename.setBinary() tempFilename.setText() encryptFile(tempFilename, preFilename, self.packager.prcEncryptionKey) tempFilename.unlink() @@ -2233,7 +2248,7 @@ class Packager: self.modelExtensions = [ 'egg', 'bam' ] # Text files that are copied (and compressed) to the package - # without processing. + # with end-of-line conversion. self.textExtensions = [ 'prc', 'ptf', 'txt', 'cg', 'sha', 'dc', 'xml' ] # Binary files that are copied (and compressed) without @@ -3495,6 +3510,10 @@ class Packager: ext = newFilename.getExtension() if ext in self.knownExtensions: + if ext in self.textExtensions: + filename.setText() + else: + filename.setBinary() self.currentPackage.addFile(filename, newName = newName, explicit = False, unprocessed = unprocessed) diff --git a/direct/src/plugin/p3dInstance.cxx b/direct/src/plugin/p3dInstance.cxx index 4eeaaa497a..5695678739 100644 --- a/direct/src/plugin/p3dInstance.cxx +++ b/direct/src/plugin/p3dInstance.cxx @@ -2136,6 +2136,9 @@ scan_app_desc_file(TiXmlDocument *doc) { void P3DInstance:: add_packages() { assert(!_packages_specified); + if (_xpackage == NULL) { + return; + } P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); diff --git a/direct/src/plugin/p3dMultifileReader.cxx b/direct/src/plugin/p3dMultifileReader.cxx index 29bbde1c67..52dc4bdc30 100644 --- a/direct/src/plugin/p3dMultifileReader.cxx +++ b/direct/src/plugin/p3dMultifileReader.cxx @@ -332,8 +332,8 @@ read_index() { // Otherwise, it's a regular file. _last_data_byte = max(_last_data_byte, s.get_last_byte_pos()); - if (flags == 0) { - // We can only support subfiles with no particular flags set. + if ((flags & SF_ignore) == 0) { + // We can only support subfiles with none of SF_ignore set. _subfiles.push_back(s); } } diff --git a/direct/src/plugin/p3dMultifileReader.h b/direct/src/plugin/p3dMultifileReader.h index 860087ca1c..80253997d3 100644 --- a/direct/src/plugin/p3dMultifileReader.h +++ b/direct/src/plugin/p3dMultifileReader.h @@ -63,6 +63,10 @@ private: inline unsigned int read_uint32(); enum SubfileFlags { + // If any of these bits are set, we can't read the subfile. + SF_ignore = 0x003f, + + // These bits are also relevant, and specifically so. SF_compressed = 0x0008, SF_encrypted = 0x0010, SF_signature = 0x0020,