mirror of
https://github.com/izzy2lost/Torch.git
synced 2026-07-06 00:18:35 -07:00
Update Companion.cpp
This commit is contained in:
+16
-10
@@ -115,6 +115,12 @@ static std::string ConvertType(std::string type) {
|
||||
return type;
|
||||
}
|
||||
|
||||
static std::string GetTypeNode(const YAML::Node& node) {
|
||||
auto type = GetSafeNode<std::string>(node, "type");
|
||||
std::transform(type.begin(), type.end(), type.begin(), toupper);
|
||||
return type;
|
||||
}
|
||||
|
||||
void Companion::Init(const ExportType type) {
|
||||
|
||||
spdlog::set_level(spdlog::level::debug);
|
||||
@@ -257,7 +263,7 @@ void Companion::ParseEnums(std::string& header) {
|
||||
}
|
||||
|
||||
std::optional<ParseResultData> Companion::ParseNode(YAML::Node& node, std::string& name) {
|
||||
auto type = GetSafeNode<std::string>(node, "type");
|
||||
auto type = GetTypeNode(node);
|
||||
std::transform(type.begin(), type.end(), type.begin(), ::toupper);
|
||||
|
||||
spdlog::set_pattern(regular);
|
||||
@@ -594,7 +600,7 @@ void Companion::ProcessFile(YAML::Node root) {
|
||||
std::replace(output.begin(), output.end(), '\\', '/');
|
||||
|
||||
if(node["type"]){
|
||||
const auto type = GetSafeNode<std::string>(node, "type");
|
||||
const auto type = GetTypeNode(node);
|
||||
if(type == "NAUDIO:V0:SAMPLE"){
|
||||
AudioManager::Instance->bind_sample(node, output);
|
||||
}
|
||||
@@ -1017,11 +1023,11 @@ void Companion::Process() {
|
||||
auto item = job->second;
|
||||
auto method = GetSafeNode<std::string>(item, "method");
|
||||
if (method == "mio0-comptool") {
|
||||
auto type = GetSafeNode<std::string>(item, "type");
|
||||
auto type = GetTypeNode(item);
|
||||
auto target = GetSafeNode<std::string>(item, "target");
|
||||
auto restart = GetSafeNode<bool>(item, "restart");
|
||||
|
||||
if (type == "decompress") {
|
||||
if (type == "DECOMPRESS") {
|
||||
this->gRomData = CompTool::Decompress(this->gRomData);
|
||||
this->gCartridge = std::make_shared<N64::Cartridge>(this->gRomData);
|
||||
this->gCartridge->Initialize();
|
||||
@@ -1460,9 +1466,9 @@ std::optional<std::tuple<std::string, YAML::Node>> Companion::GetSafeNodeByAddr(
|
||||
}
|
||||
|
||||
auto [name, n] = node.value();
|
||||
auto n_type = GetSafeNode<std::string>(n, "type");
|
||||
auto n_type = GetTypeNode(n);
|
||||
|
||||
if(ConvertType(n_type) != ConvertType(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) + " Found: " + ConvertType(n_type) + " Expected: " + ConvertType(type));
|
||||
}
|
||||
|
||||
@@ -1539,7 +1545,7 @@ std::optional<std::vector<std::tuple<std::string, YAML::Node>>> Companion::GetNo
|
||||
|
||||
for(auto& [addr, tpl] : this->gAddrMap[this->gCurrentFile]){
|
||||
auto [name, node] = tpl;
|
||||
const auto n_type = GetSafeNode<std::string>(node, "type");
|
||||
const auto n_type = GetTypeNode(node);
|
||||
if(node["autogen"]){
|
||||
SPDLOG_DEBUG("Skipping autogenerated asset {}", name);
|
||||
continue;
|
||||
@@ -1577,15 +1583,15 @@ std::optional<YAML::Node> Companion::AddAsset(YAML::Node asset) {
|
||||
if(!asset["offset"] || !asset["type"]) {
|
||||
return std::nullopt;
|
||||
}
|
||||
const auto type = GetSafeNode<std::string>(asset, "type");
|
||||
const auto type = GetTypeNode(asset);
|
||||
const auto offset = GetSafeNode<uint32_t>(asset, "offset");
|
||||
const auto symbol = GetSafeNode<std::string>(asset, "symbol", "");
|
||||
const auto decl = this->GetNodeByAddr(offset);
|
||||
|
||||
if(decl.has_value()) {
|
||||
auto found = std::get<1>(decl.value());
|
||||
if(ConvertType(GetSafeNode<std::string>(found, "type")) != ConvertType(type)) {
|
||||
SPDLOG_ERROR("Asset clash detected {} vs {} at 0x{:X}", ConvertType(type), ConvertType(GetSafeNode<std::string>(found, "type")), offset);
|
||||
if(GetTypeNode(found) != type) {
|
||||
SPDLOG_ERROR("Asset clash detected {} vs {} at 0x{:X}", type, GetTypeNode(found), offset);
|
||||
} else {
|
||||
return found;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user