From 59e1d8f7c1c0f2f07cb38c0ba3b184aa39910186 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Tue, 29 Sep 2026 04:39:23 -0500 Subject: [PATCH] fix(level): read pre-chunk scene files of versions 31 and 33 Two fields of the scene files from before chunks were read for versions the client does not read them for (SceneLoader::ReadLvlFile, 1.10.64): - the "important" byte after the version and type is there only from version 32 (SceneLoader::ReadLvlHeader, 0x010117d0: headerVersion < 32 sets it to 0); - the five strings after the skydome's file are there only from version 34 (SceneLoader::ReadSkydomeInfo, 0x0102f550: headerVersion > 33); the reader took them from version 33. Seven scenes of the alpha leak (versions 31 and 33: Gnarled_assetsMIKET, dennis_gnarled_forest_02/_03-ninja/_03-pirate_0, scale_TEST_2, scale_test_2_0, scale_test_general) now read with all their objects. Every other scene file on disk reads the same objects as before. Check in game: every world spawns its objects as before. Co-Authored-By: Claude Opus 5.5 --- dCommon/LevelFile.cpp | 7 ++++--- tests/dCommonTests/ZoneFileTests.cpp | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) 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");