mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 19:03:43 +00:00
ReadLvlObjectData (1.10.64, 0x0103ba20) reads a scene object's last field, from version 7 on, as a render technique count, and when it is not 0 a 64 byte block and 133 bytes per technique (a 64 byte name, a u32, a u8 and 16 floats) follow. The reader took the count for an unknown u32 and read the next object from inside the techniques, and read the u32 for every version. It also left the node type and glom ID uninitialized when a file has none (or, for the node type, one outside 0-10); the client uses 1 for both. The count is now SceneObject::renderTechniqueCount, the techniques are skipped, and the defaults are the client's. Every scene file on disk has no render techniques, so what they read is unchanged. Check in game: every world spawns its objects as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68 lines
1.7 KiB
C++
68 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <iosfwd>
|
|
#include <map>
|
|
#include <vector>
|
|
|
|
#include "dCommonVars.h"
|
|
#include "NiPoint3.h"
|
|
#include "NiQuaternion.h"
|
|
#include "LDFFormat.h"
|
|
|
|
struct SceneObject {
|
|
LWOOBJID id;
|
|
LOT lot;
|
|
uint32_t nodeType = 1; // the client's default when the file has none, or one outside 0-10
|
|
uint32_t glomId = 1;
|
|
NiPoint3 position;
|
|
NiQuaternion rotation = QuatUtils::IDENTITY;
|
|
float scale = 1.0f;
|
|
uint32_t renderTechniqueCount{};
|
|
LwoNameValue settings;
|
|
};
|
|
|
|
/**
|
|
* A scene file (.lvl) as the world server loads it (Level): its chunk headers and every object in it, with the object's
|
|
* settings parsed. Only reads; which objects the world spawns (feature gating, client-only objects, spawners) stays in
|
|
* dZoneManager, so the dashboard reads scenes with the same code.
|
|
*/
|
|
struct LevelFile {
|
|
enum ChunkTypeID : uint16_t {
|
|
FileInfo = 1000,
|
|
SceneEnviroment = 2000,
|
|
SceneObjectData,
|
|
SceneParticleData
|
|
};
|
|
|
|
struct FileInfoChunk {
|
|
uint32_t version{};
|
|
uint32_t revision{};
|
|
uint32_t enviromentChunkStart{};
|
|
uint32_t objectChunkStart{};
|
|
uint32_t particleChunkStart{};
|
|
};
|
|
|
|
struct ChunkHeader {
|
|
uint32_t id{};
|
|
uint16_t chunkVersion{};
|
|
ChunkTypeID chunkType{};
|
|
uint32_t size{};
|
|
uint32_t startPosition{};
|
|
FileInfoChunk fileInfo;
|
|
};
|
|
|
|
std::map<uint32_t, ChunkHeader> chunkHeaders;
|
|
std::vector<SceneObject> objects;
|
|
|
|
/**
|
|
* Reads the whole file. Throws std::runtime_error (BinaryIO) if it ends early; what was read before that stays
|
|
* (an object is only added once all of it was read).
|
|
*/
|
|
void Read(std::istream& file);
|
|
|
|
private:
|
|
void ReadFileInfoChunk(std::istream& file, ChunkHeader& header);
|
|
void ReadSceneObjectDataChunk(std::istream& file, uint32_t version);
|
|
};
|