Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Commit

Permalink
Updates for 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonBlade committed Feb 18, 2020
1 parent c80c582 commit 85a4a4f
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 34 deletions.
10 changes: 7 additions & 3 deletions PaisleyPark/Common/WaymarkNancyModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ public class RESTWaymark
public Waymark D { get; set; }
public Waymark One { get; set; }
public Waymark Two { get; set; }
}
public Waymark Three { get; set; }
public Waymark Four { get; set; }
}

public class WaymarkNancyModule : NancyModule
{
Expand All @@ -37,8 +39,10 @@ public WaymarkNancyModule()
C = MainWindowViewModel.GameMemory.C,
D = MainWindowViewModel.GameMemory.D,
One = MainWindowViewModel.GameMemory.One,
Two = MainWindowViewModel.GameMemory.Two
};
Two = MainWindowViewModel.GameMemory.Two,
Three = MainWindowViewModel.GameMemory.Three,
Four = MainWindowViewModel.GameMemory.Four
};
// Serialize and return the response.
return JsonConvert.SerializeObject(response);
Expand Down
2 changes: 2 additions & 0 deletions PaisleyPark/Models/Memory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class Memory : INotifyPropertyChanged
public Waymark D { get; set; }
public Waymark One { get; set; }
public Waymark Two { get; set; }
public Waymark Three { get; set; }
public Waymark Four { get; set; }

/// <summary>
/// Property Changed event handler for this model.
Expand Down
2 changes: 2 additions & 0 deletions PaisleyPark/Models/Preset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class Preset : INotifyPropertyChanged
public Waymark D { get; set; }
public Waymark One { get; set; }
public Waymark Two { get; set; }
public Waymark Three { get; set; }
public Waymark Four { get; set; }

/// <summary>
/// Property Changed event handler for this model.
Expand Down
33 changes: 9 additions & 24 deletions PaisleyPark/Models/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace PaisleyPark.Models
/// <summary>
/// Settings model used for saving the settings to a file.
/// </summary>
public class Settings : INotifyPropertyChanged
{
public class Settings : INotifyPropertyChanged
{
/// <summary>
/// Folder path to where the settings are stored.
/// </summary>
Expand All @@ -29,14 +29,14 @@ public class Settings : INotifyPropertyChanged
public string LatestGameVersion { get; set; }

/// <summary>
/// Path to the game to use for various functions.
/// Local only waymark placements.
/// </summary>
// public string GamePath { get; set; }
public bool LocalOnly { get; set; } = false;

/// <summary>
/// Port for HTTP server.
/// </summary>
public int Port { get; set; }
/// <summary>
/// Port for HTTP server.
/// </summary>
public int Port { get; set; } = 1337;

/// <summary>
/// Autostarts the HTTP server on launch.
Expand Down Expand Up @@ -88,21 +88,6 @@ public static void Save(Settings settings)
// Get the full path to the settings file.
var fullPath = Path.Combine(SETTINGS_FOLDER, SETTINGS_FILE);

try
{
// Store three backups
if (File.Exists(fullPath + ".2.bak"))
File.Copy(fullPath + ".2.bak", fullPath + ".3.bak", true);
if (File.Exists(fullPath + ".1.bak"))
File.Copy(fullPath + ".1.bak", fullPath + ".2.bak", true);
File.Copy(fullPath, fullPath + ".1.bak", true);
}
catch (Exception ex)
{
logger.Error(ex, "Couldn't create backups.");
MessageBox.Show("Couldn't create save backups.", "Paisley Park", MessageBoxButton.OK, MessageBoxImage.Warning);
}

// Create StreamWriter instance to save file contents into full path.
using (var text = File.CreateText(fullPath))
{
Expand Down Expand Up @@ -135,7 +120,7 @@ public static Settings Load()
{
logger.Error("Current settings file is corrupt!");
File.Copy(fullPath, fullPath + ".bak");
MessageBox.Show("Your settings file is corrupt, a new settings file is being created. You may attempt to restore settings from backups. Please ask in Discord if you have questions.", "Paisley Park", MessageBoxButton.OK, MessageBoxImage.Warning);
MessageBox.Show("Your settings file is corrupt, a new settings file is being created.", "Paisley Park", MessageBoxButton.OK, MessageBoxImage.Warning);
settings = new Settings();
}

Expand Down
2 changes: 1 addition & 1 deletion PaisleyPark/Models/Waymark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ public override bool Equals(object obj)
/// <summary>
/// Waymark ID is the byte value of the waymark ID in memory.
/// </summary>
public enum WaymarkID : byte { A = 0, B, C, D, One, Two }
public enum WaymarkID : byte { A = 0, B, C, D, One, Two, Three, Four }
}
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.5.2.0")]
[assembly: AssemblyFileVersion("1.5.2.0")]
[assembly: AssemblyVersion("1.5.3.0")]
[assembly: AssemblyFileVersion("1.5.3.0")]
57 changes: 57 additions & 0 deletions PaisleyPark/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ public MainWindowViewModel(IEventAggregator ea)
WriteWaymark(waymarks.D, 3);
WriteWaymark(waymarks.One, 4);
WriteWaymark(waymarks.Two, 5);
WriteWaymark(waymarks.Three, 6);
WriteWaymark(waymarks.Four, 7);
});

