mirror of
https://github.com/kwsch/NHSE.git
synced 2026-04-25 07:37:02 -05:00
Add some xmldoc
This commit is contained in:
parent
e0821eb9ba
commit
88b6776393
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// main.dat
|
||||
/// </summary>
|
||||
public sealed class MainSave : EncryptedFilePair
|
||||
{
|
||||
public readonly MainSaveOffsets Offsets;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// personal.dat
|
||||
/// </summary>
|
||||
public sealed class Personal : EncryptedFilePair
|
||||
{
|
||||
public readonly PersonalOffsets Offsets;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// photo_studio_island.dat
|
||||
/// </summary>
|
||||
public sealed class PhotoStudioIsland : EncryptedFilePair
|
||||
{
|
||||
public PhotoStudioIsland(string folder) : base(folder, "photo_studio_island") { }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// postbox.dat
|
||||
/// </summary>
|
||||
public sealed class PostBox : EncryptedFilePair
|
||||
{
|
||||
public PostBox(string folder) : base(folder, "postbox") { }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// profile.dat
|
||||
/// </summary>
|
||||
public sealed class Profile : EncryptedFilePair
|
||||
{
|
||||
public Profile(string folder) : base(folder, "profile") { }
|
||||
|
||||
// pretty much just a jpeg -- which is also stored in Personal.
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents two files -- <see cref="DataPath"/> and <see cref="HeaderPath"/> and their decrypted data.
|
||||
/// </summary>
|
||||
public abstract class EncryptedFilePair
|
||||
{
|
||||
public readonly byte[] Data;
|
||||
|
|
@ -44,6 +47,9 @@ public void Save(uint seed)
|
|||
File.WriteAllBytes(HeaderPath, encrypt.Header);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates all hashes of <see cref="Data"/>.
|
||||
/// </summary>
|
||||
public void Hash()
|
||||
{
|
||||
var ver = Info.GetKnownRevisionIndex();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Metadata stored in a file's Header, indicating the revision information.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class FileHeaderInfo : IEquatable<FileHeaderInfo>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents all saved data that is stored on the device for the New Horizon's game.
|
||||
/// </summary>
|
||||
public class HorizonSave
|
||||
{
|
||||
public readonly MainSave Main;
|
||||
|
|
@ -15,6 +18,10 @@ public HorizonSave(string folder)
|
|||
Players = Player.ReadMany(folder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the data using the provided crypto <see cref="seed"/>.
|
||||
/// </summary>
|
||||
/// <param name="seed">Seed to initialize the RNG with when encrypting the files.</param>
|
||||
public void Save(uint seed)
|
||||
{
|
||||
Main.Hash();
|
||||
|
|
@ -26,6 +33,13 @@ public void Save(uint seed)
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets every <see cref="FileHashRegion"/> that is deemed invalid.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Doesn't return any metadata about which file the hashes were bad for.
|
||||
/// Just check what's returned with what's implemented; the offsets are unique enough.
|
||||
/// </remarks>
|
||||
public IEnumerable<FileHashRegion> GetInvalidHashes()
|
||||
{
|
||||
return Main.InvalidHashes().Concat(Players.SelectMany(z => z.InvalidHashes()));
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@ private Player(string folder)
|
|||
Profile = new Profile(folder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the data using the provided crypto <see cref="seed"/>.
|
||||
/// </summary>
|
||||
/// <param name="seed">Seed to initialize the RNG with when encrypting the files.</param>
|
||||
public void Save(uint seed)
|
||||
{
|
||||
Personal.Save(seed);
|
||||
|
|
@ -44,6 +48,9 @@ public void Save(uint seed)
|
|||
Profile.Save(seed);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates all hashes of the Player's files.
|
||||
/// </summary>
|
||||
public void Hash()
|
||||
{
|
||||
Personal.Hash();
|
||||
|
|
@ -52,6 +59,13 @@ public void Hash()
|
|||
Profile.Hash();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets every <see cref="FileHashRegion"/> that is deemed invalid.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Doesn't return any metadata about which file the hashes were bad for.
|
||||
/// Just check what's returned with what's implemented; the offsets are unique enough.
|
||||
/// </remarks>
|
||||
public IEnumerable<FileHashRegion> InvalidHashes()
|
||||
{
|
||||
return Personal.InvalidHashes()
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic for detecting a <see cref="EncryptedFilePair"/> revision.
|
||||
/// </summary>
|
||||
public static class RevisionChecker
|
||||
{
|
||||
// Patches where the sizes of individual files changed
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores file sizes for various savedata files at different patch revisions.
|
||||
/// </summary>
|
||||
public class SaveFileSizes
|
||||
{
|
||||
public readonly uint Main;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Offset info and object retrieval logic for <see cref="MainSave"/>
|
||||
/// </summary>
|
||||
public abstract class MainSaveOffsets
|
||||
{
|
||||
public abstract int Villager { get; }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="MainSaveOffsets"/>
|
||||
/// </summary>
|
||||
public class MainSaveOffsets10 : MainSaveOffsets
|
||||
{
|
||||
public override int Villager => 0x110;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="MainSaveOffsets"/>
|
||||
/// </summary>
|
||||
public class MainSaveOffsets11 : MainSaveOffsets
|
||||
{
|
||||
public override int Villager => 0x120;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Offset info and object retrieval logic for <see cref="Personal"/>
|
||||
/// </summary>
|
||||
public abstract class PersonalOffsets
|
||||
{
|
||||
public abstract int PersonalId { get; }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="PersonalOffsets"/>
|
||||
/// </summary>
|
||||
public sealed class PersonalOffsets10 : PersonalOffsets
|
||||
{
|
||||
public override int PersonalId => 0xB0A0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="PersonalOffsets"/>
|
||||
/// </summary>
|
||||
public sealed class PersonalOffsets11 : PersonalOffsets
|
||||
{
|
||||
public override int PersonalId => 0xB0B8;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Global repository for game strings; initialized to a specified language.
|
||||
/// </summary>
|
||||
public static class GameInfo
|
||||
{
|
||||
private static readonly GameStrings[] Languages = new GameStrings[GameLanguage.LanguageCount];
|
||||
|
|
@ -11,6 +14,10 @@ public static class GameInfo
|
|||
public static readonly IReadOnlyList<string> GenderSymbolASCII = new[] { "M", "F", "-" };
|
||||
public static GameStrings Strings { get; set; } = GetStrings(CurrentLanguage);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Game Strings for a specific language.
|
||||
/// </summary>
|
||||
/// <param name="lang">2 character language ID</param>
|
||||
public static GameStrings GetStrings(string lang)
|
||||
{
|
||||
int index = GameLanguage.GetLanguageIndex(lang);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Metadata for dealing with language codes
|
||||
/// </summary>
|
||||
public static class GameLanguage
|
||||
{
|
||||
public const string DefaultLanguage = "en"; // English
|
||||
|
|
|
|||
|
|
@ -2,8 +2,16 @@
|
|||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic for dumping raw game files.
|
||||
/// </summary>
|
||||
public static class GameFileDumper
|
||||
{
|
||||
/// <summary>
|
||||
/// Dumps a copy of the <see cref="sav"/>'s files in their decrypted state to the requested <see cref="path"/>.
|
||||
/// </summary>
|
||||
/// <param name="sav">Save Data to dump</param>
|
||||
/// <param name="path">Path to dump to</param>
|
||||
public static void Dump(this HorizonSave sav, string path)
|
||||
{
|
||||
sav.Main.Dump(path);
|
||||
|
|
@ -14,20 +22,30 @@ public static void Dump(this HorizonSave sav, string path)
|
|||
}
|
||||
}
|
||||
|
||||
public static void Dump(this Player pair, string path)
|
||||
/// <summary>
|
||||
/// Dumps a copy of the <see cref="player"/>'s files in their decrypted state to the requested <see cref="path"/>.
|
||||
/// </summary>
|
||||
/// <param name="player">Save Data to dump</param>
|
||||
/// <param name="path">Path to dump to</param>
|
||||
public static void Dump(this Player player, string path)
|
||||
{
|
||||
pair.Profile.Dump(path);
|
||||
pair.Personal.Dump(path);
|
||||
pair.Photo.Dump(path);
|
||||
pair.PostBox.Dump(path);
|
||||
player.Profile.Dump(path);
|
||||
player.Personal.Dump(path);
|
||||
player.Photo.Dump(path);
|
||||
player.PostBox.Dump(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dumps a copy of the <see cref="pair"/>'s files in their decrypted state to the requested <see cref="path"/>.
|
||||
/// </summary>
|
||||
/// <param name="pair">Save Data to dump</param>
|
||||
/// <param name="path">Path to dump to</param>
|
||||
public static void Dump(this EncryptedFilePair pair, string path)
|
||||
{
|
||||
Dump(path, pair.Data, pair.NameData);
|
||||
}
|
||||
|
||||
public static void Dump(string path, byte[] data, string name)
|
||||
private static void Dump(string path, byte[] data, string name)
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
var file = Path.Combine(path, name);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@
|
|||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
public static partial class RandUtil
|
||||
/// <summary>
|
||||
/// Logic for providing random values
|
||||
/// </summary>
|
||||
public static class RandUtil
|
||||
{
|
||||
// Multithread safe rand, ha
|
||||
public static Random Rand => _local.Value;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic for retrieving resources from the dll
|
||||
/// </summary>
|
||||
public static class ResourceUtil
|
||||
{
|
||||
private static readonly Assembly thisAssembly = typeof(ResourceUtil).GetTypeInfo().Assembly;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
public static partial class StringUtil
|
||||
/// <summary>
|
||||
/// Logic for manipulating strings
|
||||
/// </summary>
|
||||
public static class StringUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// Trims a string at the first instance of a 0x0000 terminator.
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic for converting raw data to class/stack struct, and back to data.
|
||||
/// </summary>
|
||||
internal static class StructConverter
|
||||
{
|
||||
public static T ToStructure<T>(this byte[] bytes) where T : struct
|
||||
|
|
|
|||
|
|
@ -3,8 +3,16 @@
|
|||
|
||||
namespace NHSE.Parsing
|
||||
{
|
||||
/// <summary>
|
||||
/// Logic for converting various dumps to resources used by the Core project.
|
||||
/// </summary>
|
||||
public static class ParseConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts {Hex, Name} to an index-able list of strings.
|
||||
/// </summary>
|
||||
/// <param name="input">Path to Key Value pair listing, with keys being hex numbers (without 0x prefix)</param>
|
||||
/// <param name="output">File to write the result list to</param>
|
||||
public static void ConvertItemStrings(string input, string output)
|
||||
{
|
||||
var result = ConvertItemList(input);
|
||||
|
|
|
|||
|
|
@ -4,14 +4,26 @@
|
|||
|
||||
namespace NHSE.Sprites
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides sprites for Villagers.
|
||||
/// </summary>
|
||||
public static class VillagerSprite
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the Villager's 128x128 sprite based on the input parameters.
|
||||
/// </summary>
|
||||
/// <param name="species">Species of Villager</param>
|
||||
/// <param name="variant">Variant of Villager</param>
|
||||
public static Image? GetVillagerSprite(VillagerSpecies species, int variant)
|
||||
{
|
||||
var asset = VillagerUtil.GetInternalVillagerName(species, variant);
|
||||
return GetVillagerSprite(asset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sprite for the Villager based on its internal name.
|
||||
/// </summary>
|
||||
/// <param name="asset">Internal name of the villager (3char, 2digit)</param>
|
||||
public static Image? GetVillagerSprite(string asset)
|
||||
{
|
||||
return (Image?)Resources.ResourceManager.GetObject(asset);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user