diff --git a/Tweaks/UiAdjustment/RemoveQuestMarkerLimit.cs b/Tweaks/UiAdjustment/RemoveQuestMarkerLimit.cs index 7421fe4f..5d1316c5 100644 --- a/Tweaks/UiAdjustment/RemoveQuestMarkerLimit.cs +++ b/Tweaks/UiAdjustment/RemoveQuestMarkerLimit.cs @@ -1,41 +1,25 @@ -using FFXIVClientStructs.FFXIV.Client.Game; +using Dalamud.Utility.Signatures; +using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.System.String; using FFXIVClientStructs.FFXIV.Client.Game.UI; +using FFXIVClientStructs.Interop; +using SimpleTweaksPlugin.TweakSystem; using SimpleTweaksPlugin.Utility; namespace SimpleTweaksPlugin.Tweaks.UiAdjustment; +[TweakName("Remove Quest Marker Limit")] +[TweakDescription("Allow the map and minimap to display markers for more than 5 active quests.")] +[Changelog(UnreleasedVersion, "Fix tweak not working since API 9")] public unsafe class RemoveQuestMarkerLimit : UiAdjustments.SubTweak { - public override string Name => "Remove Quest Marker Limit"; - public override string Description => "Allow the map and minimap to display markers for more than 5 active quests."; - private delegate void* SetQuestMarkerInfoDelegate(Map* map, uint index, ushort questId, Utf8String* name, ushort recommendedLevel); + [TweakHook, Signature("E8 ?? ?? ?? ?? 0F B6 5B 0A", DetourName = nameof(SetQuestMarkerInfoDetour))] private HookWrapper setQuestMarkerInfoHook; - protected override void Enable() { - this.setQuestMarkerInfoHook ??= Common.Hook( - "E8 ?? ?? ?? ?? 0F B6 5B 0A", - this.SetQuestMarkerInfoDetour - ); - this.setQuestMarkerInfoHook?.Enable(); - - base.Enable(); - } - - protected override void Disable() { - this.setQuestMarkerInfoHook?.Disable(); - base.Disable(); - } - - public override void Dispose() { - this.setQuestMarkerInfoHook?.Dispose(); - base.Dispose(); - } - private void* SetQuestMarkerInfoDetour(Map* map, uint index, ushort questId, Utf8String* name, ushort recommendedLevel) { - var result = this.setQuestMarkerInfoHook.Original(map, index, questId, name, recommendedLevel); - if (QuestManager.Instance()->NormalQuestsSpan[(int)index].IsHidden) { - map->QuestDataSpan[(int)index].ShouldRender = true; + var result = setQuestMarkerInfoHook.Original(map, index, questId, name, recommendedLevel); + if (!QuestManager.Instance()->NormalQuestsSpan[(int)index].IsHidden) { + map->QuestDataSpan.GetPointer((int) index)->ShouldRender = true; } return result; }