Files
DarkflameServer/dCommon/LevelFile.h
Aaron Kimbrell 695bcf2352 fix(level): change scene object config as the client does while loading it
ReadLvlObjectData (1.10.64, 0x0103ba20) changes an object's config as it
loads it:
- before version 47 a respawn time is in milliseconds: a float over 100
  or any u32 becomes that many seconds, as a float;
- a model spawner (LOT 176 with spawntemplate 14) gets its subkey as its
  blueprintid unless it has one, DisableModelBehaviors true unless set,
  and preventRenderWrapping true;
- before version 44 an object with sceneIDOverrideEnabled gets
  sceneLayerIDOverride 0.

LevelFile now makes the same changes. On live worlds 1906 spawners in
114 scene files of versions 45-46 have a u32 respawn time; the world
already divided those by 1000 but as an integer, so they now keep their
fraction (a 2500 ms respawn is 2.5 s, not 2 s). No live scene has a
model spawner; 62 objects of version 43 scenes get sceneLayerIDOverride.

Check in game: enemies and smashables respawn after the same time as
before on Forbidden Valley, Avant Gardens and Gnarled Forest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 08:39:37 -05:00

70 lines
1.8 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:
static ChunkHeader ReadChunkHeader(std::istream& file, uint32_t start);
void ReadFileInfoChunk(std::istream& file, ChunkHeader& header);
void ReadSceneObjectDataChunk(std::istream& file, uint32_t version);
static void ApplyClientConfigFixups(SceneObject& obj, uint32_t version);
};