This commit is contained in:
marzent 2025-12-11 23:18:27 +01:00 committed by GitHub
commit d3c4a68b08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,8 +33,8 @@ internal sealed class Framework : IInternalDisposableService, IFramework
private readonly Stopwatch updateStopwatch = new();
private readonly HitchDetector hitchDetector;
private readonly Hook<CSFramework.Delegates.Tick> updateHook;
private readonly Hook<CSFramework.Delegates.Destroy> destroyHook;
private readonly Hook<CSFramework.Delegates.Tick>? updateHook;
private readonly Hook<CSFramework.Delegates.Destroy>? destroyHook;
[ServiceManager.ServiceDependency]
private readonly GameLifecycle lifecycle = Service<GameLifecycle>.Get();
@ -66,8 +66,8 @@ internal sealed class Framework : IInternalDisposableService, IFramework
this.updateHook = Hook<CSFramework.Delegates.Tick>.FromAddress((nint)CSFramework.StaticVirtualTablePointer->Tick, this.HandleFrameworkUpdate);
this.destroyHook = Hook<CSFramework.Delegates.Destroy>.FromAddress((nint)CSFramework.StaticVirtualTablePointer->Destroy, this.HandleFrameworkDestroy);
this.updateHook.Enable();
this.destroyHook.Enable();
this.updateHook?.Enable();
this.destroyHook?.Enable();
}
/// <inheritdoc/>
@ -312,14 +312,14 @@ internal sealed class Framework : IInternalDisposableService, IFramework
this.RunOnFrameworkThread(() =>
{
// ReSharper disable once AccessToDisposedClosure
this.updateHook.Disable();
this.updateHook?.Disable();
// ReSharper disable once AccessToDisposedClosure
this.destroyHook.Disable();
this.destroyHook?.Disable();
}).Wait();
this.updateHook.Dispose();
this.destroyHook.Dispose();
this.updateHook?.Dispose();
this.destroyHook?.Dispose();
this.updateStopwatch.Reset();
StatsStopwatch.Reset();
@ -465,7 +465,7 @@ internal sealed class Framework : IInternalDisposableService, IFramework
this.hitchDetector.Stop();
original:
return this.updateHook.OriginalDisposeSafe(thisPtr);
return this.updateHook?.OriginalDisposeSafe(thisPtr) ?? false;
}
private unsafe bool HandleFrameworkDestroy(CSFramework* thisPtr)