diff options
| author | KiritoDv <kiritodev01@gmail.com> | 2024-01-31 11:17:29 -0600 |
|---|---|---|
| committer | Lywx <kiritodev01@gmail.com> | 2024-01-31 12:05:40 -0600 |
| commit | 7c93abed9a0fd82de1b5b05abf27e60d245c3509 (patch) | |
| tree | 5f4ff74d3ba29b2f372f260b75fa770e336fe507 /src/utils | |
| parent | 6e5414f704cc26c9d45649188d1b6e51fcad46c3 (diff) | |
Added auto texture size calculation
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/Decompressor.cpp | 6 | ||||
| -rw-r--r-- | src/utils/Decompressor.h | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/utils/Decompressor.cpp b/src/utils/Decompressor.cpp index 7de4338..a53177b 100644 --- a/src/utils/Decompressor.cpp +++ b/src/utils/Decompressor.cpp @@ -35,7 +35,7 @@ DataChunk* Decompressor::Decode(const std::vector<uint8_t>& buffer, const uint32 } } -DecompressedData Decompressor::AutoDecode(YAML::Node& node, std::vector<uint8_t>& buffer) { +DecompressedData Decompressor::AutoDecode(YAML::Node& node, std::vector<uint8_t>& buffer, std::optional<size_t> manualSize) { if(!node["offset"]){ throw std::runtime_error("Failed to find offset"); } @@ -45,7 +45,7 @@ DecompressedData Decompressor::AutoDecode(YAML::Node& node, std::vector<uint8_t> if(node["mio0"]){ const auto mio0 = node["mio0"].as<uint32_t>(); auto decoded = Decode(buffer, offset, CompressionType::MIO0); - auto size = node["size"] ? node["size"].as<size_t>() : decoded->size - mio0; + auto size = node["size"] ? node["size"].as<size_t>() : manualSize.value_or(decoded->size - mio0); return { .root = decoded, @@ -63,7 +63,7 @@ DecompressedData Decompressor::AutoDecode(YAML::Node& node, std::vector<uint8_t> return { .root = nullptr, - .segment = { buffer.data() + offset, node["size"] ? node["size"].as<size_t>() : buffer.size() - offset } + .segment = { buffer.data() + offset, node["size"] ? node["size"].as<size_t>() : manualSize.value_or(buffer.size() - offset) } }; } diff --git a/src/utils/Decompressor.h b/src/utils/Decompressor.h index 1bd5c05..4e3c298 100644 --- a/src/utils/Decompressor.h +++ b/src/utils/Decompressor.h @@ -26,7 +26,7 @@ struct DecompressedData { class Decompressor { public: static DataChunk* Decode(const std::vector<uint8_t>& buffer, uint32_t offset, CompressionType type); - static DecompressedData AutoDecode(YAML::Node& node, std::vector<uint8_t>& buffer); + static DecompressedData AutoDecode(YAML::Node& node, std::vector<uint8_t>& buffer, std::optional<size_t> size = std::nullopt); static uint32_t TranslateAddr(uint32_t addr); static bool IsSegmented(uint32_t addr); static bool IsCompressed(YAML::Node& node); |
