mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
Add support for packed clients (#802)
* 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.
This commit is contained in:
@@ -13,17 +13,22 @@
|
||||
#include "EntityManager.h"
|
||||
#include "CDFeatureGatingTable.h"
|
||||
#include "CDClientManager.h"
|
||||
#include "AssetManager.h"
|
||||
|
||||
Level::Level(Zone* parentZone, const std::string& filepath) {
|
||||
m_ParentZone = parentZone;
|
||||
std::ifstream file(filepath, std::ios_base::in | std::ios_base::binary);
|
||||
if (file) {
|
||||
ReadChunks(file);
|
||||
} else {
|
||||
|
||||
auto buffer = Game::assetManager->GetFileAsBuffer(filepath.c_str());
|
||||
|
||||
if (!buffer.m_Success) {
|
||||
Game::logger->Log("Level", "Failed to load %s", filepath.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
file.close();
|
||||
std::istream file(&buffer);
|
||||
ReadChunks(file);
|
||||
|
||||
buffer.close();
|
||||
}
|
||||
|
||||
Level::~Level() {
|
||||
@@ -41,7 +46,7 @@ const void Level::PrintAllObjects() {
|
||||
}
|
||||
}
|
||||
|
||||
void Level::ReadChunks(std::ifstream& file) {
|
||||
void Level::ReadChunks(std::istream& file) {
|
||||
const uint32_t CHNK_HEADER = ('C' + ('H' << 8) + ('N' << 16) + ('K' << 24));
|
||||
|
||||
while (!file.eof()) {
|
||||
@@ -139,7 +144,7 @@ void Level::ReadChunks(std::ifstream& file) {
|
||||
}
|
||||
}
|
||||
|
||||
void Level::ReadFileInfoChunk(std::ifstream& file, Header& header) {
|
||||
void Level::ReadFileInfoChunk(std::istream& file, Header& header) {
|
||||
FileInfoChunk* fi = new FileInfoChunk;
|
||||
BinaryIO::BinaryRead(file, fi->version);
|
||||
BinaryIO::BinaryRead(file, fi->revision);
|
||||
@@ -152,7 +157,7 @@ void Level::ReadFileInfoChunk(std::ifstream& file, Header& header) {
|
||||
if (header.fileInfo->revision == 3452816845 && m_ParentZone->GetZoneID().GetMapID() == 1100) header.fileInfo->revision = 26;
|
||||
}
|
||||
|
||||
void Level::ReadSceneObjectDataChunk(std::ifstream& file, Header& header) {
|
||||
void Level::ReadSceneObjectDataChunk(std::istream& file, Header& header) {
|
||||
SceneObjectDataChunk* chunk = new SceneObjectDataChunk;
|
||||
uint32_t objectsCount = 0;
|
||||
BinaryIO::BinaryRead(file, objectsCount);
|
||||
|
Reference in New Issue
Block a user