mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-01-03 06:13:40 +01:00
Merge pull request #136 from rreminy/patch-6
Remove constant Alloc and Free calls from ActorTable
This commit is contained in:
commit
e1936a217c
1 changed files with 6 additions and 3 deletions
|
|
@ -32,6 +32,9 @@ namespace Dalamud.Game.ClientState.Actors {
|
||||||
private ClientStateAddressResolver Address { get; }
|
private ClientStateAddressResolver Address { get; }
|
||||||
private Dalamud dalamud;
|
private Dalamud dalamud;
|
||||||
|
|
||||||
|
private static int sz = Marshal.SizeOf(typeof(Structs.Actor));
|
||||||
|
private IntPtr actorMem = Marshal.AllocHGlobal(sz);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set up the actor table collection.
|
/// Set up the actor table collection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -64,15 +67,15 @@ namespace Dalamud.Game.ClientState.Actors {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// FIXME: hack workaround for trying to access the player on logout, after the main object has been deleted
|
// FIXME: hack workaround for trying to access the player on logout, after the main object has been deleted
|
||||||
var sz = Marshal.SizeOf(typeof(Structs.Actor));
|
//var sz = Marshal.SizeOf(typeof(Structs.Actor));
|
||||||
var actorMem = Marshal.AllocHGlobal(sz); // we arguably could just reuse this
|
//var actorMem = Marshal.AllocHGlobal(sz); // we arguably could just reuse this
|
||||||
if (!ReadProcessMemory(Process.GetCurrentProcess().Handle, offset, actorMem, sz, out _)) {
|
if (!ReadProcessMemory(Process.GetCurrentProcess().Handle, offset, actorMem, sz, out _)) {
|
||||||
Log.Debug("ActorTable - ReadProcessMemory failed: likely player deletion during logout");
|
Log.Debug("ActorTable - ReadProcessMemory failed: likely player deletion during logout");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var actorStruct = Marshal.PtrToStructure<Structs.Actor>(actorMem);
|
var actorStruct = Marshal.PtrToStructure<Structs.Actor>(actorMem);
|
||||||
Marshal.FreeHGlobal(actorMem);
|
//Marshal.FreeHGlobal(actorMem);
|
||||||
|
|
||||||
//Log.Debug("ActorTable[{0}]: {1} - {2} - {3}", index, tblIndex.ToString("X"), offset.ToString("X"),
|
//Log.Debug("ActorTable[{0}]: {1} - {2} - {3}", index, tblIndex.ToString("X"), offset.ToString("X"),
|
||||||
// actorStruct.ObjectKind.ToString());
|
// actorStruct.ObjectKind.ToString());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue