mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-16 08:45:27 +00:00
LuzFile::ReadLUZFile, LuzReader::ReadScenes and ZoneLoader::ReadZoneFile (1.10.64): - a version older than 20 is read as 20; - before version 30 a scene is a bare u32 SceneTable ID: in ID order, each one with a SceneTable row gets the next index (-1 past 255) as its ID and the row's sceneName as its file; the others are left out; - from 30 to 32 the file has no scene IDs: a scene's ID is its index in the file (they all had ID 0, colliding); - a later scene with the same ID and layer replaces an earlier one, a scene ID with no layer 0 scene is left out, and before version 41 only the layer 0 scenes are loaded. No 1.10.64 zone file has a duplicate scene, a scene without a layer 0 scene or another layer before version 41, so what live zones load is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
111 lines
4.0 KiB
C++
111 lines
4.0 KiB
C++
#pragma once
|
|
|
|
#include "dZMCommon.h"
|
|
#include "LDFFormat.h"
|
|
#include "LWOSCENEID.h"
|
|
#include "ZoneFile.h"
|
|
#include "ZoneScenes.h"
|
|
#include "tinyxml2.h"
|
|
#include <string>
|
|
#include <functional>
|
|
#include <optional>
|
|
#include <vector>
|
|
#include <map>
|
|
#include "Raw.h"
|
|
|
|
namespace LUTriggers {
|
|
struct Trigger;
|
|
};
|
|
|
|
class Level;
|
|
|
|
// A scene of the zone, with its level once loaded
|
|
struct SceneRef : ZoneScene {
|
|
std::unique_ptr<Level> level;
|
|
std::map<uint32_t, LUTriggers::Trigger*> triggers;
|
|
};
|
|
|
|
class Zone {
|
|
public:
|
|
using FileFormatVersion = ZoneFile::FileFormatVersion;
|
|
|
|
public:
|
|
Zone(const LWOZONEID zoneID);
|
|
~Zone();
|
|
|
|
void Initalize();
|
|
void LoadZoneIntoMemory();
|
|
std::string GetFilePathForZoneID() const;
|
|
uint32_t CalculateChecksum() const;
|
|
void LoadLevelsIntoMemory();
|
|
void AddRevision(LWOSCENEID sceneID, uint32_t revision);
|
|
const LWOZONEID& GetZoneID() const { return m_ZoneID; }
|
|
const uint32_t GetChecksum() const { return m_CheckSum; }
|
|
LUTriggers::Trigger* GetTrigger(uint32_t sceneID, uint32_t triggerID) const;
|
|
const Path* GetPath(std::string name) const;
|
|
|
|
// The CDClient SceneTable's sceneName for a scene of a file from before PrePreAlpha; the database's by default
|
|
using SceneTableLookup = std::function<std::optional<std::string>(uint32_t sceneTableID)>;
|
|
void SetSceneTableLookup(SceneTableLookup lookup) { m_SceneTableLookup = std::move(lookup); }
|
|
const std::vector<Path>& GetPaths() const { return m_Paths; }
|
|
// A path that isn't in the zone's files (tests); earlier GetPath pointers may move
|
|
void AddPath(Path path) { m_Paths.push_back(std::move(path)); }
|
|
|
|
uint32_t GetWorldID() const { return m_WorldID; }
|
|
[[nodiscard]] std::string GetZoneName() const { return m_ZoneName; }
|
|
std::string GetZoneRawPath() const { return m_ZoneRawPath; }
|
|
std::string GetZonePath() const { return m_ZonePath; }
|
|
|
|
const NiPoint3& GetSpawnPos() const { return m_Spawnpoint; }
|
|
const NiQuaternion& GetSpawnRot() const { return m_SpawnpointRotation; }
|
|
|
|
// Which scenes the client keeps loaded where (ZoneScenes); the scene map is empty unless LoadSceneMap read it
|
|
const ZoneScenes::SceneGraph& GetSceneGraph() const { return m_SceneGraph; }
|
|
const ZoneScenes::SceneMap& GetSceneMap() const { return m_SceneMap; }
|
|
// Reads the terrain file's scene map (for scene ghosting); false when the zone has none
|
|
bool LoadSceneMap();
|
|
|
|
void SetSpawnPos(const NiPoint3& pos) { m_Spawnpoint = pos; }
|
|
void SetSpawnRot(const NiQuaternion& rot) { m_SpawnpointRotation = rot; }
|
|
|
|
const Raw::Raw& GetZoneRaw() const { return m_Raw; }
|
|
const SceneRef* GetScene(LWOSCENEID sceneID) const;
|
|
const std::vector<SceneTransition>& GetSceneTransitions() const { return m_SceneTransitions; }
|
|
const std::vector<ZoneBoundary>& GetBoundaries() const { return m_Boundaries; }
|
|
const std::map<LWOSCENEID, SceneRef>& GetScenes() const { return m_Scenes; }
|
|
|
|
private:
|
|
LWOZONEID m_ZoneID;
|
|
std::string m_ZoneFilePath;
|
|
uint32_t m_NumberOfObjectsLoaded;
|
|
uint32_t m_NumberOfSceneTransitionsLoaded;
|
|
FileFormatVersion m_FileFormatVersion;
|
|
uint32_t m_CheckSum;
|
|
uint32_t m_WorldID; //should be equal to the MapID
|
|
NiPoint3 m_Spawnpoint;
|
|
NiQuaternion m_SpawnpointRotation = QuatUtils::IDENTITY;
|
|
uint32_t m_SceneCount;
|
|
|
|
std::string m_ZonePath; //Path to the .luz's folder
|
|
std::string m_ZoneName; //Name given to the zone by a level designer
|
|
std::string m_ZoneDesc; //Description of the zone by a level designer
|
|
std::string m_ZoneRawPath; //Path to the .raw file of this zone.
|
|
Raw::Raw m_Raw; // The Raw data for this zone
|
|
|
|
std::map<LWOSCENEID, SceneRef> m_Scenes;
|
|
std::vector<SceneTransition> m_SceneTransitions;
|
|
ZoneScenes::SceneGraph m_SceneGraph;
|
|
ZoneScenes::SceneMap m_SceneMap;
|
|
std::vector<ZoneBoundary> m_Boundaries;
|
|
|
|
uint32_t m_PathDataLength;
|
|
uint32_t m_PathChunkVersion;
|
|
std::vector<Path> m_Paths;
|
|
|
|
std::map<LWOSCENEID, uint32_t> m_MapRevisions; //rhs is the revision!
|
|
SceneTableLookup m_SceneTableLookup;
|
|
//private ("helper") functions:
|
|
void LoadScene(ZoneScene&& zoneScene);
|
|
void LoadLUTriggers(std::string triggerFile, SceneRef& scene);
|
|
};
|