Skip to content

Commit

Permalink
[fix] cn6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Loskh committed Apr 4, 2022
1 parent fee433d commit 9457838
Show file tree
Hide file tree
Showing 14 changed files with 183 additions and 96 deletions.
4 changes: 2 additions & 2 deletions PaisleyPark.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion PaisleyPark/AddressService/Offsets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<UInt16>(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;
}
}
Expand Down
10 changes: 10 additions & 0 deletions PaisleyPark/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
<prism:PrismApplication.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/materialdesigncolor.Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.ComboBox.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Dark.xaml" />-->

<!-- Include the Dragablz Material Design style -->
<!-- <ResourceDictionary Source="pack://application:,,,/Dragablz;component/Themes/materialdesign.xaml"/> -->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</prism:PrismApplication.Resources>
Expand Down
113 changes: 60 additions & 53 deletions PaisleyPark/Models/Preset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
5 changes: 5 additions & 0 deletions PaisleyPark/PaisleyPark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,19 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)Bundle.targets" />
<PropertyGroup>
<PreBuildEvent>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"
)
Expand Down
4 changes: 2 additions & 2 deletions PaisleyPark/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
13 changes: 10 additions & 3 deletions PaisleyPark/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<UInt16>(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<UInt16>(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;
}
}
Expand Down Expand Up @@ -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<Preset>(UserSettings.Presets);
vm.Offsets = Offsets;

// Check if we're saving changes.
if (win.ShowDialog() == true) {
Expand Down
2 changes: 2 additions & 0 deletions PaisleyPark/ViewModels/NewPresetViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
38 changes: 38 additions & 0 deletions PaisleyPark/ViewModels/PresetManagerViewModel.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions PaisleyPark/ViewModels/ProcessSelectorViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Preset>(settings.Presets);
// Populate the presets with our current presets as a new instance.
vm.Presets = new ObservableCollection<Preset>(settings.Presets);

// Check if we're saving changes.
if (win.ShowDialog() == true)
Expand Down
28 changes: 14 additions & 14 deletions PaisleyPark/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

Expand All @@ -29,7 +29,7 @@
</i:EventTrigger>
</i:Interaction.Triggers>

<StackPanel Margin="10,10,10,9">
<StackPanel Margin="10,10,10,0" Height="203" VerticalAlignment="Top">

<Grid>
<Grid.ColumnDefinitions>
Expand All @@ -50,18 +50,18 @@
</Grid>


<!--<Button Content="Load" Margin="0,5" Command="{Binding LoadPresetCommand}"/>-->
<Button Content="Load" Margin="0,5" Command="{Binding LoadPresetCommand}"/>
<Button Content="Load To Slot" Margin="0,5" Command="{Binding LoadPresetToSlotCommand}"/>
<GroupBox Header="Settings" Height="58">
<StackPanel Orientation="Horizontal" Height="25" VerticalAlignment="Top" Margin="0,4,0,0">
<GroupBox Header="Settings" Height="97">
<StackPanel Orientation="Horizontal" Height="84" VerticalAlignment="Top">
<StackPanel Orientation="Vertical">
<Label Content="Slot" VerticalAlignment="Center" Margin="0,0,5,0" Height="26"/>
<!--<Label Content="Delay" VerticalAlignment="Center" Margin="0,0,5,0" Height="26"/>-->
<!--<Label Content="Port" VerticalAlignment="Center" Margin="0,0,5,0"/>-->
<Label Content="Delay" VerticalAlignment="Center" Margin="0,0,5,0" Height="26"/>
<Label Content="Port" VerticalAlignment="Center" Margin="0,0,5,0"/>
</StackPanel>
<StackPanel Orientation="Vertical" Height="25" VerticalAlignment="Top">
<StackPanel Orientation="Vertical" Height="74" VerticalAlignment="Top">
<StackPanel Height="26" Orientation="Horizontal">
<ComboBox VerticalAlignment="Top" HorizontalAlignment="Left"
<ComboBox VerticalAlignment="Top" HorizontalAlignment="Left"
SelectedItem="{Binding CurrentSlot, Mode=OneWayToSource}" Width="59" RenderTransformOrigin="-0.663,0.502" SelectedIndex="0">
<System:String>Slot1</System:String>
<System:String>Slot2</System:String>
Expand All @@ -71,7 +71,7 @@
</ComboBox>
</StackPanel>

<!--<StackPanel Height="26" Orientation="Horizontal">
<StackPanel Height="26" Orientation="Horizontal">
<p:NumericTextBox TextWrapping="Wrap" VerticalAlignment="Center" ToolTip="Delay in milliseconds for each waymark to be placed."
Text="{Binding UserSettings.PlacementDelay, UpdateSourceTrigger=PropertyChanged}" Width="60"/>
</StackPanel>
Expand All @@ -82,23 +82,23 @@
<Button Content="Start" Margin="10,2,0,4" Padding="10,2" Command="{Binding StartServerCommand}"/>
<Button Content="Stop" Margin="10,2,0,4" Padding="10,2" Command="{Binding StopServerCommand}"/>
<CheckBox IsChecked="{Binding UserSettings.HTTPAutoStart}" Margin="10,2,0,4" VerticalAlignment="Center" ToolTip="Autostart server" />
</StackPanel>-->
</StackPanel>

</StackPanel>

</StackPanel>

</GroupBox>
<!--<Grid Height="35">
<Grid Height="35">
<CheckBox IsChecked="{Binding UserSettings.LocalOnly}" Content="Local Only" VerticalAlignment="Center" Margin="0,7" Height="21" />
<Label HorizontalAlignment="Right" Margin="0,4,0,0" Height="24" VerticalAlignment="Top">
<Hyperlink Command="{Binding DiscordCommand}">
<Run Text="Join the Discord"/>
</Hyperlink>
</Label>
</Grid>-->
</Grid>


</StackPanel>

</Window>
</Window>
Loading

0 comments on commit 9457838

Please sign in to comment.