mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-11 18:48:26 +00:00
don't try to load the raw if the map version is too old
fixup some comments
This commit is contained in:
@@ -100,7 +100,7 @@ namespace Raw {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ColorMap (size varies by version)
|
||||
// ColorMap
|
||||
if (version >= 32) {
|
||||
BinaryIO::BinaryRead(stream, chunk.colorMapResolution);
|
||||
} else {
|
||||
@@ -114,8 +114,7 @@ namespace Raw {
|
||||
if (stream.fail()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// LightMap DDS
|
||||
// LightMap/diffusemap.dds
|
||||
uint32_t lightMapSize;
|
||||
BinaryIO::BinaryRead(stream, lightMapSize);
|
||||
|
||||
@@ -126,7 +125,7 @@ namespace Raw {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TextureMap (size varies by version)
|
||||
// TextureMap
|
||||
if (version >= 32) {
|
||||
BinaryIO::BinaryRead(stream, chunk.textureMapResolution);
|
||||
} else {
|
||||
|
||||
@@ -57,6 +57,11 @@ void Zone::LoadZoneIntoMemory() {
|
||||
if (file) {
|
||||
BinaryIO::BinaryRead(file, m_FileFormatVersion);
|
||||
|
||||
if (m_FileFormatVersion < Zone::FileFormatVersion::PrePreAlpha) {
|
||||
LOG("Zone %s is too old to be supported, please update the map", m_ZoneFilePath.c_str());
|
||||
throw std::runtime_error("Aborting Zone loading due to old Zone File.");
|
||||
}
|
||||
|
||||
uint32_t mapRevision = 0;
|
||||
if (m_FileFormatVersion >= Zone::FileFormatVersion::Alpha) BinaryIO::BinaryRead(file, mapRevision);
|
||||
|
||||
@@ -92,23 +97,30 @@ void Zone::LoadZoneIntoMemory() {
|
||||
throw std::runtime_error("Aborting Zone loading due to no Zone Raw File.");
|
||||
}
|
||||
|
||||
auto rawFile = Game::assetManager->GetFile(zoneFolderPath + m_ZoneRawPath);
|
||||
if (!Raw::ReadRaw(rawFile, m_Raw)) {
|
||||
LOG("Failed to parse %s", (zoneFolderPath + m_ZoneRawPath).c_str());
|
||||
throw std::runtime_error("Aborting Zone loading due to invalid Raw File.");
|
||||
}
|
||||
|
||||
// Generate terrain mesh for fast scene lookups
|
||||
Raw::GenerateTerrainMesh(m_Raw, m_TerrainMesh);
|
||||
LOG("Generated terrain mesh with %llu vertices and %llu triangles",
|
||||
m_TerrainMesh.vertices.size(), m_TerrainMesh.triangles.size() / 3);
|
||||
|
||||
// Optionally export terrain mesh to OBJ for debugging/visualization
|
||||
if (Game::config->GetValue("export_terrain_to_obj") == "1") {
|
||||
std::string objFileName = "terrain_" + std::to_string(m_ZoneID.GetMapID()) + ".obj";
|
||||
if (Raw::WriteTerrainMeshToOBJ(m_TerrainMesh, objFileName)) {
|
||||
LOG("Exported terrain mesh to %s", objFileName.c_str());
|
||||
if (m_FileFormatVersion >= Zone::FileFormatVersion::PrePreAlpha) {
|
||||
auto rawFile = Game::assetManager->GetFile(zoneFolderPath + m_ZoneRawPath);
|
||||
if (!Raw::ReadRaw(rawFile, m_Raw)) {
|
||||
LOG("Failed to parse %s", (zoneFolderPath + m_ZoneRawPath).c_str());
|
||||
throw std::runtime_error("Aborting Zone loading due to invalid Raw File.");
|
||||
}
|
||||
LOG("Loaded Raw Terrain with %u chunks", m_Raw.numChunks);
|
||||
|
||||
|
||||
// Optionally export terrain mesh to OBJ for debugging/visualization
|
||||
if (Game::config->GetValue("export_terrain_to_obj") == "1") {
|
||||
|
||||
// Generate terrain mesh
|
||||
Raw::GenerateTerrainMesh(m_Raw, m_TerrainMesh);
|
||||
LOG("Generated terrain mesh with %llu vertices and %llu triangles", m_TerrainMesh.vertices.size(), m_TerrainMesh.triangles.size() / 3);
|
||||
|
||||
// Write to OBJ
|
||||
std::string objFileName = "terrain_" + std::to_string(m_ZoneID.GetMapID()) + ".obj";
|
||||
if (Raw::WriteTerrainMeshToOBJ(m_TerrainMesh, objFileName)) {
|
||||
LOG("Exported terrain mesh to %s", objFileName.c_str());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOG("Zone %s is too old to have Raw data, please update the map", m_ZoneFilePath.c_str());
|
||||
}
|
||||
|
||||
if (m_FileFormatVersion >= Zone::FileFormatVersion::PreAlpha) {
|
||||
@@ -221,7 +233,7 @@ uint32_t Zone::CalculateChecksum() const {
|
||||
void Zone::LoadLevelsIntoMemory() {
|
||||
for (auto& [sceneID, scene] : m_Scenes) {
|
||||
if (scene.level) continue;
|
||||
scene.level = std::make_unique<Level>(this, m_ZonePath + scene.filename);
|
||||
scene.level = std::make_unique<Level>(this, sceneID, m_ZonePath + scene.filename);
|
||||
|
||||
if (scene.level->m_ChunkHeaders.empty()) continue;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user