Browse Source

[PR] API12 Update

- Updated for API12
SheepGoMeh 1 năm trước cách đây
mục cha
commit
cdef5d9e80

+ 26 - 0
HuntBuddy/BillEnum.cs

@@ -0,0 +1,26 @@
+namespace HuntBuddy;
+
+public enum BillEnum: uint {
+	ArrRank1,
+	HwRank1,
+	HwRank2,
+	HwRank3,
+	ArrElite,
+	HwElite,
+	SbRank1,
+	SbRank2,
+	SbRank3,
+	SbElite,
+	ShbRank1,
+	ShbRank2,
+	ShbRank3,
+	ShbElite,
+	EwRank1,
+	EwRank2,
+	EwRank3,
+	EwElite,
+	DtRank1,
+	DtRank2,
+	DtRank3,
+	DtElite,
+}

+ 3 - 53
HuntBuddy/HuntBuddy.csproj

@@ -1,59 +1,9 @@
-<Project Sdk="Microsoft.NET.Sdk">
-
+<Project Sdk="Dalamud.NET.Sdk/12.0.2">
     <PropertyGroup>
-        <TargetFramework>net8-windows</TargetFramework>
-        <Nullable>enable</Nullable>
-        <AssemblyVersion>1.2.0.3</AssemblyVersion>
+        <AssemblyVersion>1.2.1.0</AssemblyVersion>
         <FileVersion>$(AssemblyVersion)</FileVersion>
-        <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
         <RootNamespace>HuntBuddy</RootNamespace>
         <IsPackable>false</IsPackable>
-        <LangVersion>default</LangVersion>
+        <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
     </PropertyGroup>
-    <PropertyGroup>
-        <ProduceReferenceAssembly>false</ProduceReferenceAssembly>
-        <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
-    </PropertyGroup>
-    <PropertyGroup>
-        <DalamudLibPath>$(AppData)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
-    </PropertyGroup>
-    <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
-        <PlatformTarget>x64</PlatformTarget>
-    </PropertyGroup>
-    <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
-        <PlatformTarget>x64</PlatformTarget>
-    </PropertyGroup>
-    <ItemGroup>
-        <Reference Include="Dalamud">
-            <HintPath>$(DalamudLibPath)Dalamud.dll</HintPath>
-            <Private>False</Private>
-        </Reference>
-        <Reference Include="FFXIVClientStructs">
-            <HintPath>$(DalamudLibPath)FFXIVClientStructs.dll</HintPath>
-            <Private>False</Private>
-        </Reference>
-        <Reference Include="ImGui.NET">
-            <HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath>
-            <Private>False</Private>
-        </Reference>
-        <Reference Include="ImGuiScene">
-            <HintPath>$(DalamudLibPath)ImGuiScene.dll</HintPath>
-            <Private>False</Private>
-        </Reference>
-        <Reference Include="Lumina">
-            <HintPath>$(DalamudLibPath)Lumina.dll</HintPath>
-            <Private>False</Private>
-        </Reference>
-        <Reference Include="Lumina.Excel">
-            <HintPath>$(DalamudLibPath)Lumina.Excel.dll</HintPath>
-            <Private>False</Private>
-        </Reference>
-        <Reference Include="Newtonsoft.Json">
-            <HintPath>$(DalamudLibPath)Newtonsoft.Json.dll</HintPath>
-            <Private>False</Private>
-        </Reference>
-    </ItemGroup>
-    <ItemGroup>
-        <PackageReference Include="DalamudPackager" Version="11.0.0" />
-    </ItemGroup>
 </Project>

+ 0 - 3
HuntBuddy/Ipc/ConsumerBase.cs

@@ -1,8 +1,5 @@
 using System;
