Shared/Packets: Tweak (de)serialization offsets to a more stable layout
Also: - Add a missing ShinePacket field
This commit is contained in:
parent
f9c20e73a8
commit
4656b8af40
|
@ -12,7 +12,7 @@ public struct CapPacket : IPacket {
|
|||
public bool CapOut;
|
||||
public string CapAnim;
|
||||
|
||||
public short Size => 0x50;
|
||||
public short Size => 32 + NameSize;
|
||||
|
||||
public void Serialize(Span<byte> data) {
|
||||
MemoryMarshal.Write(data, ref Position);
|
||||
|
|
|
@ -12,16 +12,16 @@ public struct GamePacket : IPacket {
|
|||
|
||||
public GamePacket() { }
|
||||
|
||||
public short Size => 0x42;
|
||||
public short Size => 5 + StageSize;
|
||||
public void Serialize(Span<byte> data) {
|
||||
MemoryMarshal.Write(data, ref Is2d);
|
||||
MemoryMarshal.Write(data[1..], ref ScenarioNum);
|
||||
Encoding.UTF8.GetBytes(Stage).CopyTo(data[2..(2 + StageSize)]);
|
||||
MemoryMarshal.Write(data[4..], ref ScenarioNum);
|
||||
Encoding.UTF8.GetBytes(Stage).CopyTo(data[5..(5 + StageSize)]);
|
||||
}
|
||||
|
||||
public void Deserialize(ReadOnlySpan<byte> data) {
|
||||
Is2d = MemoryMarshal.Read<bool>(data);
|
||||
ScenarioNum = MemoryMarshal.Read<byte>(data[1..]);
|
||||
Stage = Encoding.UTF8.GetString(data[2..(2 + StageSize)]).TrimEnd('\0');
|
||||
ScenarioNum = MemoryMarshal.Read<byte>(data[4..]);
|
||||
Stage = Encoding.UTF8.GetString(data[5..(5 + StageSize)]).TrimEnd('\0');
|
||||
}
|
||||
}
|
|
@ -5,14 +5,17 @@ namespace Shared.Packet.Packets;
|
|||
[Packet(PacketType.Shine)]
|
||||
public struct ShinePacket : IPacket {
|
||||
public int ShineId;
|
||||
public bool IsGrand;
|
||||
|
||||
public short Size => 4;
|
||||
public short Size => 8;
|
||||
|
||||
public void Serialize(Span<byte> data) {
|
||||
MemoryMarshal.Write(data, ref ShineId);
|
||||
MemoryMarshal.Write(data[4..], ref IsGrand);
|
||||
}
|
||||
|
||||
public void Deserialize(ReadOnlySpan<byte> data) {
|
||||
ShineId = MemoryMarshal.Read<int>(data);
|
||||
IsGrand = MemoryMarshal.Read<bool>(data[4..]);
|
||||
}
|
||||
}
|
|
@ -9,20 +9,20 @@ public struct TagPacket : IPacket {
|
|||
public byte Seconds;
|
||||
public ushort Minutes;
|
||||
|
||||
public short Size => 6;
|
||||
public short Size => 8;
|
||||
|
||||
public void Serialize(Span<byte> data) {
|
||||
MemoryMarshal.Write(data, ref UpdateType);
|
||||
MemoryMarshal.Write(data[1..], ref IsIt);
|
||||
MemoryMarshal.Write(data[2..], ref Seconds);
|
||||
MemoryMarshal.Write(data[4..], ref Minutes);
|
||||
MemoryMarshal.Write(data[5..], ref Seconds);
|
||||
MemoryMarshal.Write(data[6..], ref Minutes);
|
||||
}
|
||||
|
||||
public void Deserialize(ReadOnlySpan<byte> data) {
|
||||
UpdateType = MemoryMarshal.Read<TagUpdate>(data);
|
||||
IsIt = MemoryMarshal.Read<bool>(data[1..]);
|
||||
Seconds = MemoryMarshal.Read<byte>(data[2..]);
|
||||
Minutes = MemoryMarshal.Read<ushort>(data[4..]);
|
||||
Seconds = MemoryMarshal.Read<byte>(data[5..]);
|
||||
Minutes = MemoryMarshal.Read<ushort>(data[6..]);
|
||||
}
|
||||
|
||||
[Flags]
|
||||
|
|
Loading…
Reference in New Issue