mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-26 23:43:34 +00:00
4a6f3e44ee
* First iteration of pack reader and interface * Fix memory leak and remove logs * Complete packed asset interface and begin on file loading replacement * Implement proper BinaryIO error * Improve AssetMemoryBuffer for reading and implement more reading * Repair more file loading code and improve how navmeshes are loaded * Missing checks implementation * Revert addition of Manifest class and migration changes * Resolved all feedback.
74 lines
1.6 KiB
C++
74 lines
1.6 KiB
C++
#pragma once
|
|
#include "dZMCommon.h"
|
|
#include <map>
|
|
#include <iostream>
|
|
#include "Zone.h"
|
|
|
|
class Level {
|
|
public:
|
|
enum ChunkTypeID : uint16_t {
|
|
FileInfo = 1000,
|
|
SceneEnviroment = 2000,
|
|
SceneObjectData,
|
|
SceneParticleData
|
|
};
|
|
|
|
enum ChunkTypes {
|
|
Enviroment,
|
|
Objects,
|
|
Particles
|
|
};
|
|
|
|
struct FileInfoChunk {
|
|
uint32_t version;
|
|
uint32_t revision;
|
|
uint32_t enviromentChunkStart;
|
|
uint32_t objectChunkStart;
|
|
uint32_t particleChunkStart;
|
|
};
|
|
|
|
struct SceneObjectDataChunk {
|
|
std::map<LWOOBJID, SceneObject> objects;
|
|
|
|
SceneObject& GetObject(LWOOBJID id) {
|
|
for (std::map<LWOOBJID, SceneObject>::iterator it = objects.begin(); it != objects.end(); ++it) {
|
|
if (it->first == id) return it->second;
|
|
}
|
|
}
|
|
|
|
const void PrintAllObjects() {
|
|
for (std::map<LWOOBJID, SceneObject>::iterator it = objects.begin(); it != objects.end(); ++it) {
|
|
std::cout << "\t ID: " << it->first << " LOT: " << it->second.lot << std::endl;
|
|
}
|
|
}
|
|
|
|
uint32_t GetObjectCount() { return objects.size(); }
|
|
};
|
|
|
|
struct Header {
|
|
uint32_t id;
|
|
uint16_t chunkVersion;
|
|
ChunkTypeID chunkType;
|
|
uint32_t size;
|
|
uint32_t startPosition;
|
|
FileInfoChunk* fileInfo;
|
|
SceneObjectDataChunk* sceneObjects;
|
|
LWOSCENEID lwoSceneID;
|
|
};
|
|
|
|
public:
|
|
Level(Zone* parentZone, const std::string& filepath);
|
|
~Level();
|
|
|
|
const void PrintAllObjects();
|
|
|
|
std::map<uint32_t, Header> m_ChunkHeaders;
|
|
private:
|
|
Zone* m_ParentZone;
|
|
|
|
//private functions:
|
|
void ReadChunks(std::istream& file);
|
|
void ReadFileInfoChunk(std::istream& file, Header& header);
|
|
void ReadSceneObjectDataChunk(std::istream& file, Header& header);
|
|
};
|