mirror of
https://github.com/kwsch/NHSE.git
synced 2026-04-18 22:47:24 -05:00
parent
7f58513d29
commit
86da243405
|
|
@ -222,6 +222,12 @@ public uint EventPlazaLeftUpZ
|
|||
set => BitConverter.GetBytes(value).CopyTo(Data, Offsets.OutsideField + AcreSizeAll + 8);
|
||||
}
|
||||
|
||||
public GSaveFg SaveFg
|
||||
{
|
||||
get => Data.ToClass<GSaveFg>(Offsets.SaveFg, GSaveFg.SIZE);
|
||||
set => value.ToBytesClass().CopyTo(Data, Offsets.SaveFg);
|
||||
}
|
||||
|
||||
public GSaveTime LastSaved => Data.Slice(Offsets.LastSavedTime, GSaveTime.SIZE).ToStructure<GSaveTime>();
|
||||
|
||||
public GSaveBulletinBoard Bulletin
|
||||
|
|
|
|||
|
|
@ -124,6 +124,12 @@ public short[] GetEventFlagsPlayer()
|
|||
|
||||
public void SetEventFlagsPlayer(short[] value) => Buffer.BlockCopy(value, 0, Data, Offsets.EventFlagsPlayer, value.Length * sizeof(short));
|
||||
|
||||
public GSaveDateMD Birthday
|
||||
{
|
||||
get => Data.ToStructure<GSaveDateMD>(Offsets.Birthday, GSaveDateMD.SIZE);
|
||||
set => value.ToBytes().CopyTo(Data, Offsets.Birthday);
|
||||
}
|
||||
|
||||
public byte[] GetPhotoData()
|
||||
{
|
||||
var offset = Offsets.Photo;
|
||||
|
|
|
|||
|
|
@ -29,16 +29,13 @@ public abstract class MainSaveOffsets
|
|||
public abstract int LandMakingMap { get; }
|
||||
public abstract int PlayerHouseList { get; }
|
||||
public abstract int NpcHouseList { get; }
|
||||
|
||||
public abstract int LastSavedTime { get; }
|
||||
public abstract int BulletinBoard { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Turnip Stalk Market
|
||||
/// </summary>
|
||||
public abstract int ShopKabu { get; }
|
||||
|
||||
public abstract int SaveFg { get; }
|
||||
public abstract int BulletinBoard { get; }
|
||||
|
||||
public abstract int LostItemBox { get; }
|
||||
public abstract int LastSavedTime { get; }
|
||||
|
||||
public static MainSaveOffsets GetOffsets(FileHeaderInfo Info)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public class MainSaveOffsets10 : MainSaveOffsets
|
|||
|
||||
public const int GSaveShop = GSaveLandStart + 0x40ECE8;
|
||||
public override int ShopKabu => GSaveShop + 0x2AD0; // part of shop
|
||||
public override int SaveFg => GSaveLandStart + 0x4150B4;
|
||||
#endregion
|
||||
|
||||
#region GSaveLandOther
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public class MainSaveOffsets11 : MainSaveOffsets
|
|||
|
||||
public const int GSaveShop = GSaveLandStart + 0x40F480;
|
||||
public override int ShopKabu => GSaveShop + 0x2AD0; // part of shop
|
||||
public override int SaveFg => GSaveLandStart + 0x41584C;
|
||||
#endregion
|
||||
|
||||
#region GSaveLandOther
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public class MainSaveOffsets12 : MainSaveOffsets
|
|||
|
||||
public const int GSaveShop = GSaveLandStart + 0x40F480;
|
||||
public override int ShopKabu => GSaveShop + 0x2AD0; // part of shop
|
||||
public override int SaveFg => GSaveLandStart + 0x415AF8;
|
||||
#endregion
|
||||
|
||||
#region GSaveLandOther
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ public abstract class PersonalOffsets
|
|||
public abstract int Wallet { get; }
|
||||
public abstract int NowPoint { get; }
|
||||
public abstract int TotalPoint { get; }
|
||||
public abstract int Birthday { get; }
|
||||
public abstract int Photo { get; }
|
||||
|
||||
public abstract int Pockets1 { get; }
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public sealed class PersonalOffsets10 : PersonalOffsets
|
|||
|
||||
public override int NowPoint => GSaveLifeSupport + 0x5498; // Nook Miles
|
||||
public override int TotalPoint => NowPoint + 8; // Total Nook Miles Earned
|
||||
public override int Birthday => Player + 0x11478;
|
||||
|
||||
private const int GSaveNetPlayerProfile = Player + 0x11480;
|
||||
public override int Photo => GSaveNetPlayerProfile + 0x24;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public sealed class PersonalOffsets11 : PersonalOffsets
|
|||
|
||||
public override int NowPoint => GSaveLifeSupport + 0x5498; // Nook Miles
|
||||
public override int TotalPoint => NowPoint + 8; // Total Nook Miles Earned
|
||||
public override int Birthday => Player + 0x11488;
|
||||
|
||||
private const int GSaveNetPlayerProfile = Player + 0x11490;
|
||||
public override int Photo => GSaveNetPlayerProfile + 0x24;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public sealed class PersonalOffsets12 : PersonalOffsets
|
|||
|
||||
public override int NowPoint => GSaveLifeSupport + 0x5498; // Nook Miles
|
||||
public override int TotalPoint => NowPoint + 8; // Total Nook Miles Earned
|
||||
public override int Birthday => Player + 0x1168C;
|
||||
|
||||
private const int GSaveNetPlayerProfile = Player + 0x11690;
|
||||
public override int Photo => GSaveNetPlayerProfile + 0x24;
|
||||
|
|
|
|||
16
NHSE.Core/Structures/Misc/GSaveDateMD.cs
Normal file
16
NHSE.Core/Structures/Misc/GSaveDateMD.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using System.ComponentModel;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NHSE.Core
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
[TypeConverter(typeof(ValueTypeTypeConverter))]
|
||||
public struct GSaveDateMD
|
||||
{
|
||||
public const int SIZE = 2;
|
||||
public override string ToString() => $"{Month:00}-{Day:00}";
|
||||
|
||||
public byte Month { get; set; }
|
||||
public byte Day { get; set; }
|
||||
}
|
||||
}
|
||||
23
NHSE.Core/Structures/Misc/GSaveFg.cs
Normal file
23
NHSE.Core/Structures/Misc/GSaveFg.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
#pragma warning disable CS8618, CA1815, CA1819, IDE1006
|
||||
namespace NHSE.Core
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
public class GSaveFg
|
||||
{
|
||||
public const int SIZE = 0x928;
|
||||
private const int _7b9816fbCount = 0x900;
|
||||
private const int _e88f809dCount = 8;
|
||||
|
||||
[field: MarshalAs(UnmanagedType.ByValArray, SizeConst = _7b9816fbCount)]
|
||||
public byte[] _7b9816fb { get; set; } // @0x0 size 0x900, align 1
|
||||
public ushort SpecialityFruit { get; set; } // @0x900 size 0x2, align 2
|
||||
public ushort SisterFruit { get; set; } // @0x902 size 0x2, align 2
|
||||
|
||||
[field: MarshalAs(UnmanagedType.ByValArray, SizeConst = _e88f809dCount)]
|
||||
public uint[] _e88f809d { get; set; } // @0x904 size 0x4, align 4
|
||||
public byte VillageFlower { get; set; } // @0x924 size 0x1, align 1
|
||||
public byte SpecialityFlower { get; set; } // @0x925 size 0x1, align 1
|
||||
}
|
||||
}
|
||||
|
|
@ -23,6 +23,18 @@ public static class StructConverter
|
|||
finally { handle.Free(); }
|
||||
}
|
||||
|
||||
public static T ToStructure<T>(this byte[] bytes, int offset, int length) where T : struct
|
||||
{
|
||||
var slice = bytes.Slice(offset, length);
|
||||
return slice.ToStructure<T>();
|
||||
}
|
||||
|
||||
public static T ToClass<T>(this byte[] bytes, int offset, int length) where T : class
|
||||
{
|
||||
var slice = bytes.Slice(offset, length);
|
||||
return slice.ToClass<T>();
|
||||
}
|
||||
|
||||
public static byte[] ToBytesClass<T>(this T obj) where T : class
|
||||
{
|
||||
int size = Marshal.SizeOf(obj);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ public class FancyMarshalTests
|
|||
[Fact] public void MarshalBulletinBoard() => MarshalBytesTestS<BulletinBoardStock>(BulletinBoardStock.SIZE);
|
||||
[Fact] public void MarshalGSaveBBS() => MarshalBytesTestS<GSaveBBS>(GSaveBBS.SIZE);
|
||||
[Fact] public void MarshalGSaveDate() => MarshalBytesTestS<GSaveDate>(GSaveDate.SIZE);
|
||||
[Fact] public void MarshalGSaveDateMD() => MarshalBytesTestS<GSaveDateMD>(GSaveDateMD.SIZE);
|
||||
[Fact] public void MarshalGSavePlayerId() => MarshalBytesTestS<GSavePlayerId>(GSavePlayerId.SIZE);
|
||||
[Fact] public void MarshalGSaveLandId() => MarshalBytesTestS<GSaveLandId>(GSaveLandId.SIZE);
|
||||
[Fact] public void MarshalGSavePlayerBaseId() => MarshalBytesTestS<GSavePlayerBaseId>(GSavePlayerBaseId.SIZE);
|
||||
|
|
@ -18,6 +19,7 @@ public class FancyMarshalTests
|
|||
[Fact] public void MarshalGSaveRoomFloorWall() => MarshalBytesTestS<GSaveRoomFloorWall>(GSaveRoomFloorWall.SIZE);
|
||||
|
||||
[Fact] public void MarshalGSaveManpu() => MarshalBytesTestS<GSavePlayerManpu>(GSavePlayerManpu.SIZE);
|
||||
[Fact] public void MarshalGSaveFg() => MarshalBytesTest<GSaveFg>(GSaveFg.SIZE);
|
||||
|
||||
private static void MarshalBytesTestS<T>(int size) where T : struct
|
||||
{
|
||||
|
|
@ -27,5 +29,14 @@ public class FancyMarshalTests
|
|||
var decomputed = obj.ToBytes();
|
||||
decomputed.Length.Should().Be(size);
|
||||
}
|
||||
|
||||
private static void MarshalBytesTest<T>(int size) where T : class
|
||||
{
|
||||
var bytes = new byte[size];
|
||||
var obj = bytes.ToClass<T>();
|
||||
|
||||
var decomputed = obj.ToBytesClass();
|
||||
decomputed.Length.Should().Be(size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user