summaryrefslogtreecommitdiff
path: root/src/Companion.cpp
diff options
context:
space:
mode:
authorcoco875 <pereira.jannin@gmail.com>2025-07-08 21:56:08 +0200
committerLywx <kiritodev01@gmail.com>2025-07-08 20:32:34 -0600
commit783f2d55af1953d4cfb6dbfe82a6c6f4ac6c4016 (patch)
treea291dd061105c6452517dcc07c771b2a1e7e0f1e /src/Companion.cpp
parent35f6032824a96b98d5998e6f94d134e6aad063cd (diff)
Update Companion.cpp
Diffstat (limited to 'src/Companion.cpp')
-rw-r--r--src/Companion.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/Companion.cpp b/src/Companion.cpp
index 7815498..515b17c 100644
--- a/src/Companion.cpp
+++ b/src/Companion.cpp
@@ -105,6 +105,16 @@ namespace fs = std::filesystem;
static const std::string regular = "[%Y-%m-%d %H:%M:%S.%e] [%l] %v";
static const std::string line = "[%Y-%m-%d %H:%M:%S.%e] [%l] > %v";
+static std::string ConvertType(std::string type) {
+ int index = type.find(':');
+
+ if(index != std::string::npos) {
+ type = type.substr(index + 1);
+ }
+ std::transform(type.begin(), type.end(), type.begin(), tolower);
+ return type;
+}
+
void Companion::Init(const ExportType type) {
spdlog::set_level(spdlog::level::debug);
@@ -1452,8 +1462,8 @@ std::optional<std::tuple<std::string, YAML::Node>> Companion::GetSafeNodeByAddr(
auto [name, n] = node.value();
auto n_type = GetSafeNode<std::string>(n, "type");
- if(n_type != type) {
- throw std::runtime_error("Requested node type does not match with the target node type at " + Torch::to_hex(addr, false));
+ if(ConvertType(n_type) != ConvertType(type)) {
+ throw std::runtime_error("Requested node type does not match with the target node type at " + Torch::to_hex(addr, false) + " Found: " + ConvertType(n_type) + " Expected: " + ConvertType(type));
}
return node;
@@ -1563,16 +1573,6 @@ std::string Companion::CalculateHash(const std::vector<uint8_t>& data) {
return Chocobo1::SHA1().addData(data).finalize().toString();
}
-static std::string ConvertType(std::string type) {
- int index = type.find(':');
-
- if(index != std::string::npos) {
- type = type.substr(index + 1);
- }
- std::transform(type.begin(), type.end(), type.begin(), tolower);
- return type;
-}
-
std::optional<YAML::Node> Companion::AddAsset(YAML::Node asset) {
if(!asset["offset"] || !asset["type"]) {
return std::nullopt;