Skip to content

Commit

Permalink
Critical bug fix
Browse files Browse the repository at this point in the history
- Fixed wrong behavior, making launch delete all .pak files regardless when scan for damaged/missing files.
- User can also now perform File Verification even when the client needs updates. This results in full file verification while updating the game client.
  • Loading branch information
Leayal committed Aug 6, 2024
1 parent cd58773 commit 187ab4b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ namespace Leayal.SnowBreakLauncher
{
static internal class AssemblyInfo
{
public const string Version = "1.3.5";
public const string Version = "1.3.6";
}
}
34 changes: 23 additions & 11 deletions src/Snowbreak/GameUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -540,23 +540,35 @@ await Task.WhenAll(task_FileCheck,
// Double ensure that we don't get any Pak archives left over from old major releases to cause data collisions.
if (fixMode)
{
var dataDirectory = mgr.Files.GetFullPath(Path.Join("Game", "Content"));
if (Directory.Exists(dataDirectory))
static void EncapsuleToEscapeAsyncRule_DeleteUnknownFiles(GameManager mgr, FrozenDictionary<string, PakEntry> remoteFilelist)
{
foreach (var filename in Directory.EnumerateFiles(dataDirectory, "*", new EnumerationOptions() { RecurseSubdirectories = true, ReturnSpecialDirectories = false, AttributesToSkip = FileAttributes.None, MaxRecursionDepth = 30 }))
var gameDirLength = mgr.FullPathOfGameDirectory.Length;
var dataDirectory = mgr.Files.GetFullPath(Path.Join("Game", "Content"));
ReadOnlySpan<char> directorySeparatorChars = stackalloc char[]
{
var mem_relativePath = filename.AsMemory(dataDirectory.Length + 1);
var relativePath = string.Create(mem_relativePath.Length, mem_relativePath, (c, obj) =>
{
obj.Span.CopyTo(c);
c.Replace('\\', '/');
});
if (!remoteFilelist.ContainsKey(relativePath))
Path.DirectorySeparatorChar,
Path.AltDirectorySeparatorChar,
' ',
char.MinValue
};
if (Directory.Exists(dataDirectory))
{
foreach (var filename in Directory.EnumerateFiles(dataDirectory, "*", new EnumerationOptions() { RecurseSubdirectories = true, ReturnSpecialDirectories = false, AttributesToSkip = FileAttributes.None, MaxRecursionDepth = 30 }))
{
FileSystem.ForceDelete(filename);
var mem_relativePath = filename.AsMemory(gameDirLength).TrimStart(directorySeparatorChars); // Can optimize it by using "filename.AsMemory(gameDirLength + 1);" but we will lost sanitize
var relativePath = string.Create(mem_relativePath.Length, mem_relativePath, (c, obj) =>
{
obj.Span.CopyTo(c);
c.Replace('\\', '/');
});
if (!remoteFilelist.ContainsKey(relativePath))
{
FileSystem.ForceDelete(filename);
}
}
}
}
EncapsuleToEscapeAsyncRule_DeleteUnknownFiles(this.manager, remoteFilelist);
}
else if (bufferedLocalFileTable.Count != 0)
{
Expand Down
9 changes: 8 additions & 1 deletion src/Windows/MainWindow.Handlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,14 @@ public async void MenuItem_GameDataIntegrityCheck_Click(object source, RoutedEve
return;
}

if (this.GameStartButtonState != GameStartButtonState.CanStartGame) return;
switch (this.GameStartButtonState)
{
case GameStartButtonState.CanStartGame:
case GameStartButtonState.RequiresUpdate:
break;
default:
return;
}

if ((await ShowYesNoMsgBox("Are you sure you want to begin file integrity check and download missing/damaged files?" + Environment.NewLine
+ "(This action will take a short time or long time, depending on your disk's speed)", "Confirmation")) != MsBox.Avalonia.Enums.ButtonResult.Yes)
Expand Down

0 comments on commit 187ab4b

Please sign in to comment.