Add some xmldoc

This commit is contained in:
Kurt 2020-03-27 21:01:24 -07:00
parent e0821eb9ba
commit 88b6776393
27 changed files with 146 additions and 8 deletions

View File

@ -2,6 +2,9 @@
namespace NHSE.Core
{
/// <summary>
/// main.dat
/// </summary>
public sealed class MainSave : EncryptedFilePair
{
public readonly MainSaveOffsets Offsets;

View File

@ -3,6 +3,9 @@
namespace NHSE.Core
{
/// <summary>
/// personal.dat
/// </summary>
public sealed class Personal : EncryptedFilePair
{
public readonly PersonalOffsets Offsets;

View File

@ -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") { }

View File

@ -1,5 +1,8 @@
namespace NHSE.Core
{
/// <summary>
/// postbox.dat
/// </summary>
public sealed class PostBox : EncryptedFilePair
{
public PostBox(string folder) : base(folder, "postbox") { }

View File

@ -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.
}
}

View File

@ -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();

View File

@ -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>
{

View File

@ -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()));

View File

@ -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()

View File

@ -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

View File

@ -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;

View File

@ -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; }

View File

@ -1,5 +1,8 @@
namespace NHSE.Core
{
/// <summary>
/// <inheritdoc cref="MainSaveOffsets"/>
/// </summary>
public class MainSaveOffsets10 : MainSaveOffsets
{
public override int Villager => 0x110;

View File

@ -1,5 +1,8 @@
namespace NHSE.Core
{
/// <summary>
/// <inheritdoc cref="MainSaveOffsets"/>
/// </summary>
public class MainSaveOffsets11 : MainSaveOffsets
{
public override int Villager => 0x120;

View File

@ -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; }

View File

@ -1,5 +1,8 @@
namespace NHSE.Core
{
/// <summary>
/// <inheritdoc cref="PersonalOffsets"/>
/// </summary>
public sealed class PersonalOffsets10 : PersonalOffsets
{
public override int PersonalId => 0xB0A0;

View File

@ -1,5 +1,8 @@
namespace NHSE.Core
{
/// <summary>
/// <inheritdoc cref="PersonalOffsets"/>
/// </summary>
public sealed class PersonalOffsets11 : PersonalOffsets
{
public override int PersonalId => 0xB0B8;

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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.

View File

@ -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

View File

@ -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);

View File

@ -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);