mirror of
https://github.com/kwsch/NHSE.git
synced 2026-08-20 01:26:19 -05:00
Update to .NET 10 (#683)
This commit is contained in:
@@ -1,63 +1,63 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace NHSE.Core
|
||||
namespace NHSE.Core;
|
||||
|
||||
/// <summary>
|
||||
/// Logic for loading decrypted game files.
|
||||
/// </summary>
|
||||
/// <seealso cref="GameFileDumper"/>
|
||||
public static class GameFileLoader
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic for loading decrypted game files.
|
||||
/// Loads a copy of the <see cref="sav"/>'s files in their decrypted state from the requested <see cref="path"/>.
|
||||
/// </summary>
|
||||
/// <seealso cref="GameFileDumper"/>
|
||||
public static class GameFileLoader
|
||||
/// <param name="sav">Save Data to load</param>
|
||||
/// <param name="path">Path to load from</param>
|
||||
public static void Load(this HorizonSave sav, string path)
|
||||
{
|
||||
/// <summary>
|
||||
/// Loads a copy of the <see cref="sav"/>'s files in their decrypted state from the requested <see cref="path"/>.
|
||||
/// </summary>
|
||||
/// <param name="sav">Save Data to load</param>
|
||||
/// <param name="path">Path to load from</param>
|
||||
public static void Load(this HorizonSave sav, string path)
|
||||
sav.Main.Load(path);
|
||||
foreach (var p in sav.Players)
|
||||
{
|
||||
sav.Main.Load(path);
|
||||
foreach (var p in sav.Players)
|
||||
{
|
||||
var dir = Path.Combine(path, p.DirectoryName);
|
||||
p.Load(dir);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a copy of the <see cref="player"/>'s files in their decrypted state from the requested <see cref="path"/>.
|
||||
/// </summary>
|
||||
/// <param name="player">Save Data to load</param>
|
||||
/// <param name="path">Path to load from</param>
|
||||
public static void Load(this Player player, string path)
|
||||
{
|
||||
foreach (var pair in player)
|
||||
pair.Load(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the <see cref="pair"/>'s files in their decrypted state from the requested <see cref="path"/>.
|
||||
/// </summary>
|
||||
/// <param name="pair">Save Data to load</param>
|
||||
/// <param name="path">Path to load from</param>
|
||||
public static void Load(this EncryptedFilePair pair, string path)
|
||||
{
|
||||
Load(path, pair.Data, pair.NameData);
|
||||
}
|
||||
|
||||
private static void Load(string path, byte[] data, string name)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
return;
|
||||
|
||||
var file = Path.Combine(path, name);
|
||||
if (!File.Exists(file))
|
||||
return;
|
||||
|
||||
var import = File.ReadAllBytes(file);
|
||||
if (data.Length != import.Length)
|
||||
return;
|
||||
|
||||
import.CopyTo(data, 0);
|
||||
var dir = Path.Combine(path, p.DirectoryName);
|
||||
p.Load(dir);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a copy of the <see cref="player"/>'s files in their decrypted state from the requested <see cref="path"/>.
|
||||
/// </summary>
|
||||
/// <param name="player">Save Data to load</param>
|
||||
/// <param name="path">Path to load from</param>
|
||||
public static void Load(this Player player, string path)
|
||||
{
|
||||
foreach (var pair in player)
|
||||
pair.Load(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the <see cref="pair"/>'s files in their decrypted state from the requested <see cref="path"/>.
|
||||
/// </summary>
|
||||
/// <param name="pair">Save Data to load</param>
|
||||
/// <param name="path">Path to load from</param>
|
||||
public static void Load(this EncryptedFilePair pair, string path)
|
||||
{
|
||||
Load(path, pair.Data, pair.NameData);
|
||||
}
|
||||
|
||||
private static void Load(string path, Span<byte> data, string name)
|
||||
{
|
||||
if (!Directory.Exists(path))
|
||||
return;
|
||||
|
||||
var file = Path.Combine(path, name);
|
||||
if (!File.Exists(file))
|
||||
return;
|
||||
|
||||
var import = File.ReadAllBytes(file);
|
||||
if (data.Length != import.Length)
|
||||
return;
|
||||
|
||||
import.CopyTo(data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user