summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAltoXorg <atrl101@yahoo.com>2024-04-23 11:49:56 +0800
committerLywx <kiritodev01@gmail.com>2024-04-22 22:19:52 -0600
commitc90e106087f4113cf34dee232207c3fe4eb31497 (patch)
tree52e24c711f4309bb4634c07abe95a499f2fa3d92
parent6fd59e84ee76715eb5cc533f68b269f089c1c414 (diff)
make external file processing first priority
-rw-r--r--src/Companion.cpp90
1 files changed, 43 insertions, 47 deletions
diff --git a/src/Companion.cpp b/src/Companion.cpp
index dc205d5..b9177f3 100644
--- a/src/Companion.cpp
+++ b/src/Companion.cpp
@@ -255,6 +255,49 @@ void Companion::ParseModdingConfig() {
void Companion::ParseCurrentFileConfig(YAML::Node node) {
+ if (node["external_files"]) {
+ auto externalFiles = node["external_files"];
+ if (externalFiles.IsSequence() && externalFiles.size()) {
+ for(size_t i = 0; i < externalFiles.size(); i++) {
+ auto externalFile = externalFiles[i];
+ if (externalFile.size() == 0) {
+ this->gCurrentExternalFiles.push_back(externalFile.as<std::string>());
+ } else {
+ SPDLOG_INFO("External File size {}", externalFile.size());
+ throw std::runtime_error("Incorrect yaml syntax for external files.\n\nThe yaml expects:\n:config:\n external_files:\n - <external_files>\n\ne.g.:\nexternal_files:\n - actors/actor1.yaml");
+ }
+
+ auto externalFileName = externalFile.as<std::string>();
+ if (std::filesystem::relative(externalFileName, this->gAssetPath).string().starts_with("../")) {
+ throw std::runtime_error("External File " + externalFileName + " Not In Asset Directory " + this->gAssetPath);
+ } else if (std::filesystem::relative(externalFileName, this->gAssetPath).string() == "") {
+ throw std::runtime_error("External File " + externalFileName + " Not In Asset Directory " + this->gAssetPath);
+ }
+
+ if (!this->gAddrMap.contains(externalFileName)) {
+ SPDLOG_INFO("Dependency on external file {}. Now processing {}", externalFileName, externalFileName);
+ auto currentFile = this->gCurrentFile;
+ auto currentDirectory = this->gCurrentDirectory;
+ auto currentExternalFiles = this->gCurrentExternalFiles;
+
+ this->gCurrentFile = externalFileName;
+ this->gCurrentDirectory = std::filesystem::relative(externalFileName, this->gAssetPath).replace_extension("");
+
+ YAML::Node root = YAML::LoadFile(externalFileName);
+
+ ProcessFile(root);
+
+ SPDLOG_INFO("Finishing processing of file: {}", currentFile);
+
+ this->gCurrentFile = currentFile;
+ this->gCurrentDirectory = currentDirectory;
+ this->gCurrentExternalFiles = currentExternalFiles;
+ this->gFileHeader.clear();
+ }
+ }
+ }
+ }
+
if(node["segments"]) {
auto segments = node["segments"];
@@ -326,53 +369,6 @@ void Companion::ParseCurrentFileConfig(YAML::Node node) {
this->gCurrentVram = { addr, offset };
}
- if (node["external_files"]) {
- auto externalFiles = node["external_files"];
- if (externalFiles.IsSequence() && externalFiles.size()) {
- for(size_t i = 0; i < externalFiles.size(); i++) {
- auto externalFile = externalFiles[i];
- if (externalFile.size() == 0) {
- this->gCurrentExternalFiles.push_back(externalFile.as<std::string>());
- } else {
- SPDLOG_INFO("External File size {}", externalFile.size());
- throw std::runtime_error("Incorrect yaml syntax for external files.\n\nThe yaml expects:\n:config:\n external_files:\n - <external_files>\n\ne.g.:\nexternal_files:\n - actors/actor1.yaml");
- }
-
- auto externalFileName = externalFile.as<std::string>();
- if (std::filesystem::relative(externalFileName, this->gAssetPath).string().starts_with("../")) {
- throw std::runtime_error("External File " + externalFileName + " Not In Asset Directory " + this->gAssetPath);
- } else if (std::filesystem::relative(externalFileName, this->gAssetPath).string() == "") {
- throw std::runtime_error("External File " + externalFileName + " Not In Asset Directory " + this->gAssetPath);
- }
-
- if (!this->gAddrMap.contains(externalFileName)) {
- SPDLOG_INFO("Dependency on external file {}. Now processing {}", externalFileName, externalFileName);
- auto currentFile = this->gCurrentFile;
- auto currentDirectory = this->gCurrentDirectory;
- auto currentSegmentNumber = gCurrentSegmentNumber;
- auto currentFileOffset = gCurrentFileOffset;
- auto currentCompressionType = gCurrentCompressionType;
-
- this->gCurrentFile = externalFileName;
- this->gCurrentDirectory = std::filesystem::relative(externalFileName, this->gAssetPath).replace_extension("");
-
- YAML::Node root = YAML::LoadFile(externalFileName);
-
- ProcessFile(root);
-
- SPDLOG_INFO("Finishing processing of file: {}", currentFile);
-
- this->gCurrentFile = currentFile;
- this->gCurrentDirectory = currentDirectory;
-
- gCurrentSegmentNumber = currentSegmentNumber;
- gCurrentFileOffset = currentFileOffset;
- gCurrentCompressionType = currentCompressionType;
- }
- }
- }
- }
-
this->gEnablePadGen = GetSafeNode<bool>(node, "autopads", true);
this->gNodeForceProcessing = GetSafeNode<bool>(node, "force", false);
this->gIndividualIncludes = GetSafeNode<bool>(node, "individual_data_incs", false);