Skip to content

Commit

Permalink
simplify GetAddonAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
marzent committed Mar 31, 2023
1 parent b555a42 commit 0a0b405
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions OverlayPlugin.Core/MemoryProcessors/AtkStage/AtkStageMemory62.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
Expand All @@ -21,21 +20,18 @@ public AtkStageMemory62(TinyIoCContainer container) :
public unsafe IntPtr GetAddonAddress(string name)
{
var atkStage = AtkStage.GetSingleton();
var raptureAtkUnitManager = atkStage->RaptureAtkUnitManager;
var unitMgr = raptureAtkUnitManager->AtkUnitManager;
var list = unitMgr.AllLoadedUnitsList;
var entries = (long*)&list.AtkUnitEntries;
if (atkStage == null)
return nint.Zero;

for (var i = 0; i < list.Count; i++)
{
var ptr = new nint(entries[i]);
var atkUnit = (AtkUnitBase)Marshal.PtrToStructure(ptr, typeof(AtkUnitBase))!;
var atkUnitNameValue = FFXIVMemory.GetStringFromBytes(atkUnit.Name, 32);
if (atkUnitNameValue.Equals(name))
return ptr;
}
var unitMgr = atkStage->RaptureAtkUnitManager;
if (unitMgr == null)
return nint.Zero;

var addon = unitMgr->GetAddonByName(name);
if (addon == null)
return nint.Zero;

return nint.Zero;
return (IntPtr)addon;
}

private static readonly Dictionary<string, Type> AddonMap = new()
Expand Down

0 comments on commit 0a0b405

Please sign in to comment.