Skip to content

Commit

Permalink
Support for FFXIV v6.1
Browse files Browse the repository at this point in the history
- Tweak a broken signature for McGuffins
- Swap out a deprecated method for action unlock checks
- Use ClientStructs provided methods for Hotbars (one less sig!)
- Remove PatchedWindowSystem as it's unnecessary
- Version bump everything
- Increase the Dalamud API version
  • Loading branch information
KazWolfe committed Apr 14, 2022
1 parent c5c7688 commit d62d350
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 65 deletions.
10 changes: 5 additions & 5 deletions FFXIVPlugin/ActionExecutor/Strategies/GeneralActionStrategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private IEnumerable<uint> GetIllegalActionIDs() {
if (action == null) return null;

// ERRATA - swap out melding
if (actionId == 12 && UIState.Instance()->Hotbar.IsActionUnlocked(12)) {
if (actionId == 12 && UIState.Instance()->IsUnlockLinkUnlocked(12)) {
action = GetActionById(13)!;
}

Expand All @@ -78,11 +78,11 @@ public unsafe void Execute(uint actionId, dynamic? _) {
$"The action \"{action.Name}\" (ID {actionId}) is marked as illegal and cannot be used.");
}

if (action.UnlockLink != 0 && !UIState.Instance()->Hotbar.IsActionUnlocked(action.UnlockLink)) {
if (action.UnlockLink != 0 && !UIState.Instance()->IsUnlockLinkUnlocked(action.UnlockLink)) {
throw new ActionLockedException($"The action \"{action.Name}\" is not yet unlocked.");
}

if (actionId == 12 && UIState.Instance()->Hotbar.IsActionUnlocked(12)) {
if (actionId == 12 && UIState.Instance()->IsUnlockLinkUnlocked(12)) {
action = GetActionById(13)!;
}

Expand All @@ -96,7 +96,7 @@ public unsafe void Execute(uint actionId, dynamic? _) {

public unsafe int GetIconId(uint actionId) {
// ERRATA - replace Materia Melding with Advanced Materia Melding if unlocked
if (actionId == 12 && UIState.Instance()->Hotbar.IsActionUnlocked(12)) {
if (actionId == 12 && UIState.Instance()->IsUnlockLinkUnlocked(12)) {
actionId = 13;
}

Expand All @@ -111,7 +111,7 @@ public unsafe List<ExecutableAction> GetAllowedItems() {
continue;
}

if (action.UnlockLink != 0 && !UIState.Instance()->Hotbar.IsActionUnlocked(action.UnlockLink)) {
if (action.UnlockLink != 0 && !UIState.Instance()->IsUnlockLinkUnlocked(action.UnlockLink)) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private static ExecutableAction GetExecutableAction(Perform instrument) {
public unsafe bool IsPerformUnlocked() {
// APPARENTLY unlock 255 is performance?!
return XIVDeckPlugin.Instance.XivCommon.Functions.Journal.IsQuestCompleted(68555) &&
UIState.Instance()->Hotbar.IsActionUnlocked(255);
UIState.Instance()->IsUnlockLinkUnlocked(255);
}

public ExecutableAction? GetExecutableActionById(uint actionId) {
Expand Down
7 changes: 5 additions & 2 deletions FFXIVPlugin/Game/GameStateCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ private static class Signatures {

internal const string IsOrnamentUnlocked = "E8 ?? ?? ?? ?? BA ?? ?? ?? ?? 41 0F B6 CE";
internal const string OrnamentBitmask = "48 8D 0D ?? ?? ?? ?? 48 8B D8 E8 ?? ?? ?? ?? BA ?? ?? ?? ?? 41 0F B6 CE";

internal const string IsMcGuffinUnlocked = "8D 42 FF 3C 03 77 44";

// This sig is (interestingly) hand-found in order to allow Square to change McGuffin counts without
// breaking my code. Simple explanation is that ?? is current count of McGuffins, and 40 07 00 00 is a known
// offset to the mcguffin field of PlayerStatus.
internal const string IsMcGuffinUnlocked = "8D 42 FF 3C ?? 77 44 4C 8B 89 40 07 00 00";
}

public struct Gearset {
Expand Down
24 changes: 4 additions & 20 deletions FFXIVPlugin/Game/SigHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ namespace XIVDeck.FFXIVPlugin.Game;

public unsafe class SigHelper : IDisposable {
private static class Signatures {
internal const string ExecuteHotbarSlot = "E9 ?? ?? ?? ?? 48 8D 91 ?? ?? ?? ?? E9";

// todo: this is *way* too broad. this game is very write-happy when it comes to gearset updates.
internal const string SaveGearset = "48 89 5C 24 ?? 48 89 74 24 ?? 57 48 83 EC 30 48 8B F2 48 8B F9 33 D2";

Expand All @@ -35,9 +33,6 @@ private static class Signatures {
}

/***** functions *****/
[Signature(Signatures.ExecuteHotbarSlot, Fallibility = Fallibility.Fallible)]
private readonly delegate* unmanaged<RaptureHotbarModule*, HotBarSlot*, void> _execHotbarSlot = null!;

[Signature(Signatures.LoadHotbarSlotIcon, Fallibility = Fallibility.Fallible)]
private readonly delegate* unmanaged<HotBarSlot*, bool> _refreshHotbarIcon = null!;

Expand Down Expand Up @@ -69,19 +64,8 @@ public void Dispose() {

GC.SuppressFinalize(this);
}

public void ExecuteHotbarSlot(HotBarSlot* slot) {
if (this._execHotbarSlot == null) {
throw new InvalidOperationException("Couldn't find RaptureHotbarModule::ExecuteSlot");
}

this._execHotbarSlot( Framework.Instance()->GetUiModule()->GetRaptureHotbarModule(), slot);
}


public void ExecuteHotbarAction(HotbarSlotType commandType, uint commandId, bool safemode = true) {
if (this._execHotbarSlot == null) {
throw new InvalidOperationException("Couldn't find RaptureHotbarModule::ExecuteSlot");
}
var hotbarModulePtr = Framework.Instance()->GetUiModule()->GetRaptureHotbarModule();

var slot = new HotBarSlot {
Expand All @@ -91,9 +75,9 @@ public void ExecuteHotbarAction(HotbarSlotType commandType, uint commandId, bool

var ptr = Marshal.AllocHGlobal(Marshal.SizeOf(slot));
Marshal.StructureToPtr(slot, ptr, false);
this._execHotbarSlot(hotbarModulePtr, (HotBarSlot*) ptr);

hotbarModulePtr->ExecuteSlot((HotBarSlot*) ptr);

Marshal.FreeHGlobal(ptr);
}

Expand Down
3 changes: 1 addition & 2 deletions FFXIVPlugin/Server/Controllers/HotbarController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public unsafe void TriggerHotbarSlot(int hotbarId, int slotId) {
PluginLog.Debug("timing: pre-TickScheduler");
TickScheduler.Schedule(delegate {
PluginLog.Debug("timing: TickScheduler start");
var hotbarItem = hotbarModule->HotBar[hotbarId]->Slot[slotId];
plugin.SigHelper.ExecuteHotbarSlot(hotbarItem);
Framework.Instance()->UIModule->GetRaptureHotbarModule()->ExecuteSlotById((uint) hotbarId, (uint) slotId);
PluginLog.Debug("timing: TickScheduler end");
});
PluginLog.Debug("timing: TriggerHotbarSlot ended");
Expand Down
29 changes: 0 additions & 29 deletions FFXIVPlugin/UI/PatchedWindowSystem.cs

This file was deleted.

8 changes: 5 additions & 3 deletions FFXIVPlugin/XIVDeck.FFXIVPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Product>XIVDeck Game Plugin</Product>
<Authors>Kaz Wolfe</Authors>
<Company>Blacksite Technologies</Company>
<Version>0.1.3</Version>
<Version>0.1.4</Version>

<AssemblyName>XIVDeck.FFXIVPlugin</AssemblyName>

Expand Down Expand Up @@ -52,7 +52,7 @@
<PackageReference Include="EmbedIO" Version="3.4.3" />

<!-- Dalamud things -->
<PackageReference Include="DalamudPackager" Version="2.1.5" />
<PackageReference Include="DalamudPackager" Version="2.1.6" />
<PackageReference Include="ILRepack" Version="2.1.0-beta1" GeneratePathProperty="true" />
<PackageReference Include="XivCommon" Version="5.0.0" />
<Reference Include="FFXIVClientStructs">
Expand Down Expand Up @@ -110,7 +110,9 @@
</Target>

<Target Name="PackagePlugin" AfterTargets="CleanOutDir" Condition="'$(Configuration)' == 'Release'">
<DalamudPackager ProjectDir="$(ProjectDir)" OutputPath="$(OutputPath)" AssemblyName="$(AssemblyName)" MakeZip="true" />
<DalamudPackager ProjectDir="$(ProjectDir)" OutputPath="$(OutputPath)" AssemblyName="$(AssemblyName)"
MakeZip="true" VersionComponents="3"
/>
</Target>

</Project>
1 change: 1 addition & 0 deletions FFXIVPlugin/XIVDeck.FFXIVPlugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ description: |-
Please report all problems to KazWolfe#2896 in the Dalamud Support server or by opening an Issue on GitHub.
repo_url: https://github.com/KazWolfe/XIVDeck/
dalamud_api_level: 6
tags:
- stream deck
- ui
Expand Down
5 changes: 3 additions & 2 deletions FFXIVPlugin/XIVDeckPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
using FFXIVClientStructs;
using XivCommon;
Expand All @@ -21,7 +22,7 @@ public sealed class XIVDeckPlugin : IDalamudPlugin {
public DalamudPluginInterface PluginInterface { get; init; }
public PluginConfig Configuration { get; init; }
public IconManager IconManager { get; set; }
public PatchedWindowSystem WindowSystem;
public WindowSystem WindowSystem;
public XivCommonBase XivCommon { get; }
public SigHelper SigHelper { get; }

Expand Down Expand Up @@ -53,7 +54,7 @@ public XIVDeckPlugin(DalamudPluginInterface pluginInterface) {
this.IconManager = new IconManager(this.PluginInterface);
this._chatLinkWiring = new ChatLinkWiring(this.PluginInterface);
this._hotbarWatcher = new HotbarWatcher();
this.WindowSystem = new PatchedWindowSystem(this.Name);
this.WindowSystem = new WindowSystem(this.Name);

// Start the websocket server itself.
this.InitializeWebServer();
Expand Down
2 changes: 1 addition & 1 deletion SDPlugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kazwolfe/xivdeck-sdplugin",
"version": "0.1.3",
"version": "0.1.4",
"private": true,
"scripts": {
"build-release": "webpack --mode production",
Expand Down

0 comments on commit d62d350

Please sign in to comment.