diff --git a/Legion/RpakLib.h b/Legion/RpakLib.h index 4ea107c3..36e60b67 100644 --- a/Legion/RpakLib.h +++ b/Legion/RpakLib.h @@ -471,6 +471,7 @@ class RpakLib uint32_t LoadedFileIndex; List LoadFileQueue; + List LoadedFilePaths; // The exporter formats for models and anims std::unique_ptr ModelExporter; diff --git a/Legion/src/RpakLib.cpp b/Legion/src/RpakLib.cpp index fc389133..23e606cc 100644 --- a/Legion/src/RpakLib.cpp +++ b/Legion/src/RpakLib.cpp @@ -37,12 +37,10 @@ RpakLib::RpakLib() void RpakLib::LoadRpaks(const List& Paths) { - List LoadedFiles; - for (auto& Rpak : Paths) { // Ignore duplicate files triggered by loading multiple rpaks at once. - if (LoadedFiles.Contains(Rpak)) + if (this->LoadedFilePaths.Contains(Rpak)) continue; this->LoadRpak(Rpak, false); @@ -50,7 +48,7 @@ void RpakLib::LoadRpaks(const List& Paths) // Copy over to loaded, clear for next file for (auto& Loaded : this->LoadFileQueue) { - LoadedFiles.EmplaceBack(Loaded); + this->LoadedFilePaths.EmplaceBack(Loaded); } this->LoadFileQueue.Clear(); } @@ -830,26 +828,25 @@ bool RpakLib::ParseApexRpak(const string& RpakPath, std::unique_ptrRead(File->SegmentData.get(), 0, BufferRemaining); - if (this->LoadedFileIndex == 1) - { - string BasePath = IO::Path::GetDirectoryName(RpakPath); - string FileNameNoExt = IO::Path::GetFileNameWithoutExtension(RpakPath); + + string BasePath = IO::Path::GetDirectoryName(RpakPath); + string FileNameNoExt = IO::Path::GetFileNameWithoutExtension(RpakPath); // Trim off the () if exists - if (FileNameNoExt.Contains("(")) - FileNameNoExt = FileNameNoExt.Substring(0, FileNameNoExt.IndexOf("(")); + if (FileNameNoExt.Contains("(")) + FileNameNoExt = FileNameNoExt.Substring(0, FileNameNoExt.IndexOf("(")); - string FinalPath = IO::Path::Combine(BasePath, FileNameNoExt); + string FinalPath = IO::Path::Combine(BasePath, FileNameNoExt); - for (uint32_t i = 0; i < Header.PatchIndex; i++) - { - uint16_t PatchIndexToFile = PatchIndicesToFile[i]; + for (uint32_t i = 0; i < Header.PatchIndex; i++) + { + uint16_t PatchIndexToFile = PatchIndicesToFile[i]; + string AdditionalRpakToLoad = string::Format(PatchIndexToFile == 0 ? "%s.rpak" : "%s(%02d).rpak", FinalPath.ToCString(), PatchIndexToFile); - if (PatchIndexToFile == 0) - this->LoadFileQueue.EmplaceBack(string::Format("%s.rpak", FinalPath.ToCString())); - else - this->LoadFileQueue.EmplaceBack(string::Format("%s(%02d).rpak", FinalPath.ToCString(), PatchIndexToFile)); - } + if (this->LoadedFilePaths.Contains(AdditionalRpakToLoad) || this->LoadFileQueue.Contains(AdditionalRpakToLoad)) + continue; + + this->LoadFileQueue.EmplaceBack(AdditionalRpakToLoad); } return true;