fix unlocking fps

This commit is contained in:
DismissedLight
2024-03-14 19:58:01 +08:00
parent 206100d8ef
commit b98dc9f5d3
3 changed files with 7 additions and 4 deletions

View File

@@ -23,8 +23,10 @@ internal sealed class LaunchExecutionUnlockFpsHandler : ILaunchExecutionDelegate
try
{
await unlocker.UnlockAsync(context.CancellationToken).ConfigureAwait(false);
unlocker.PostUnlockAsync(context.CancellationToken).SafeForget();
if (await unlocker.UnlockAsync(context.CancellationToken).ConfigureAwait(false))
{
unlocker.PostUnlockAsync(context.CancellationToken).SafeForget();
}
}
catch (InvalidOperationException ex)
{

View File

@@ -28,7 +28,7 @@ internal sealed class GameFpsUnlocker : IGameFpsUnlocker
}
/// <inheritdoc/>
public async ValueTask UnlockAsync(CancellationToken token = default)
public async ValueTask<bool> UnlockAsync(CancellationToken token = default)
{
HutaoException.ThrowIfNot(state.IsUnlockerValid, HutaoExceptionKind.GameFpsUnlockingFailed, "This Unlocker is invalid");
(FindModuleResult result, RequiredGameModule gameModule) = await GameProcessModule.FindModuleAsync(state).ConfigureAwait(false);
@@ -37,6 +37,7 @@ internal sealed class GameFpsUnlocker : IGameFpsUnlocker
GameFpsAddress.UnsafeFindFpsAddress(state, gameModule);
state.Report();
return state.FpsAddress != 0U;
}
public async ValueTask PostUnlockAsync(CancellationToken token = default)

View File

@@ -11,5 +11,5 @@ internal interface IGameFpsUnlocker
{
ValueTask PostUnlockAsync(CancellationToken token = default);
ValueTask UnlockAsync(CancellationToken token = default);
ValueTask<bool> UnlockAsync(CancellationToken token = default);
}