Skip to content

Commit

Permalink
fix #2363
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Jan 10, 2025
1 parent bda63d0 commit 561d01c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public async ValueTask<ValueResult<bool, GachaLogQuery>> GetQueryAsync()
{
using (MemoryStream memoryStream = await memoryStreamFactory.GetStreamAsync(fileStream).ConfigureAwait(false))
{
string? result = Match(memoryStream, cacheFile.Contains(GameConstants.GenshinImpactData, StringComparison.Ordinal));
string? result = Match(memoryStream, cacheFile.Contains(GameConstants.GenshinImpactData, StringComparison.OrdinalIgnoreCase));

if (string.IsNullOrEmpty(result))
{
Expand All @@ -97,7 +97,7 @@ public async ValueTask<ValueResult<bool, GachaLogQuery>> GetQueryAsync()
using (IMemoryOwner<byte> memoryOwner = MemoryPool<byte>.Shared.Rent((int)stream.Length))
{
Span<byte> span = memoryOwner.Memory.Span;
stream.Write(span);
stream.Read(span);

ReadOnlySpan<byte> match = isOversea
? "https://gs.hoyoverse.com/genshin/event/e20190909gacha-v3/index.html"u8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public async ValueTask<ValueResult<bool, string>> SilentGetGamePathAsync()
}

// Try to locate by unity log
if (await gameLocatorFactory.LocateSingleAsync(GameLocationSourceKind.UnityLog).ConfigureAwait(false) is (true, { } path1))
if (await gameLocatorFactory.LocateSingleAsync(GameLocationSourceKind.UnityLog).ConfigureAwait(false) is (true, { } path))
{
launchOptions.UpdateGamePath(path1);
launchOptions.UpdateGamePath(path);
return new(true, launchOptions.GamePath);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ public void AddStrategy(AvatarStrategy strategy)
{
this.Add(strategy);
}

public void RemoveStrategy(AvatarStrategy strategy)
{
this.Delete(strategy);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ internal sealed partial class AvatarStrategyService : IAvatarStrategyService
public async ValueTask<AvatarStrategy?> GetStrategyByAvatarId(AvatarId avatarId)
{
AvatarStrategy? strategy = repository.GetStrategyByAvatarId(avatarId);
if (strategy is { ChineseStrategyId: 0 } or { OverseaStrategyId: 0 })
{
repository.RemoveStrategy(strategy);
strategy = default;
return default;
}

if (strategy is null)
{
using (IServiceScope scope = serviceProvider.CreateScope())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ internal interface IAvatarStrategyRepository : IRepository<AvatarStrategy>
AvatarStrategy? GetStrategyByAvatarId(AvatarId avatarId);

void AddStrategy(AvatarStrategy strategy);
void RemoveStrategy(AvatarStrategy strategy);

Check warning on line 15 in src/Snap.Hutao/Snap.Hutao/Service/Hutao/IAvatarStrategyRepository.cs

View workflow job for this annotation

GitHub Actions / build

Check warning on line 15 in src/Snap.Hutao/Snap.Hutao/Service/Hutao/IAvatarStrategyRepository.cs

View workflow job for this annotation

GitHub Actions / build

}

0 comments on commit 561d01c

Please sign in to comment.