diff --git a/RoleplayersToolbox/Plugin.cs b/RoleplayersToolbox/Plugin.cs
index 94dfe4e..8a6da10 100755
--- a/RoleplayersToolbox/Plugin.cs
+++ b/RoleplayersToolbox/Plugin.cs
@@ -20,7 +20,11 @@ using RoleplayersToolbox.Tools.Illegal.EmoteSnap;
namespace RoleplayersToolbox {
internal class Plugin : IDalamudPlugin {
+ #if DEBUG
+ public string Name => "The Roleplayer's Toolbox (Debug)";
+ #else
public string Name => "The Roleplayer's Toolbox";
+ #endif
[PluginService]
internal DalamudPluginInterface Interface { get; init; } = null!;
diff --git a/RoleplayersToolbox/RoleplayersToolbox.csproj b/RoleplayersToolbox/RoleplayersToolbox.csproj
index 503aec3..8afea0a 100755
--- a/RoleplayersToolbox/RoleplayersToolbox.csproj
+++ b/RoleplayersToolbox/RoleplayersToolbox.csproj
@@ -53,8 +53,8 @@
-
+
-
+
diff --git a/RoleplayersToolbox/Tools/Housing/HousingTool.cs b/RoleplayersToolbox/Tools/Housing/HousingTool.cs
index 8dea79b..602bd19 100755
--- a/RoleplayersToolbox/Tools/Housing/HousingTool.cs
+++ b/RoleplayersToolbox/Tools/Housing/HousingTool.cs
@@ -1,12 +1,12 @@
using System;
using System.Linq;
-using System.Numerics;
using System.Runtime.InteropServices;
using Dalamud.Game;
using Dalamud.Game.Command;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using FFXIVClientStructs.FFXIV.Client.UI;
+using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
@@ -16,13 +16,8 @@ namespace RoleplayersToolbox.Tools.Housing {
internal class HousingTool : BaseTool, IDisposable {
private static class Signatures {
internal const string AddonMapHide = "40 53 48 83 EC 30 0F B6 91 ?? ?? ?? ?? 48 8B D9 E8 ?? ?? ?? ??";
- internal const string HousingPointer = "48 8B 05 ?? ?? ?? ?? 48 83 78 ?? ?? 74 16 48 8D 8F ?? ?? ?? ?? 66 89 5C 24 ?? 48 8D 54 24 ?? E8 ?? ?? ?? ?? 48 8B 7C 24";
}
- // Updated: 5.55
- // 48 89 5C 24 ?? 57 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 80 3D ?? ?? ?? ?? ??
- private const int AgentMapId = 38;
-
// AgentMap.vf8 has this offset if the sig above doesn't work
private const int AgentMapFlagSetOffset = 0x5997;
@@ -50,21 +45,7 @@ namespace RoleplayersToolbox.Tools.Housing {
}
}
- // Updated: 5.55
- // 48 89 5C 24 ?? 48 89 6C 24 ?? 48 89 74 24 ?? 57 41 56 41 57 48 83 EC 20 49 8B 00
- private unsafe ushort? CurrentWard {
- get {
- var objPtr = Util.FollowPointerChain(this._housingPointer, new[] { 0, 8 });
- if (objPtr == IntPtr.Zero) {
- return null;
- }
-
- return (ushort) (*(ushort*) (objPtr + 0x96a2) + 1);
- }
- }
-
private readonly AddonMapHideDelegate? _addonMapHide;
- private readonly IntPtr _housingPointer;
internal HousingTool(Plugin plugin) {
this.Plugin = plugin;
@@ -77,8 +58,6 @@ namespace RoleplayersToolbox.Tools.Housing {
this._addonMapHide = Marshal.GetDelegateForFunctionPointer(addonMapHidePtr);
}
- this.Plugin.SigScanner.TryGetStaticAddressFromSig(Signatures.HousingPointer, out this._housingPointer);
-
this.Plugin.Common.Functions.ContextMenu.OpenContextMenu += this.OnContextMenu;
this.Plugin.Framework.Update += this.OnFramework;
this.Plugin.CommandManager.AddHandler("/route", new CommandInfo(this.OnRouteCommand) {
@@ -137,7 +116,7 @@ namespace RoleplayersToolbox.Tools.Housing {
var world = this.Destination.World;
if (ImGui.BeginCombo("World", world?.Name?.ToString() ?? string.Empty)) {
- var dataCentre = this.Plugin.ClientState.LocalPlayer?.HomeWorld?.GameData?.DataCenter?.Row;
+ var dataCentre = this.Plugin.ClientState.LocalPlayer?.HomeWorld.GameData.DataCenter?.Row;
foreach (var availWorld in this.Plugin.DataManager.GetExcelSheet()!) {
if (availWorld.DataCenter.Row != dataCentre || !availWorld.IsPublic) {
@@ -189,7 +168,7 @@ namespace RoleplayersToolbox.Tools.Housing {
ImGui.SameLine();
var destArea = this.Destination.Area.Value;
- if (!destArea.CanWorldTravel() && this.Destination?.World != null && this.Destination?.World != this.Plugin.ClientState.LocalPlayer?.CurrentWorld?.GameData) {
+ if (!destArea.CanWorldTravel() && this.Destination?.World != null && this.Destination?.World != this.Plugin.ClientState.LocalPlayer?.CurrentWorld.GameData) {
destArea = HousingArea.Mist;
}
@@ -289,16 +268,15 @@ namespace RoleplayersToolbox.Tools.Housing {
return;
}
+ var loc = this.Plugin.Common.Functions.Housing.Location;
+
// ensure in correct ward
- if (this.CurrentWard != destination.Ward) {
+ if (loc?.Ward != destination.Ward) {
return;
}
- var localPos = player.Position;
- var localPosCorrected = new Vector3(localPos.X, localPos.Z, localPos.Y);
- var distance = Util.DistanceBetween(localPosCorrected, new Vector3(info.X, info.Y, info.Z));
-
- if (distance >= 15) {
+ // ensure either in the yard of the destination plot or actually inside the destination
+ if (loc?.Yard != destination.Plot && loc?.Plot != destination.Plot) {
return;
}
@@ -319,7 +297,7 @@ namespace RoleplayersToolbox.Tools.Housing {
}
private unsafe void ClearFlag() {
- var mapAgent = this.Plugin.Common.Functions.GetAgentByInternalId(AgentMapId);
+ var mapAgent = (IntPtr) this.Plugin.Common.Functions.GetFramework()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.Map);
if (mapAgent != IntPtr.Zero) {
*(byte*) (mapAgent + AgentMapFlagSetOffset) = 0;
}
@@ -433,14 +411,15 @@ namespace RoleplayersToolbox.Tools.Housing {
private bool ShouldHighlight(SeString str) {
var text = str.TextValue;
- var sameWorld = this.Destination?.World == this.Plugin.ClientState.LocalPlayer?.CurrentWorld?.GameData;
+ var sameWorld = this.Destination?.World == this.Plugin.ClientState.LocalPlayer?.CurrentWorld.GameData;
if (!sameWorld && this.Destination?.World != null) {
return text == " Visit Another World Server.";
}
// TODO: figure out how to use HousingAethernet.Order with current one missing
var placeName = this.Destination?.ClosestAethernet?.PlaceName?.Value?.Name?.ToString();
- if (this.CurrentWard == this.Destination?.Ward && placeName != null && text.StartsWith(placeName) && text.Length == placeName.Length + 1) {
+ var currentWard = this.Plugin.Common.Functions.Housing.Location?.Ward;
+ if (currentWard == this.Destination?.Ward && placeName != null && text.StartsWith(placeName) && text.Length == placeName.Length + 1) {
return true;
}
diff --git a/RoleplayersToolbox/Util.cs b/RoleplayersToolbox/Util.cs
index e9d992b..9990c2a 100755
--- a/RoleplayersToolbox/Util.cs
+++ b/RoleplayersToolbox/Util.cs
@@ -1,43 +1,12 @@
using System;
using System.Collections.Generic;
-using System.Numerics;
-using System.Runtime.InteropServices;
using System.Text;
-using Dalamud.Game;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Interface;
using ImGuiNET;
namespace RoleplayersToolbox {
internal static class Util {
- public static double DistanceBetween(Vector3 a, Vector3 b) {
- var xDiff = a.X - b.X;
- var yDiff = a.Y - b.Y;
- var zDiff = a.Z - b.Z;
- var sumOfSquares = Math.Pow(xDiff, 2) + Math.Pow(yDiff, 2) + Math.Pow(zDiff, 2);
- return Math.Sqrt(sumOfSquares);
- }
-
- public static bool TryScanText(this SigScanner scanner, string sig, out IntPtr result) {
- result = IntPtr.Zero;
- try {
- result = scanner.ScanText(sig);
- return true;
- } catch (KeyNotFoundException) {
- return false;
- }
- }
-
- public static bool TryGetStaticAddressFromSig(this SigScanner scanner, string sig, out IntPtr result) {
- result = IntPtr.Zero;
- try {
- result = scanner.GetStaticAddressFromSig(sig);
- return true;
- } catch (KeyNotFoundException) {
- return false;
- }
- }
-
public static SeString ReadSeString(IntPtr ptr) {
var bytes = ReadTerminatedBytes(ptr);
return SeString.Parse(bytes);
@@ -50,7 +19,7 @@ namespace RoleplayersToolbox {
private static unsafe byte[] ReadTerminatedBytes(IntPtr ptr) {
if (ptr == IntPtr.Zero) {
- return new byte[0];
+ return Array.Empty();
}
var bytes = new List();
@@ -64,21 +33,6 @@ namespace RoleplayersToolbox {
return bytes.ToArray();
}
- internal static IntPtr FollowPointerChain(IntPtr start, IEnumerable offsets) {
- if (start == IntPtr.Zero) {
- return IntPtr.Zero;
- }
-
- foreach (var offset in offsets) {
- start = Marshal.ReadIntPtr(start + offset);
- if (start == IntPtr.Zero) {
- return IntPtr.Zero;
- }
- }
-
- return start;
- }
-
internal static bool IconButton(FontAwesomeIcon icon, string? id = null) {
var label = icon.ToIconString();
if (id != null) {