diff --git a/dCommon/LevelFile.cpp b/dCommon/LevelFile.cpp index 4748b1fa8..ddf13bc9e 100644 --- a/dCommon/LevelFile.cpp +++ b/dCommon/LevelFile.cpp @@ -42,9 +42,9 @@ void LevelFile::Read(std::istream& file) { header.id = ChunkTypeID::FileInfo; BinaryIO::BinaryRead(file, header.chunkVersion); BinaryIO::BinaryRead(file, header.chunkType); + // Only from version 32 (SceneLoader::ReadLvlHeader) uint8_t important = 0; - BinaryIO::BinaryRead(file, important); - // file.ignore(1); //probably used + if (header.chunkVersion >= 32) BinaryIO::BinaryRead(file, important); if (header.chunkVersion > 36) { BinaryIO::BinaryRead(file, header.fileInfo.revision); } @@ -87,7 +87,8 @@ void LevelFile::Read(std::istream& file) { BinaryIO::BinaryRead(file, count); file.ignore(count); - if (header.chunkVersion >= 33) { + // Five more strings from version 34 (SceneLoader::ReadSkydomeInfo) + if (header.chunkVersion >= 34) { for (uint32_t i = 0; i < 5; ++i) { uint32_t count = 0; BinaryIO::BinaryRead(file, count); diff --git a/tests/dCommonTests/ZoneFileTests.cpp b/tests/dCommonTests/ZoneFileTests.cpp index b63c8f6d6..db02c63bb 100644 --- a/tests/dCommonTests/ZoneFileTests.cpp +++ b/tests/dCommonTests/ZoneFileTests.cpp @@ -276,7 +276,7 @@ TEST(LevelFileTests, ReadsChunkedObjects) { // Some live scenes (e.g. Nimbus Station's Gnarled Forest launch pad) are from before chunks TEST(LevelFileTests, ReadsFilesWithoutChunks) { ZoneBytes w; - w.Put(30).Put(0).Put(1); // version, type, important + w.Put(30).Put(0); // version, type; no important byte before 32 w.data.append(48 + 12, '\0'); // version 30 settings the world skips w.Put(0); // no skydome w.Put(1); @@ -293,7 +293,7 @@ TEST(LevelFileTests, ReadsFilesWithoutChunks) { TEST(LevelFileTests, DamagedFilesKeepWhatWasRead) { ZoneBytes w; - w.Put(30).Put(0).Put(1); + w.Put(30).Put(0); w.data.append(48 + 12, '\0'); w.Put(0).Put(2); w.Object(30, 1, 0, "a=0:b");