Skip to content

Commit 2a44755

Browse files
committedJan 15, 2025··
Apply for persistent audio patch if possible
Sometimes the user have other audio packages installed on game, which will be stored into persistent folder instead.
1 parent e7de2d2 commit 2a44755

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed
 

‎CollapseLauncher/Classes/InstallManagement/Base/InstallManagerBase.cs

+10-11
Original file line numberDiff line numberDiff line change
@@ -1582,22 +1582,19 @@ private string GetBasePersistentDirectory(string basePath, string input)
15821582
input = ConverterTool.NormalizePath(input);
15831583
string inStreamingAssetsPath = Path.Combine(basePath, input);
15841584

1585-
int baseStreamingAssetsIndex = input.LastIndexOf(streamingAssetsName, StringComparison.OrdinalIgnoreCase);
1585+
int baseStreamingAssetsIndex = input
1586+
.LastIndexOf(streamingAssetsName, StringComparison.OrdinalIgnoreCase);
15861587
if (baseStreamingAssetsIndex <= 0)
15871588
{
15881589
return inStreamingAssetsPath;
15891590
}
15901591

1591-
string inputTrimmed = input.AsSpan().Slice(baseStreamingAssetsIndex + streamingAssetsName.Length + 1)
1592-
.ToString();
1592+
string inputTrimmed = input.AsSpan()
1593+
.Slice(baseStreamingAssetsIndex + streamingAssetsName.Length + 1)
1594+
.ToString();
15931595
string inPersistentPath = Path.Combine(basePath, _gamePersistentFolderBasePath, inputTrimmed);
15941596

1595-
if (File.Exists(inPersistentPath))
1596-
{
1597-
return inPersistentPath;
1598-
}
1599-
1600-
return inStreamingAssetsPath;
1597+
return File.Exists(inPersistentPath) ? inPersistentPath : inStreamingAssetsPath;
16011598
}
16021599

16031600
private async Task FileHdiffPatcherInner(string patchPath, string sourceBasePath, string destPath, CancellationToken token)
@@ -1728,11 +1725,13 @@ protected virtual async Task ApplyHDiffMap()
17281725

17291726
bool isSuccess = false;
17301727

1731-
FileInfo sourcePath = new FileInfo(Path.Combine(gameDir, entry.SourceFileName ?? ""))
1728+
FileInfo sourcePath = new FileInfo(GetBasePersistentDirectory(gameDir, entry.SourceFileName ?? ""))
17321729
.EnsureNoReadOnly(out bool isSourceExist);
1730+
string sourcePathDir = sourcePath.DirectoryName;
17331731
FileInfo patchPath = new FileInfo(Path.Combine(gameDir, entry.PatchFileName ?? ""))
17341732
.EnsureNoReadOnly(out bool isPatchExist);
1735-
FileInfo targetPath = new FileInfo(Path.Combine(gameDir, entry.TargetFileName ?? ""))
1733+
string targetPathBasedOnSource = Path.Combine(sourcePathDir ?? "", Path.GetFileName(entry.TargetFileName ?? ""));
1734+
FileInfo targetPath = new FileInfo(targetPathBasedOnSource)
17361735
.EnsureCreationOfDirectory()
17371736
.EnsureNoReadOnly();
17381737
FileInfo targetPathTemp = new FileInfo(targetPath + "_tmp")

0 commit comments

Comments
 (0)
Please sign in to comment.