fix: update housing router
This commit is contained in:
parent
7330592f06
commit
2609a0d0e8
|
@ -20,7 +20,11 @@ using RoleplayersToolbox.Tools.Illegal.EmoteSnap;
|
||||||
|
|
||||||
namespace RoleplayersToolbox {
|
namespace RoleplayersToolbox {
|
||||||
internal class Plugin : IDalamudPlugin {
|
internal class Plugin : IDalamudPlugin {
|
||||||
|
#if DEBUG
|
||||||
|
public string Name => "The Roleplayer's Toolbox (Debug)";
|
||||||
|
#else
|
||||||
public string Name => "The Roleplayer's Toolbox";
|
public string Name => "The Roleplayer's Toolbox";
|
||||||
|
#endif
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
internal DalamudPluginInterface Interface { get; init; } = null!;
|
internal DalamudPluginInterface Interface { get; init; } = null!;
|
||||||
|
|
|
@ -53,8 +53,8 @@
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="DalamudPackager" Version="2.1.2"/>
|
<PackageReference Include="DalamudPackager" Version="2.1.4"/>
|
||||||
<PackageReference Include="F23.StringSimilarity" Version="4.1.0"/>
|
<PackageReference Include="F23.StringSimilarity" Version="4.1.0"/>
|
||||||
<PackageReference Include="XivCommon" Version="3.0.1"/>
|
<PackageReference Include="XivCommon" Version="3.2.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Dalamud.Game;
|
using Dalamud.Game;
|
||||||
using Dalamud.Game.Command;
|
using Dalamud.Game.Command;
|
||||||
using Dalamud.Game.Text.SeStringHandling;
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Lumina.Excel.GeneratedSheets;
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
@ -16,13 +16,8 @@ namespace RoleplayersToolbox.Tools.Housing {
|
||||||
internal class HousingTool : BaseTool, IDisposable {
|
internal class HousingTool : BaseTool, IDisposable {
|
||||||
private static class Signatures {
|
private static class Signatures {
|
||||||
internal const string AddonMapHide = "40 53 48 83 EC 30 0F B6 91 ?? ?? ?? ?? 48 8B D9 E8 ?? ?? ?? ??";
|
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
|
// AgentMap.vf8 has this offset if the sig above doesn't work
|
||||||
private const int AgentMapFlagSetOffset = 0x5997;
|
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 AddonMapHideDelegate? _addonMapHide;
|
||||||
private readonly IntPtr _housingPointer;
|
|
||||||
|
|
||||||
internal HousingTool(Plugin plugin) {
|
internal HousingTool(Plugin plugin) {
|
||||||
this.Plugin = plugin;
|
this.Plugin = plugin;
|
||||||
|
@ -77,8 +58,6 @@ namespace RoleplayersToolbox.Tools.Housing {
|
||||||
this._addonMapHide = Marshal.GetDelegateForFunctionPointer<AddonMapHideDelegate>(addonMapHidePtr);
|
this._addonMapHide = Marshal.GetDelegateForFunctionPointer<AddonMapHideDelegate>(addonMapHidePtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Plugin.SigScanner.TryGetStaticAddressFromSig(Signatures.HousingPointer, out this._housingPointer);
|
|
||||||
|
|
||||||
this.Plugin.Common.Functions.ContextMenu.OpenContextMenu += this.OnContextMenu;
|
this.Plugin.Common.Functions.ContextMenu.OpenContextMenu += this.OnContextMenu;
|
||||||
this.Plugin.Framework.Update += this.OnFramework;
|
this.Plugin.Framework.Update += this.OnFramework;
|
||||||
this.Plugin.CommandManager.AddHandler("/route", new CommandInfo(this.OnRouteCommand) {
|
this.Plugin.CommandManager.AddHandler("/route", new CommandInfo(this.OnRouteCommand) {
|
||||||
|
@ -137,7 +116,7 @@ namespace RoleplayersToolbox.Tools.Housing {
|
||||||
|
|
||||||
var world = this.Destination.World;
|
var world = this.Destination.World;
|
||||||
if (ImGui.BeginCombo("World", world?.Name?.ToString() ?? string.Empty)) {
|
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<World>()!) {
|
foreach (var availWorld in this.Plugin.DataManager.GetExcelSheet<World>()!) {
|
||||||
if (availWorld.DataCenter.Row != dataCentre || !availWorld.IsPublic) {
|
if (availWorld.DataCenter.Row != dataCentre || !availWorld.IsPublic) {
|
||||||
|
@ -189,7 +168,7 @@ namespace RoleplayersToolbox.Tools.Housing {
|
||||||
ImGui.SameLine();
|
ImGui.SameLine();
|
||||||
|
|
||||||
var destArea = this.Destination.Area.Value;
|
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;
|
destArea = HousingArea.Mist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,16 +268,15 @@ namespace RoleplayersToolbox.Tools.Housing {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var loc = this.Plugin.Common.Functions.Housing.Location;
|
||||||
|
|
||||||
// ensure in correct ward
|
// ensure in correct ward
|
||||||
if (this.CurrentWard != destination.Ward) {
|
if (loc?.Ward != destination.Ward) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var localPos = player.Position;
|
// ensure either in the yard of the destination plot or actually inside the destination
|
||||||
var localPosCorrected = new Vector3(localPos.X, localPos.Z, localPos.Y);
|
if (loc?.Yard != destination.Plot && loc?.Plot != destination.Plot) {
|
||||||
var distance = Util.DistanceBetween(localPosCorrected, new Vector3(info.X, info.Y, info.Z));
|
|
||||||
|
|
||||||
if (distance >= 15) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +297,7 @@ namespace RoleplayersToolbox.Tools.Housing {
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe void ClearFlag() {
|
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) {
|
if (mapAgent != IntPtr.Zero) {
|
||||||
*(byte*) (mapAgent + AgentMapFlagSetOffset) = 0;
|
*(byte*) (mapAgent + AgentMapFlagSetOffset) = 0;
|
||||||
}
|
}
|
||||||
|
@ -433,14 +411,15 @@ namespace RoleplayersToolbox.Tools.Housing {
|
||||||
private bool ShouldHighlight(SeString str) {
|
private bool ShouldHighlight(SeString str) {
|
||||||
var text = str.TextValue;
|
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) {
|
if (!sameWorld && this.Destination?.World != null) {
|
||||||
return text == " Visit Another World Server.";
|
return text == " Visit Another World Server.";
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: figure out how to use HousingAethernet.Order with current one missing
|
// TODO: figure out how to use HousingAethernet.Order with current one missing
|
||||||
var placeName = this.Destination?.ClosestAethernet?.PlaceName?.Value?.Name?.ToString();
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,43 +1,12 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Numerics;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Dalamud.Game;
|
|
||||||
using Dalamud.Game.Text.SeStringHandling;
|
using Dalamud.Game.Text.SeStringHandling;
|
||||||
using Dalamud.Interface;
|
using Dalamud.Interface;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
|
|
||||||
namespace RoleplayersToolbox {
|
namespace RoleplayersToolbox {
|
||||||
internal static class Util {
|
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) {
|
public static SeString ReadSeString(IntPtr ptr) {
|
||||||
var bytes = ReadTerminatedBytes(ptr);
|
var bytes = ReadTerminatedBytes(ptr);
|
||||||
return SeString.Parse(bytes);
|
return SeString.Parse(bytes);
|
||||||
|
@ -50,7 +19,7 @@ namespace RoleplayersToolbox {
|
||||||
|
|
||||||
private static unsafe byte[] ReadTerminatedBytes(IntPtr ptr) {
|
private static unsafe byte[] ReadTerminatedBytes(IntPtr ptr) {
|
||||||
if (ptr == IntPtr.Zero) {
|
if (ptr == IntPtr.Zero) {
|
||||||
return new byte[0];
|
return Array.Empty<byte>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var bytes = new List<byte>();
|
var bytes = new List<byte>();
|
||||||
|
@ -64,21 +33,6 @@ namespace RoleplayersToolbox {
|
||||||
return bytes.ToArray();
|
return bytes.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static IntPtr FollowPointerChain(IntPtr start, IEnumerable<int> 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) {
|
internal static bool IconButton(FontAwesomeIcon icon, string? id = null) {
|
||||||
var label = icon.ToIconString();
|
var label = icon.ToIconString();
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
|
|
Loading…
Reference in New Issue