fix: read a scene file's chunks, environment and objects as the client does

The world read only a scene's objects and skipped the rest with
file.ignore. Level now reads a .lvl the way SceneLoader::LoadLvlFile
does (1.10.64) and keeps what it reads.

Chunked files: the file info chunk gives where the environment, object
and particle chunks start (the chunks were walked in order before); the
environment chunk gives where the lighting, skydome and editor settings
start, and the client reads all three only when there is lighting.

Files from before chunks: the no-editor-settings byte only from version
32, the revision from 37, a file newer than 48 is not read, a file
older than 3 has no objects; then lighting, skydome, editor settings
and objects in turn.

Kept, by version:
- lighting: blend time (45 on, default 10), ambient, specular, upper
  hemisphere, position, min and max draw distances (31 on; before 39
  fog near and far only), cull settings (40 on), fog colour (31 on),
  directional colour (36 on), and before 42 the zone's spawn point
  (before 33 the fixed one the client uses);
- the skydome and its five other files (34 on; they were skipped from
  33);
- the editor's colours (37 on, the first 32);
- each object's node type (38 on), glom ID (32 on) and render
  techniques (7 on: a 64 byte name, then per technique a 64 byte name,
  u32, u8 and 16 floats); before, a count of techniques was read and
  the techniques themselves were not, so an object with any misread
  the rest of the file.

Object config is split at line breaks as before. A file that ends early
keeps the objects read before its end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-10-27 10:34:14 -05:00
parent 88d08aa2b0
commit d06cc2923e
5 changed files with 582 additions and 140 deletions

View File

@@ -20,6 +20,7 @@
#include "PhysicsComponent.h"
#include "dConfig.h"
#include <ranges>
#include <stdexcept>
Level::Level(Zone* parentZone, const std::string& filepath, int32_t sceneID) {
m_ParentZone = parentZone;
@@ -35,7 +36,12 @@ Level::Level(Zone* parentZone, const std::string& filepath, int32_t sceneID) {
// The file itself is read by LevelFile (dCommon), which the dashboard uses too
LevelFile levelFile;
levelFile.Read(stream);
try {
levelFile.Read(stream);
} catch (const std::runtime_error&) {
// The client reads past the end of such a file; what was read before it is kept
LOG("%s ends early; loading the %zu objects read before its end", filepath.c_str(), levelFile.objects.size());
}
for (const auto& [id, chunkHeader] : levelFile.chunkHeaders) {
Header header;
static_cast<LevelFile::ChunkHeader&>(header) = chunkHeader;