diff options
| author | KiritoDv <kiritodev01@gmail.com> | 2024-01-31 10:26:10 -0600 |
|---|---|---|
| committer | Lywx <kiritodev01@gmail.com> | 2024-01-31 12:05:40 -0600 |
| commit | 6e5414f704cc26c9d45649188d1b6e51fcad46c3 (patch) | |
| tree | d9f38b296eb3d62ce36498dab6ec5de29ffb6cfe | |
| parent | af3f59fde52eccb0d419dea42d5ea6185e401f91 (diff) | |
Added ZAPD like format support
| -rw-r--r-- | src/Companion.cpp | 33 | ||||
| -rw-r--r-- | src/factories/BaseFactory.h | 2 |
2 files changed, 29 insertions, 6 deletions
diff --git a/src/Companion.cpp b/src/Companion.cpp index be70629..ba0df34 100644 --- a/src/Companion.cpp +++ b/src/Companion.cpp @@ -298,16 +298,39 @@ void Companion::Process() { for(auto asset = root.begin(); asset != root.end(); ++asset){ auto entryName = asset->first.as<std::string>(); - std::string output = (this->gCurrentDirectory / entryName).string(); - std::replace(output.begin(), output.end(), '\\', '/'); + auto assetNode = asset->second; - if(entryName.find(":config") != std::string::npos) { + if(entryName.find(":config") != std::string::npos) { continue; } - this->gConfig.segment.temporal.clear(); + // Parse horizontal assets + if(assetNode["files"]){ + auto segment = assetNode["segment"] ? assetNode["segment"].as<uint8_t>() : -1; + auto files = assetNode["files"]; + for (const auto& file : files) { + auto node = file.as<YAML::Node>(); + auto childName = node["name"].as<std::string>(); + + if(!node["offset"]) { + continue; + } + + if(segment != -1) { + node["offset"] = (segment << 24) | node["offset"].as<uint32_t>(); + } - this->ExtractNode(asset->second, output, wrapper); + auto output = (this->gCurrentDirectory / entryName / childName).string(); + std::replace(output.begin(), output.end(), '\\', '/'); + this->gConfig.segment.temporal.clear(); + this->ExtractNode(node, output, wrapper); + } + } else { + std::string output = (this->gCurrentDirectory / entryName).string(); + std::replace(output.begin(), output.end(), '\\', '/'); + this->gConfig.segment.temporal.clear(); + this->ExtractNode(assetNode, output, wrapper); + } spdlog::set_pattern(regular); SPDLOG_INFO("------------------------------------------------"); diff --git a/src/factories/BaseFactory.h b/src/factories/BaseFactory.h index cf00685..fc7aed6 100644 --- a/src/factories/BaseFactory.h +++ b/src/factories/BaseFactory.h @@ -40,7 +40,7 @@ std::optional<T> GetNode(YAML::Node& node, const std::string& key) { template<typename T> T GetSafeNode(YAML::Node& node, const std::string& key) { if(!node[key]) { - throw std::runtime_error("Failed to find entry"); + throw std::runtime_error("Failed to find " + key); } return node[key].as<T>(); |
