@@ -130,6 +130,11 @@ static std::string GetTypeNode(YAML::Node& node) {
130130Companion* Companion::Instance;
131131
132132void Companion::Init (const ExportType type) {
133+ size_t assetCount = 0 ;
134+ Init (type, std::atomic_ref<size_t >(assetCount));
135+ }
136+
137+ void Companion::Init (const ExportType type, std::atomic_ref<size_t > assetCount) {
133138
134139 spdlog::set_level (spdlog::level::debug);
135140 spdlog::set_pattern (" [%Y-%m-%d %H:%M:%S.%e] [%l] %v" );
@@ -224,7 +229,7 @@ void Companion::Init(const ExportType type) {
224229 this ->RegisterFactory (" NAUDIO:V1:SEQUENCE" , std::make_shared<NSequenceFactory>());
225230#endif
226231#ifndef __EMSCRIPTEN__ // We call this manually
227- this ->Process ();
232+ this ->Process (assetCount );
228233#endif
229234}
230235
@@ -356,7 +361,7 @@ void Companion::ParseModdingConfig() {
356361}
357362
358363
359- void Companion::ParseCurrentFileConfig (YAML::Node node) {
364+ void Companion::ParseCurrentFileConfig (YAML::Node node, std::atomic_ref< size_t > assetCount ) {
360365 if (node[" external_files" ]) {
361366 auto externalFiles = node[" external_files" ];
362367 if (externalFiles.IsSequence () && externalFiles.size ()) {
@@ -388,8 +393,10 @@ void Companion::ParseCurrentFileConfig(YAML::Node node) {
388393 YAML::Node root = YAML::LoadFile (externalFileName);
389394
390395 if (!Torch::contains (this ->gProcessedFiles , this ->gCurrentFile )) {
391- ProcessFile (root);
392- this ->gProcessedFiles .insert (this ->gCurrentFile );
396+ ProcessFile (root, assetCount);
397+ if (process) {
398+ this ->gProcessedFiles .insert (this ->gCurrentFile );
399+ }
393400 }
394401
395402 SPDLOG_INFO (" Finishing processing of file: {}" , currentFile);
@@ -610,6 +617,12 @@ void Companion::ProcessTables(YAML::Node& rom) {
610617}
611618
612619void Companion::ProcessFile (YAML::Node root) {
620+ size_t assetCount = 0 ;
621+ ProcessFile (root, std::atomic_ref<size_t >(assetCount));
622+ }
623+
624+ void Companion::ProcessFile (YAML::Node root, std::atomic_ref<size_t > assetCount) {
625+ assetCount++;
613626 // Set compressed file offsets and compression type
614627 if (auto segments = root[" :config" ][" segments" ]) {
615628 if (segments.IsSequence () && segments.size () > 0 ) {
@@ -672,10 +685,10 @@ void Companion::ProcessFile(YAML::Node root) {
672685 GFXDOverride::ClearVtx ();
673686
674687 if (root[" :config" ]) {
675- this ->ParseCurrentFileConfig (root[" :config" ]);
688+ this ->ParseCurrentFileConfig (root[" :config" ], assetCount );
676689 }
677690
678- if (!this ->NodeHasChanges (this ->gCurrentFile ) && !this ->gNodeForceProcessing ) {
691+ if (!process || (! this ->NodeHasChanges (this ->gCurrentFile ) && !this ->gNodeForceProcessing ) ) {
679692 return ;
680693 }
681694
@@ -1018,8 +1031,7 @@ void Companion::ProcessFile(YAML::Node root) {
10181031 }
10191032}
10201033
1021- void Companion::Process () {
1022-
1034+ void Companion::Process (std::atomic_ref<size_t > assetCount) {
10231035 auto configPath = this ->gSourceDirectory / " config.yml" ;
10241036
10251037 if (!fs::exists (configPath)) {
@@ -1315,8 +1327,10 @@ void Companion::Process() {
13151327 this ->gCurrentFile = yamlPath;
13161328
13171329 if (!Torch::contains (this ->gProcessedFiles , this ->gCurrentFile )) {
1318- ProcessFile (root);
1319- this ->gProcessedFiles .insert (this ->gCurrentFile );
1330+ ProcessFile (root, assetCount);
1331+ if (process) {
1332+ this ->gProcessedFiles .insert (this ->gCurrentFile );
1333+ }
13201334 }
13211335 }
13221336
@@ -1672,6 +1686,10 @@ std::optional<std::vector<std::tuple<std::string, YAML::Node>>> Companion::GetNo
16721686
16731687}
16741688
1689+ void Companion::SetProcess (bool shouldProcess) {
1690+ this ->process = shouldProcess;
1691+ }
1692+
16751693void Companion::RegisterCompanionFile (const std::string path, std::vector<char > data) {
16761694 this ->gCompanionFiles [path] = data;
16771695 SPDLOG_TRACE (" Registered companion file {}" , path);
0 commit comments