logger.Debug("Subscribing to Load Preset event.");
Expand All @@ -148,6 +150,8 @@ public MainWindowViewModel(IEventAggregator ea)
WriteWaymark(preset.D, 3);
WriteWaymark(preset.One, 4);
WriteWaymark(preset.Two, 5);
WriteWaymark(preset.Three, 6);
WriteWaymark(preset.Four, 7);
});
}
catch (Exception ex)
Expand Down Expand Up @@ -190,6 +194,8 @@ public MainWindowViewModel(IEventAggregator ea)
preset.D = GameMemory.D;
preset.One = GameMemory.One;
preset.Two = GameMemory.Two;
preset.Three = GameMemory.Three;
preset.Four = GameMemory.Four;
preset.MapID = GameMemory.MapID;
Settings.Save(UserSettings);
Expand Down Expand Up @@ -609,6 +615,8 @@ private void OnWork(object sender, DoWorkEventArgs e)
var wayD = (ffxiv + Offsets.Waymarks + 0x60).ToUint64();
var wayOne = (ffxiv + Offsets.Waymarks + 0x80).ToUint64();
var wayTwo = (ffxiv + Offsets.Waymarks + 0xA0).ToUint64();
var wayThree = (ffxiv + Offsets.Waymarks + 0xC0).ToUint64();
var wayFour = (ffxiv + Offsets.Waymarks + 0xE0).ToUint64();

// Worker loop runs indefinitely.
while (true)
Expand Down Expand Up @@ -640,6 +648,8 @@ private void OnWork(object sender, DoWorkEventArgs e)
GameMemory.D = ReadWaymark(wayD, WaymarkID.D);
GameMemory.One = ReadWaymark(wayOne, WaymarkID.One);
GameMemory.Two = ReadWaymark(wayTwo, WaymarkID.Two);
GameMemory.Three = ReadWaymark(wayThree, WaymarkID.Three);
GameMemory.Four = ReadWaymark(wayFour, WaymarkID.Four);

// Read the map ID.
GameMemory.MapID = GameProcess.ReadUInt32(new Pointer(GameProcess, 0x1AE6A88, 0x5C4));
Expand Down Expand Up @@ -672,6 +682,51 @@ private void WriteWaymark(Waymark waymark, int id = -1)
if (waymark == null)
return;

// Initialize pointers and addresses to the memory we're going to read.
var ffxiv = GameProcess.BaseProcess.MainModule.BaseAddress;

// pointers for waymark positions
var wayA = (ffxiv + Offsets.Waymarks + 0x00).ToUint64();
var wayB = (ffxiv + Offsets.Waymarks + 0x20).ToUint64();
var wayC = (ffxiv + Offsets.Waymarks + 0x40).ToUint64();
var wayD = (ffxiv + Offsets.Waymarks + 0x60).ToUint64();
var wayOne = (ffxiv + Offsets.Waymarks + 0x80).ToUint64();
var wayTwo = (ffxiv + Offsets.Waymarks + 0xA0).ToUint64();
var wayThree = (ffxiv + Offsets.Waymarks + 0xC0).ToUint64();
var wayFour = (ffxiv + Offsets.Waymarks + 0xE0).ToUint64();

if (UserSettings.LocalOnly)
{
ulong markAddr = 0;
if (waymark.ID == WaymarkID.A)
markAddr = wayA;
else if (waymark.ID == WaymarkID.B)
markAddr = wayB;
else if (waymark.ID == WaymarkID.C)
markAddr = wayC;
else if (waymark.ID == WaymarkID.D)
markAddr = wayD;
else if (waymark.ID == WaymarkID.One)
markAddr = wayOne;
else if (waymark.ID == WaymarkID.Two)
markAddr = wayTwo;
else if (waymark.ID == WaymarkID.Three)
markAddr = wayThree;
else if (waymark.ID == WaymarkID.Four)
markAddr = wayFour;

// Write the X, Y and Z coordinates
GameProcess.Write(markAddr, waymark.X);
GameProcess.Write(markAddr + 0x4, waymark.Y);
GameProcess.Write(markAddr + 0x8, waymark.Z);

// Write the active state
GameProcess.Write(markAddr + 0x10, (byte)(waymark.Active ? 1 : 0));

// Return out of this function
return;
}

// Write the X, Y and Z coordinates.
GameProcess.Write(_newmem, waymark.X);
GameProcess.Write(_newmem + 0x4, waymark.Y);
Expand Down Expand Up @@ -755,6 +810,8 @@ private void LoadPreset()
WriteWaymark(CurrentPreset.D, 3);
WriteWaymark(CurrentPreset.One, 4);
WriteWaymark(CurrentPreset.Two, 5);
WriteWaymark(CurrentPreset.Three, 6);
WriteWaymark(CurrentPreset.Four, 7);
});

WaymarkThread.Start();
Expand Down
4 changes: 4 additions & 0 deletions PaisleyPark/ViewModels/PresetManagerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ private void OnAddPreset()
p.D = GameMemory.D;
p.One = GameMemory.One;
p.Two = GameMemory.Two;
p.Three = GameMemory.Three;
p.Four = GameMemory.Four;
p.MapID = GameMemory.MapID;
}

Expand Down Expand Up @@ -171,6 +173,8 @@ private void OnEdit()
SelectedItem.D = GameMemory.D;
SelectedItem.One = GameMemory.One;
SelectedItem.Two = GameMemory.Two;
SelectedItem.Three = GameMemory.Three;
SelectedItem.Four = GameMemory.Four;
SelectedItem.MapID = GameMemory.MapID;
}
}
Expand Down
12 changes: 8 additions & 4 deletions PaisleyPark/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,14 @@

</GroupBox>

<Label HorizontalAlignment="Right">
<Hyperlink Command="{Binding DiscordCommand}">Join the Discord</Hyperlink>
</Label>
<Grid>
<CheckBox IsChecked="{Binding UserSettings.LocalOnly}" Content="Local Only" VerticalAlignment="Center" />
<Label HorizontalAlignment="Right">
<Hyperlink Command="{Binding DiscordCommand}">Join the Discord</Hyperlink>
</Label>
</Grid>

</StackPanel>

</StackPanel>

</Window>

0 comments on commit 85a4a4f

Please sign in to comment.