chore: rename Framework destroy => free for accuracy

This commit is contained in:
goaaats 2022-06-20 22:10:46 +02:00
parent 3397b608d0
commit 2febdd2124
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B

View file

@ -36,8 +36,8 @@ namespace Dalamud.Game
private bool tierInitError = false; private bool tierInitError = false;
private Hook<OnUpdateDetour> updateHook; private Hook<OnUpdateDetour> updateHook;
private Hook<OnDestroyDetour> destroyHook; private Hook<OnDestroyDetour> freeHook;
private Hook<OnRealDestroyDelegate> realDestroyHook; private Hook<OnRealDestroyDelegate> destroyHook;
private Thread? frameworkUpdateThread; private Thread? frameworkUpdateThread;
@ -50,8 +50,8 @@ namespace Dalamud.Game
this.Address.Setup(); this.Address.Setup();
this.updateHook = new Hook<OnUpdateDetour>(this.Address.TickAddress, this.HandleFrameworkUpdate); this.updateHook = new Hook<OnUpdateDetour>(this.Address.TickAddress, this.HandleFrameworkUpdate);
this.destroyHook = new Hook<OnDestroyDetour>(this.Address.FreeAddress, this.HandleFrameworkDestroy); this.freeHook = new Hook<OnDestroyDetour>(this.Address.FreeAddress, this.HandleFrameworkFree);
this.realDestroyHook = new Hook<OnRealDestroyDelegate>(this.Address.DestroyAddress, this.HandleRealDestroy); this.destroyHook = new Hook<OnRealDestroyDelegate>(this.Address.DestroyAddress, this.HandleFrameworkDestroy);
} }
/// <summary> /// <summary>
@ -133,8 +133,8 @@ namespace Dalamud.Game
Service<GameNetwork>.Get().Enable(); Service<GameNetwork>.Get().Enable();
this.updateHook.Enable(); this.updateHook.Enable();
this.freeHook.Enable();
this.destroyHook.Enable(); this.destroyHook.Enable();
this.realDestroyHook.Enable();
} }
/// <summary> /// <summary>
@ -224,13 +224,13 @@ namespace Dalamud.Game
Service<GameNetwork>.GetNullable()?.ExplicitDispose(); Service<GameNetwork>.GetNullable()?.ExplicitDispose();
this.updateHook?.Disable(); this.updateHook?.Disable();
this.freeHook?.Disable();
this.destroyHook?.Disable(); this.destroyHook?.Disable();
this.realDestroyHook?.Disable();
Thread.Sleep(500); Thread.Sleep(500);
this.updateHook?.Dispose(); this.updateHook?.Dispose();
this.freeHook?.Dispose();
this.destroyHook?.Dispose(); this.destroyHook?.Dispose();
this.realDestroyHook?.Dispose();
this.updateStopwatch.Reset(); this.updateStopwatch.Reset();
statsStopwatch.Reset(); statsStopwatch.Reset();
@ -346,7 +346,7 @@ namespace Dalamud.Game
return this.updateHook.Original(framework); return this.updateHook.Original(framework);
} }
private bool HandleRealDestroy(IntPtr framework) private bool HandleFrameworkDestroy(IntPtr framework)
{ {
if (this.DispatchUpdateEvents) if (this.DispatchUpdateEvents)
{ {
@ -360,15 +360,15 @@ namespace Dalamud.Game
this.DispatchUpdateEvents = false; this.DispatchUpdateEvents = false;
return this.realDestroyHook.Original(framework); return this.destroyHook.Original(framework);
} }
private IntPtr HandleFrameworkDestroy() private IntPtr HandleFrameworkFree()
{ {
Log.Information("Framework::Free!"); Log.Information("Framework::Free!");
// Store the pointer to the original trampoline location // Store the pointer to the original trampoline location
var originalPtr = Marshal.GetFunctionPointerForDelegate(this.destroyHook.Original); var originalPtr = Marshal.GetFunctionPointerForDelegate(this.freeHook.Original);
var dalamud = Service<Dalamud>.Get(); var dalamud = Service<Dalamud>.Get();
dalamud.Unload(); dalamud.Unload();