mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +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.
39 lines
761 B
C++
39 lines
761 B
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
#include <filesystem>
|
|
|
|
#pragma pack(push, 1)
|
|
struct PackRecord {
|
|
uint32_t m_Crc;
|
|
int32_t m_LowerCrc;
|
|
int32_t m_UpperCrc;
|
|
uint32_t m_UncompressedSize;
|
|
char m_UncompressedHash[32];
|
|
uint32_t m_Padding1;
|
|
uint32_t m_CompressedSize;
|
|
char m_CompressedHash[32];
|
|
uint32_t m_Padding2;
|
|
uint32_t m_FilePointer;
|
|
uint32_t m_IsCompressed; // u32 bool
|
|
};
|
|
#pragma pack(pop)
|
|
|
|
class Pack {
|
|
public:
|
|
Pack(const std::filesystem::path& filePath);
|
|
~Pack() = default;
|
|
|
|
bool HasFile(uint32_t crc);
|
|
bool ReadFileFromPack(uint32_t crc, char** data, uint32_t* len);
|
|
private:
|
|
std::ifstream m_FileStream;
|
|
std::filesystem::path m_FilePath;
|
|
|
|
char m_Version[7];
|
|
|
|
uint32_t m_RecordCount;
|
|
std::vector<PackRecord> m_Records;
|
|
};
|