-using System.Collections.Generic;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace HuntBuddy.Ipc;
 public abstract class ConsumerBase {

+ 1 - 1
HuntBuddy/Location.cs

@@ -600,7 +600,7 @@ public static class Location {
 
 		(int X, int Y) pos = MapToWorldCoordinates(Database[mobHuntId].Coordinate, mapId);
 
-		map->IsFlagMarkerSet = 0;
+		map->IsFlagMarkerSet = false;
 		map->SetFlagMapMarker(territoryType, mapId, pos.X, pos.Y, 60004);
 
 		switch (openType) {

+ 3 - 1
HuntBuddy/MobHuntEntry.cs

@@ -17,7 +17,9 @@ public class MobHuntEntry {
 
 	public bool IsEliteMark { get; init; }
 
-	public uint CurrentKillsOffset { get; init; }
+	public byte BillNumber { get; set; }
+
+	public byte MobIndex { get; set; }
 
 	public uint NeededKills { get; set; }
 

+ 14 - 21
HuntBuddy/Plugin.cs

@@ -11,17 +11,18 @@ using Dalamud.Plugin;
 using Dalamud.Plugin.Services;
 using Dalamud.Utility;
 
+using FFXIVClientStructs.FFXIV.Client.Game.UI;
+
 using HuntBuddy.Attributes;
 using HuntBuddy.Ipc;
-using HuntBuddy.Structs;
 using HuntBuddy.Windows;
 
 using ImGuiNET;
 
 using Lumina.Excel;
 using Lumina.Excel.Sheets;
-using Lumina.Text;
-using Lumina.Text.ReadOnly;
+
+using Map = Lumina.Excel.Sheets.Map;
 
 namespace HuntBuddy;
 
@@ -30,13 +31,12 @@ public class Plugin: IDalamudPlugin {
 
 	private readonly PluginCommandManager<Plugin> commandManager;
 
-	private ObtainedBillEnum lastState;
+	private int lastState;
 
 	// Dictionary<string ExpansionName, Dictionary<KeyValuePair<uint MobTerritoryType, string MobTerritoryName>, List<MobHuntEntry MobsInZone>>>
 	public readonly Dictionary<string, Dictionary<KeyValuePair<uint, string>, List<MobHuntEntry>>> MobHuntEntries;
 	public readonly ConcurrentBag<MobHuntEntry> CurrentAreaMobHuntEntries;
 	public bool MobHuntEntriesReady = true;
-	public readonly unsafe MobHuntStruct* MobHuntStruct;
 	public readonly Configuration Configuration;
 	public static TeleportConsumer? TeleportConsumer { get; private set; }
 	public static EspConsumer? EspConsumer { get; private set; }
@@ -70,12 +70,6 @@ public class Plugin: IDalamudPlugin {
 		this.Configuration.IconBackgroundColourU32 =
 			ImGui.ColorConvertFloat4ToU32(this.Configuration.IconBackgroundColour);
 
-		unsafe {
-			this.MobHuntStruct =
-				(MobHuntStruct*)Service.SigScanner.GetStaticAddressFromSig(
-					"48 8D 0D ?? ?? ?? ?? 8B D8 0F B6 52");
-		}
-
 		this.MainWindow = new MainWindow();
 		this.ConfigurationWindow = new ConfigurationWindow();
 
@@ -94,11 +88,11 @@ public class Plugin: IDalamudPlugin {
 	}
 
 	private unsafe void FrameworkOnUpdate(IFramework framework) {
-		if (this.lastState == this.MobHuntStruct->ObtainedBillEnumFlags) {
+		if (this.lastState == MobHunt.Instance()->ObtainedFlags) {
 			return;
 		}
 
-		this.lastState = this.MobHuntStruct->ObtainedBillEnumFlags;
+		this.lastState = MobHunt.Instance()->ObtainedFlags;
 		this.PluginCommand(string.Empty, "reload");
 	}
 
@@ -152,9 +146,8 @@ public class Plugin: IDalamudPlugin {
 				case "next":
 					if (this.MobHuntEntries.Count > 0) {
 						bool filterPredicate(MobHuntEntry entry) => entry.IsEliteMark ||
-							this.MobHuntStruct->CurrentKills[
-								entry.CurrentKillsOffset] <
-							entry.NeededKills;
+						                                            MobHunt.Instance()->GetKillCount(entry.BillNumber,
+							                                            entry.MobIndex) < entry.NeededKills;
 						Location.OpenType openType = Location.OpenType.None;
 						Vector3 playerLocation = Service.ClientState.LocalPlayer!.Position;
 						Map map = Service.DataManager.GetExcelSheet<TerritoryType>()!.GetRow(Service.ClientState
@@ -211,8 +204,7 @@ public class Plugin: IDalamudPlugin {
 								}
 							}
 							else {
-								long remaining = chosen.NeededKills -
-												 this.MobHuntStruct->CurrentKills[chosen.CurrentKillsOffset];
+								long remaining = chosen.NeededKills - MobHunt.Instance()->GetKillCount(chosen.BillNumber, chosen.MobIndex);
 								Service.Chat.Print($"Hunting {remaining}x {chosen.Name} in {chosen.TerritoryName}");
 								Location.CreateMapMarker(
 									chosen.TerritoryType,
@@ -262,7 +254,7 @@ public class Plugin: IDalamudPlugin {
 		SubrowExcelSheet<MobHuntOrder> mobHuntOrderSheet = Service.DataManager.GetSubrowExcelSheet<MobHuntOrder>();
 
 		foreach (BillEnum billNumber in Enum.GetValues<BillEnum>()) {
-			if (!this.MobHuntStruct->ObtainedBillEnumFlags.HasFlag((ObtainedBillEnum)(1 << (int)billNumber))) {
+			if ((MobHunt.Instance()->ObtainedFlags & (1 << (int)billNumber)) == 0) {
 				continue;
 			}
 
@@ -270,7 +262,7 @@ public class Plugin: IDalamudPlugin {
 				Service.DataManager.Excel.GetSheet<MobHuntOrderType>()!.GetRow((uint)billNumber)!;
 
 			uint rowId = mobHuntOrderTypeRow.OrderStart.Value!.RowId +
-						 (uint)(this.MobHuntStruct->BillOffset[mobHuntOrderTypeRow.RowId] - 1);
+						 (uint)(MobHunt.Instance()->ObtainedMarkId[(int)mobHuntOrderTypeRow.RowId] - 1);
 
 			IEnumerable<MobHuntOrder> mobHuntOrderRows = mobHuntOrderSheet[rowId];
 
@@ -293,7 +285,8 @@ public class Plugin: IDalamudPlugin {
 							TerritoryType = mobHuntOrderRow.Target.Value.TerritoryType.Value.TerritoryType.RowId,
 							MobHuntId = mobHuntOrderRow.Target.Value.Name.RowId,
 							IsEliteMark = mobHuntOrderTypeRow.Type == 2,
-							CurrentKillsOffset = (5 * (uint)billNumber) + mobHuntOrderRow.SubrowId,
+							BillNumber = (byte)billNumber,
+							MobIndex = (byte)mobHuntOrderRow.SubrowId,
 							NeededKills = mobHuntOrderRow.NeededKills,
 							Icon = mobHuntOrderRow.Target.Value.Icon,
 						});

+ 1 - 8
HuntBuddy/Service.cs

@@ -1,5 +1,4 @@
-using Dalamud.Game;
-using Dalamud.IoC;
+using Dalamud.IoC;
 using Dalamud.Plugin;
 using Dalamud.Plugin.Services;
 
@@ -30,12 +29,6 @@ public class Service {
 		set;
 	} = null!;
 
-	[PluginService]
-	public static ISigScanner SigScanner {
-		get;
-		set;
-	} = null!;
-
 	[PluginService]
 	public static IGameGui GameGui {
 		get;

+ 0 - 64
HuntBuddy/Structs/MobHuntStruct.cs

@@ -1,64 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-
-namespace HuntBuddy.Structs;
-
-public enum BillEnum: uint {
-	ArrRank1,
-	HwRank1,
-	HwRank2,
-	HwRank3,
-	ArrElite,
-	HwElite,
-	SbRank1,
-	SbRank2,
-	SbRank3,
-	SbElite,
-	ShbRank1,
-	ShbRank2,
-	ShbRank3,
-	ShbElite,
-	EwRank1,
-	EwRank2,
-	EwRank3,
-	EwElite,
-	DtRank1,
-	DtRank2,
-	DtRank3,
-	DtElite,
-}
-
-[Flags]
-public enum ObtainedBillEnum: uint {
-	ArrRank1 = 1,
-	HwRank1 = 1 << 1,
-	HwRank2 = 1 << 2,
-	HwRank3 = 1 << 3,
-	ArrElite = 1 << 4,
-	HwElite = 1 << 5,
-	SbRank1 = 1 << 6,
-	SbRank2 = 1 << 7,
-	SbRank3 = 1 << 8,
-	SbElite = 1 << 9,
-	ShbRank1 = 1 << 10,
-	ShbRank2 = 1 << 11,
-	ShbRank3 = 1 << 12,
-	ShbElite = 1 << 13,
-	EwRank1 = 1 << 14,
-	EwRank2 = 1 << 15,
-	EwRank3 = 1 << 16,
-	EwElite = 1 << 17,
-	DtRank1 = 1 << 18,
-	DtRank2 = 1 << 19,
-	DtRank3 = 1 << 20,
-	DtElite = 1 << 21,
-}
-
-// Signature to get struct address
-// D1 48 8D 0D ? ? ? ? 48 83 C4 20 5F E9 ? ? ? ?
-[StructLayout(LayoutKind.Explicit, Size = 0x198)]
-public unsafe struct MobHuntStruct {
-	[FieldOffset(0x1E)] public fixed byte BillOffset[22];
-	[FieldOffset(0x34)] public fixed int CurrentKills[5 * 22];
-	[FieldOffset(0x1EC)] public readonly ObtainedBillEnum ObtainedBillEnumFlags;
-}

+ 0 - 5
HuntBuddy/Utils/InterfaceUtil.cs

@@ -2,14 +2,9 @@
 
 using Dalamud.Interface;
 using Dalamud.Interface.Textures.TextureWraps;
-using Dalamud.Plugin.Services;
 using Dalamud.Interface.Textures;
 using ImGuiNET;
 
-using Lumina.Data.Files;
-
-using Lumina.Extensions;
-
 namespace HuntBuddy.Utils;
 
 /// <summary>

+ 4 - 2
HuntBuddy/Windows/LocalHuntsWindow.cs

@@ -5,6 +5,8 @@ using Dalamud.Game.ClientState.Conditions;
 using Dalamud.Interface;
 using Dalamud.Interface.Windowing;
 
+using FFXIVClientStructs.FFXIV.Client.Game.UI;
+
 using HuntBuddy.Utils;
 
 using ImGuiNET;
@@ -51,11 +53,11 @@ public class LocalHuntsWindow: Window {
 		&& !Service.Condition.Any(ConditionFlag.WatchingCutscene, ConditionFlag.OccupiedInCutSceneEvent)
 		&& !Plugin.Instance.CurrentAreaMobHuntEntries.IsEmpty
 		&& Plugin.Instance.CurrentAreaMobHuntEntries
-			.Count(x => Plugin.Instance.MobHuntStruct->CurrentKills[x.CurrentKillsOffset] == x.NeededKills) != Plugin.Instance.CurrentAreaMobHuntEntries.Count;
+			.Count(x => MobHunt.Instance()->GetKillCount(x.BillNumber, x.MobIndex) == x.NeededKills) != Plugin.Instance.CurrentAreaMobHuntEntries.Count;
 
 	public override unsafe void Draw() {
 		foreach (MobHuntEntry? mobHuntEntry in Plugin.Instance.CurrentAreaMobHuntEntries) {
-			int currentKills = Plugin.Instance.MobHuntStruct->CurrentKills[mobHuntEntry.CurrentKillsOffset];
+			int currentKills = MobHunt.Instance()->GetKillCount(mobHuntEntry.BillNumber, mobHuntEntry.MobIndex);
 
 			if (Plugin.Instance.Configuration.HideCompletedHunts && currentKills == mobHuntEntry.NeededKills) {
 				continue;

+ 4 - 2
HuntBuddy/Windows/MainWindow.cs

@@ -7,6 +7,8 @@ using Dalamud.Interface;
 using Dalamud.Interface.Utility;
 using Dalamud.Interface.Windowing;
 
+using FFXIVClientStructs.FFXIV.Client.Game.UI;
+
 using HuntBuddy.Utils;
 
 using ImGuiNET;
@@ -83,7 +85,7 @@ public class MainWindow: Window {
 				.Where(entry => {
 					bool treeOpen = ImGui.TreeNodeEx(entry.Key.Value, ImGuiTreeNodeFlags.AllowItemOverlap);
 					ImGui.SameLine();
-					int killedCount = entry.Value.Count(x => Plugin.Instance.MobHuntStruct->CurrentKills[x.CurrentKillsOffset] == x.NeededKills);
+					int killedCount = entry.Value.Count(x => MobHunt.Instance()->GetKillCount(x.BillNumber, x.MobIndex) == x.NeededKills);
 					if (killedCount != entry.Value.Count) {
 						ImGui.Text($"({killedCount}/{entry.Value.Count})");
 					}
@@ -183,7 +185,7 @@ public class MainWindow: Window {
 						}
 					}
 
-					int currentKills = Plugin.Instance.MobHuntStruct->CurrentKills[mobHuntEntry.CurrentKillsOffset];
+					int currentKills = MobHunt.Instance()->GetKillCount(mobHuntEntry.BillNumber, mobHuntEntry.MobIndex);
 					ImGui.Text(mobHuntEntry.Name);
 					if (ImGui.IsItemHovered()) {
 						ImGui.PushStyleColor(ImGuiCol.PopupBg, Vector4.Zero);

+ 10 - 4
HuntBuddy/packages.lock.json

@@ -1,12 +1,18 @@
 {
   "version": 1,
   "dependencies": {
-    "net8.0-windows7.0": {
+    "net9.0-windows7.0": {
       "DalamudPackager": {
         "type": "Direct",
-        "requested": "[11.0.0, )",
-        "resolved": "11.0.0",
-        "contentHash": "bjT7XUlhIJSmsE/O76b7weUX+evvGQctbQB8aKXt94o+oPWxHpCepxAGMs7Thow3AzCyqWs7cOpp9/2wcgRRQA=="
+        "requested": "[12.0.0, )",
+        "resolved": "12.0.0",
+        "contentHash": "J5TJLV3f16T/E2H2P17ClWjtfEBPpq3yxvqW46eN36JCm6wR+EaoaYkqG9Rm5sHqs3/nK/vKjWWyvEs/jhKoXw=="
+      },
+      "DotNet.ReproducibleBuilds": {
+        "type": "Direct",
+        "requested": "[1.2.25, )",
+        "resolved": "1.2.25",
+        "contentHash": "xCXiw7BCxHJ8pF6wPepRUddlh2dlQlbr81gXA72hdk4FLHkKXas7EH/n+fk5UCA/YfMqG1Z6XaPiUjDbUNBUzg=="
       }
     }
   }