diff --git a/PaisleyPark.sln b/PaisleyPark.sln index e288abf..d878386 100644 --- a/PaisleyPark.sln +++ b/PaisleyPark.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28621.142 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32002.185 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PaisleyPark", "PaisleyPark\PaisleyPark.csproj", "{80C7757C-B3D3-4E52-9DD8-373DE51AB450}" ProjectSection(ProjectDependencies) = postProject diff --git a/PaisleyPark/AddressService/Offsets.cs b/PaisleyPark/AddressService/Offsets.cs index 1a49a16..34a9abd 100644 --- a/PaisleyPark/AddressService/Offsets.cs +++ b/PaisleyPark/AddressService/Offsets.cs @@ -24,7 +24,9 @@ public Offsets(MemoryService memoryService) { MemoryService = memoryService; WayMarkSlot = new WayMarkSlot(MemoryService); - MapID = MemoryService.Scanner.GetStaticAddressFromSig("48 8D 0D ?? ?? ?? ?? 45 8B CD 48 89 7C 24 ??") + 0x05C0 + 0x06; + //MapID = MemoryService.Scanner.GetStaticAddressFromSig("48 8D 0D ?? ?? ?? ?? 45 8B CD 48 89 7C 24 ??") + 0x05C0 + 0x06; + var mapIDOffset = MemoryService.Read(MemoryService.Scanner.ScanText("66 89 81 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 44 8B CF")+3); + MapID = MemoryService.Scanner.GetStaticAddressFromSig("48 8D 0D ?? ?? ?? ?? 0F B6 55 ??") + mapIDOffset; Waymarks = MemoryService.Scanner.GetStaticAddressFromSig("48 8B 94 24 ?? ?? ?? ?? 48 8D 0D ?? ?? ?? ?? 41 B0 01") + 432; } } diff --git a/PaisleyPark/App.xaml b/PaisleyPark/App.xaml index 48bcbc7..369c58b 100644 --- a/PaisleyPark/App.xaml +++ b/PaisleyPark/App.xaml @@ -6,6 +6,16 @@ + + + + diff --git a/PaisleyPark/Models/Preset.cs b/PaisleyPark/Models/Preset.cs index fd6b484..cbb11ed 100644 --- a/PaisleyPark/Models/Preset.cs +++ b/PaisleyPark/Models/Preset.cs @@ -40,61 +40,68 @@ public Preset Parse(byte[] rawData) { if (rawData.Length != 104) { throw new Exception("Unexpected data length in WaymarkPreset.Parse"); } - Preset preset = new Preset(); - - preset.A.X = BitConverter.ToInt32(rawData, 0) / 1000.0f; - preset.A.Y = BitConverter.ToInt32(rawData, 4) / 1000.0f; - preset.A.Z = BitConverter.ToInt32(rawData, 8) / 1000.0f; - preset.A.Active = (rawData[96] & 0b00000001) > 0; - preset.A.ID = (WaymarkID)0; - - preset.B.X = BitConverter.ToInt32(rawData, 12) / 1000.0f; - preset.B.Y = BitConverter.ToInt32(rawData, 16) / 1000.0f; - preset.B.Z = BitConverter.ToInt32(rawData, 20) / 1000.0f; - preset.B.Active = (rawData[96] & 0b00000010) > 0; - preset.B.ID = (WaymarkID)1; - - preset.C.X = BitConverter.ToInt32(rawData, 24) / 1000.0f; - preset.C.Y = BitConverter.ToInt32(rawData, 28) / 1000.0f; - preset.C.Z = BitConverter.ToInt32(rawData, 32) / 1000.0f; - preset.C.Active = (rawData[96] & 0b00000100) > 0; - preset.C.ID = (WaymarkID)2; - - preset.D.X = BitConverter.ToInt32(rawData, 36) / 1000.0f; - preset.D.Y = BitConverter.ToInt32(rawData, 40) / 1000.0f; - preset.D.Z = BitConverter.ToInt32(rawData, 44) / 1000.0f; - preset.D.Active = (rawData[96] & 0b00001000) > 0; - preset.D.ID = (WaymarkID)3; - - preset.One.X = BitConverter.ToInt32(rawData, 48) / 1000.0f; - preset.One.Y = BitConverter.ToInt32(rawData, 52) / 1000.0f; - preset.One.Z = BitConverter.ToInt32(rawData, 56) / 1000.0f; - preset.One.Active = (rawData[96] & 0b00010000) > 0; - preset.One.ID = (WaymarkID)4; - - preset.Two.X = BitConverter.ToInt32(rawData, 60) / 1000.0f; - preset.Two.Y = BitConverter.ToInt32(rawData, 64) / 1000.0f; - preset.Two.Z = BitConverter.ToInt32(rawData, 68) / 1000.0f; - preset.Two.Active = (rawData[96] & 0b00100000) > 0; - preset.Two.ID = (WaymarkID)5; - - preset.Three.X = BitConverter.ToInt32(rawData, 72) / 1000.0f; - preset.Three.Y = BitConverter.ToInt32(rawData, 76) / 1000.0f; - preset.Three.Z = BitConverter.ToInt32(rawData, 80) / 1000.0f; - preset.Three.Active = (rawData[96] & 0b01000000) > 0; - preset.Three.ID = (WaymarkID)6; - - preset.Four.X = BitConverter.ToInt32(rawData, 84) / 1000.0f; - preset.Four.Y = BitConverter.ToInt32(rawData, 88) / 1000.0f; - preset.Four.Z = BitConverter.ToInt32(rawData, 92) / 1000.0f; - preset.Four.Active = (rawData[96] & 0b10000000) > 0; - preset.Four.ID = (WaymarkID)7; - - preset.MapID = BitConverter.ToUInt16(rawData, 98); + //Preset preset = new Preset(); + var p = this; + this.A=new Waymark(); + this.A.X = BitConverter.ToInt32(rawData, 0) / 1000.0f; + this.A.Y = BitConverter.ToInt32(rawData, 4) / 1000.0f; + this.A.Z = BitConverter.ToInt32(rawData, 8) / 1000.0f; + this.A.Active = (rawData[96] & 0b00000001) > 0; + this.A.ID = (WaymarkID)0; + + this.B = new Waymark(); + this.B.X = BitConverter.ToInt32(rawData, 12) / 1000.0f; + this.B.Y = BitConverter.ToInt32(rawData, 16) / 1000.0f; + this.B.Z = BitConverter.ToInt32(rawData, 20) / 1000.0f; + this.B.Active = (rawData[96] & 0b00000010) > 0; + this.B.ID = (WaymarkID)1; + + this.C = new Waymark(); + this.C.X = BitConverter.ToInt32(rawData, 24) / 1000.0f; + this.C.Y = BitConverter.ToInt32(rawData, 28) / 1000.0f; + this.C.Z = BitConverter.ToInt32(rawData, 32) / 1000.0f; + this.C.Active = (rawData[96] & 0b00000100) > 0; + this.C.ID = (WaymarkID)2; + + this.D = new Waymark(); + this.D.X = BitConverter.ToInt32(rawData, 36) / 1000.0f; + this.D.Y = BitConverter.ToInt32(rawData, 40) / 1000.0f; + this.D.Z = BitConverter.ToInt32(rawData, 44) / 1000.0f; + this.D.Active = (rawData[96] & 0b00001000) > 0; + this.D.ID = (WaymarkID)3; + + this.One = new Waymark(); + this.One.X = BitConverter.ToInt32(rawData, 48) / 1000.0f; + this.One.Y = BitConverter.ToInt32(rawData, 52) / 1000.0f; + this.One.Z = BitConverter.ToInt32(rawData, 56) / 1000.0f; + this.One.Active = (rawData[96] & 0b00010000) > 0; + this.One.ID = (WaymarkID)4; + + this.Two = new Waymark(); + this.Two.X = BitConverter.ToInt32(rawData, 60) / 1000.0f; + this.Two.Y = BitConverter.ToInt32(rawData, 64) / 1000.0f; + this.Two.Z = BitConverter.ToInt32(rawData, 68) / 1000.0f; + this.Two.Active = (rawData[96] & 0b00100000) > 0; + this.Two.ID = (WaymarkID)5; + + this.Three = new Waymark(); + this.Three.X = BitConverter.ToInt32(rawData, 72) / 1000.0f; + this.Three.Y = BitConverter.ToInt32(rawData, 76) / 1000.0f; + this.Three.Z = BitConverter.ToInt32(rawData, 80) / 1000.0f; + this.Three.Active = (rawData[96] & 0b01000000) > 0; + this.Three.ID = (WaymarkID)6; + + this.Four = new Waymark(); + this.Four.X = BitConverter.ToInt32(rawData, 84) / 1000.0f; + this.Four.Y = BitConverter.ToInt32(rawData, 88) / 1000.0f; + this.Four.Z = BitConverter.ToInt32(rawData, 92) / 1000.0f; + this.Four.Active = (rawData[96] & 0b10000000) > 0; + this.Four.ID = (WaymarkID)7; + + this.MapID = BitConverter.ToUInt16(rawData, 98); //preset.Time = DateTimeOffset.FromUnixTimeSeconds(BitConverter.ToInt32(rawData, 100)); - - return preset; + return p; } public byte[] ConstructGamePreset() { diff --git a/PaisleyPark/PaisleyPark.csproj b/PaisleyPark/PaisleyPark.csproj index 5ee8a9a..0499f20 100644 --- a/PaisleyPark/PaisleyPark.csproj +++ b/PaisleyPark/PaisleyPark.csproj @@ -299,14 +299,19 @@ false + + + if $(ConfigurationName) == NGARelease ( +del $(SolutionDir)\PaisleyPark\Views\MainWindow.xaml copy "$(SolutionDir)\PaisleyPark\Views\MainWindow_Lite.xaml" "$(SolutionDir)\PaisleyPark\Views\MainWindow.xaml" echo "NGA Release" ) if $(ConfigurationName) == Release ( +del $(SolutionDir)\PaisleyPark\Views\MainWindow.xaml copy "$(SolutionDir)\PaisleyPark\Views\MainWindow_Full.xaml" "$(SolutionDir)\PaisleyPark\Views\MainWindow.xaml" echo "Full Release" ) diff --git a/PaisleyPark/Properties/AssemblyInfo.cs b/PaisleyPark/Properties/AssemblyInfo.cs index dbc29dd..b10c21b 100644 --- a/PaisleyPark/Properties/AssemblyInfo.cs +++ b/PaisleyPark/Properties/AssemblyInfo.cs @@ -47,5 +47,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.6.3.0")] -[assembly: AssemblyFileVersion("1.6.3.0")] +[assembly: AssemblyVersion("1.6.4.1")] +[assembly: AssemblyFileVersion("1.6.4.1")] diff --git a/PaisleyPark/ViewModels/MainWindowViewModel.cs b/PaisleyPark/ViewModels/MainWindowViewModel.cs index b307dc6..74938f4 100644 --- a/PaisleyPark/ViewModels/MainWindowViewModel.cs +++ b/PaisleyPark/ViewModels/MainWindowViewModel.cs @@ -660,20 +660,26 @@ public void WriteWaymark(Waymark waymark, int id = -1) { //Kernel32.CloseHandle(threadHandle); } - - private void LoadPresetToSlot() { // Ensure we have a preset selected. if (CurrentPreset == null) return; if (CurrentSlot == null) return; + + if (CurrentPreset.MapID > 1000) { + var ffxiv = MemoryService.Process.MainModule.BaseAddress; + var mapID = MemoryService.Read(Offsets.MapID); + MessageBox.Show($"The MapID in Preset is {CurrentPreset.MapID}\nIt seems like invalid and may causes game carsh.\n Use current map id:{mapID} instead.", "Paisley Park", MessageBoxButton.OK, MessageBoxImage.Information); + CurrentPreset.MapID = mapID; + } + if (CurrentPreset.MapID == 0) { var ffxiv = MemoryService.Process.MainModule.BaseAddress; var mapID = Offsets.MapID; CurrentPreset.MapID = MemoryService.Read(mapID); if (CurrentPreset.MapID == 0) { - MessageBox.Show("Current MapID is 0.\nWaymark Preset without MapID is invalid", "Paisley Park", MessageBoxButton.OK, MessageBoxImage.Information); + MessageBox.Show($"Current MapID is {CurrentPreset.MapID}.\nIt can not be writed to WayMark Slot.", "Paisley Park", MessageBoxButton.OK, MessageBoxImage.Information); return; } } @@ -848,6 +854,7 @@ private void OnManagePresets() { // Populate the presets with our current presets as a new instance. vm.Presets = new System.Collections.ObjectModel.ObservableCollection(UserSettings.Presets); + vm.Offsets = Offsets; // Check if we're saving changes. if (win.ShowDialog() == true) { diff --git a/PaisleyPark/ViewModels/NewPresetViewModel.cs b/PaisleyPark/ViewModels/NewPresetViewModel.cs index 14470bc..fc7ba13 100644 --- a/PaisleyPark/ViewModels/NewPresetViewModel.cs +++ b/PaisleyPark/ViewModels/NewPresetViewModel.cs @@ -10,6 +10,8 @@ public class NewPresetViewModel : BindableBase { public string Name { get; set; } public bool UseCurrentWaymarks { get; set; } = true; + public bool UseSlotWaymarks { get; set; } = false; + public string CurrentSlot { get; set; } public bool? DialogResult { get; private set; } public ICommand CreateCommand { get; private set; } diff --git a/PaisleyPark/ViewModels/PresetManagerViewModel.cs b/PaisleyPark/ViewModels/PresetManagerViewModel.cs index f86483f..e3bbb15 100644 --- a/PaisleyPark/ViewModels/PresetManagerViewModel.cs +++ b/PaisleyPark/ViewModels/PresetManagerViewModel.cs @@ -1,5 +1,7 @@ using Newtonsoft.Json; +using PaisleyPark.Address; using PaisleyPark.Common; +using PaisleyPark.MemoryCore; using PaisleyPark.Models; using PaisleyPark.Views; using Prism.Commands; @@ -23,6 +25,8 @@ public class PresetManagerViewModel : BindableBase public ICommand ImportCommand { get; private set; } public ICommand ExportCommand { get; private set; } + public Offsets Offsets; + public bool DialogResult { get; private set; } private Memory GameMemory; private readonly static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); @@ -97,6 +101,40 @@ private void OnAddPreset() { p.Four = GameMemory.Four; } + if (vm.UseSlotWaymarks) { + byte[] importdata = new byte[104]; + //importdata = CurrentPreset.ConstructGamePreset(); + IntPtr SlotOffset; + switch (vm.CurrentSlot) { + case "Slot1": { + SlotOffset = Offsets.Slot1; + break; + } + case "Slot2": { + SlotOffset = Offsets.Slot2; + break; + } + case "Slot3": { + SlotOffset = Offsets.Slot3; + break; + } + case "Slot4": { + SlotOffset = Offsets.Slot4; + break; + } + case "Slot5": { + SlotOffset = Offsets.Slot5; + break; + } + default: { + SlotOffset = Offsets.Slot1; + break; + } + } + MemoryService.Read(SlotOffset, importdata); + p.Parse(importdata); + } + // Add the preset. Presets.Add(p); } diff --git a/PaisleyPark/ViewModels/ProcessSelectorViewModel.cs b/PaisleyPark/ViewModels/ProcessSelectorViewModel.cs index a8e4818..225d94b 100644 --- a/PaisleyPark/ViewModels/ProcessSelectorViewModel.cs +++ b/PaisleyPark/ViewModels/ProcessSelectorViewModel.cs @@ -66,8 +66,8 @@ private void OnManage() // Pull view model from window. var vm = win.DataContext as PresetManagerViewModel; - // Populate the presets with our current presets as a new instance. - vm.Presets = new ObservableCollection(settings.Presets); + // Populate the presets with our current presets as a new instance. + vm.Presets = new ObservableCollection(settings.Presets); // Check if we're saving changes. if (win.ShowDialog() == true) diff --git a/PaisleyPark/Views/MainWindow.xaml b/PaisleyPark/Views/MainWindow.xaml index 6641b13..936b1a4 100644 --- a/PaisleyPark/Views/MainWindow.xaml +++ b/PaisleyPark/Views/MainWindow.xaml @@ -15,7 +15,7 @@ SizeToContent="Height" Top="{Binding UserSettings.Top, Mode=TwoWay}" Left="{Binding UserSettings.Left, Mode=TwoWay}" - Height="161.046" + Height="242.929" Width="389.608" ResizeMode="CanMinimize"> @@ -29,7 +29,7 @@ - + @@ -50,18 +50,18 @@ - +