Skip to content

Commit

Permalink
Force game's binary to be checked throughoutly
Browse files Browse the repository at this point in the history
  • Loading branch information
Leayal committed Apr 8, 2024
1 parent f3f66bc commit 1f631b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 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.2.7";
public const string Version = "1.2.8";
}
}
8 changes: 7 additions & 1 deletion src/Snowbreak/GameUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ static bool IsFastVerifyMatchedUnsafe(string file, long? fastVerifyValue)
return ((new DateTimeOffset(File.GetLastWriteTimeUtc(file))).ToUnixTimeSeconds() == fastVerifyValue.Value);
}

/// <summary></summary>
/// <param name="pak"></param>
/// <returns><see langword="true"/> if the file's cached hash should be skipped and the hash will be calculated from data on disk. <see langword="false"/> if cached hash is allowed to use.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static bool IsFileForcedToSkipHashCache(in PakEntry pak) => pak.name.EndsWith("Game.exe", StringComparison.OrdinalIgnoreCase); // Currently there's only 1 file so we can do one-line.

private readonly record struct DownloadResult(bool success, long fileLastWriteTimeInUnixSeconds);

public async Task UpdateGameClientAsync(GameClientManifestData? remote_manifest = null, bool skipCrcTableCache = false, GameUpdaterProgressCallback? progressCallback = null, CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -145,7 +151,7 @@ public async Task UpdateGameClientAsync(GameClientManifestData? remote_manifest
var path_localPak = mgr.Files.GetFullPath(pak.name);
if (File.Exists(path_localPak))
{
if (!skipCrcTableCache && bufferedLocalFileTable.TryGetValue(pak.name, out var localPakInfo) && IsFastVerifyMatchedUnsafe(path_localPak, localPakInfo.fastVerify) && !string.IsNullOrEmpty(localPakInfo.hash))
if (!skipCrcTableCache && !IsFileForcedToSkipHashCache(in pak) && bufferedLocalFileTable.TryGetValue(pak.name, out var localPakInfo) && IsFastVerifyMatchedUnsafe(path_localPak, localPakInfo.fastVerify) && !string.IsNullOrEmpty(localPakInfo.hash))
{
if (!string.Equals(localPakInfo.hash, pak.hash, StringComparison.OrdinalIgnoreCase) || localPakInfo.sizeInBytes != pak.sizeInBytes)
{
Expand Down

0 comments on commit 1f631b0

Please sign in to comment.