mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 19:03:43 +00:00
fix(zone): keep the scenes of a zone file the client loads
LuzReader::ReadScenes (1.10.64) keeps a zone's scenes by scene ID and layer, so a later scene with the same ID and layer replaces an earlier one. ZoneLoader::ReadZoneFile then goes through them in scene ID order and - leaves out every layer of a scene ID that has no layer 0 (General) scene; - before version 41 loads only the layer 0 scene of each ID; from 41 on the other layers (Audio, FX) are loaded with it. ZoneFile now keeps the scenes the same way, so the world loads the same scenes as the client. No zone file on disk has a duplicate, a scene without a General layer, or a non-General layer before version 41, and their scenes are already in ID order: what every file reads is unchanged. Check in game: nothing to check (no live zone changes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -35,6 +35,7 @@ void ZoneFile::ReadHeader(std::istream& file) {
|
||||
for (uint32_t i = 0; i < sceneCount; ++i) {
|
||||
ReadScene(file, i);
|
||||
}
|
||||
KeepLoadedScenes();
|
||||
|
||||
ReadZoneBoundaries(file);
|
||||
|
||||
@@ -106,6 +107,21 @@ void ZoneFile::ReadScene(std::istream& file, uint32_t index) {
|
||||
scenes.push_back(std::move(scene));
|
||||
}
|
||||
|
||||
void ZoneFile::KeepLoadedScenes() {
|
||||
if (fileFormatVersion < FileFormatVersion::PrePreAlpha) return; // ResolveSceneTable does this for those
|
||||
// LuzReader::ReadScenes keeps the scenes by scene ID and layer, a later one replacing an earlier one.
|
||||
// ZoneLoader::ReadZoneFile then goes through them by scene ID: a scene ID with no General layer is left out, and
|
||||
// before Latest only the General layer is loaded
|
||||
std::map<std::pair<uint32_t, eSceneType>, ZoneScene> byID;
|
||||
for (auto& scene : scenes) byID.insert_or_assign({ scene.id, scene.sceneType }, std::move(scene));
|
||||
scenes.clear();
|
||||
for (auto& [key, scene] : byID) {
|
||||
if (!byID.contains({ key.first, eSceneType::General })) continue;
|
||||
if (key.second != eSceneType::General && fileFormatVersion < FileFormatVersion::Latest) continue;
|
||||
scenes.push_back(std::move(scene));
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneFile::ResolveSceneTable(const std::function<std::optional<std::string>(uint32_t)>& sceneName) {
|
||||
if (fileFormatVersion >= FileFormatVersion::PrePreAlpha) return;
|
||||
// ZoneLoader::ReadZoneFile: the scenes go by their SceneTable ID; each one with a row there gets the next index
|
||||
|
||||
Reference in New Issue
Block a user