fix: incorrect offset

This commit is contained in:
Timothy Schenk 2023-11-16 12:22:18 +01:00
parent 316881266b
commit 797ea61f36

View file

@ -18,38 +18,38 @@ public class CharacterCreationResponsePacket : IPacket
{
Span<byte> data = stackalloc byte[132];
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(0 + 132, 4), 0);
Encoding.ASCII.GetBytes(Character.Name, data.Slice(4 + 132, 20));
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(0, 4), 0);
Encoding.ASCII.GetBytes(Character.Name, data.Slice(4, 20));
// Job Data
data[24 + 132] = Character.Job.FirstJob;
data[25 + 132] = Character.Job.SecondJob;
data[26 + 132] = Character.Job.ThirdJob;
data[27 + 132] = Character.Job.FourthJob;
data[24] = Character.Job.FirstJob;
data[25] = Character.Job.SecondJob;
data[26] = Character.Job.ThirdJob;
data[27] = Character.Job.FourthJob;
data[28 + 132] = (byte)Character.Gender;
BinaryPrimitives.WriteUInt16LittleEndian(data.Slice(49 + 132, 2), Character.Level);
data[31 + 132] = (byte)Character.Experience;
data[28] = (byte)Character.Gender;
BinaryPrimitives.WriteUInt16LittleEndian(data.Slice(49, 2), Character.Level);
data[31] = (byte)Character.Experience;
// Stats
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(32 + 132, 2), Character.Stats.Strength);
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(34 + 132, 2), Character.Stats.Dexterity);
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(36 + 132, 2), Character.Stats.Intelligence);
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(38 + 132, 2), Character.Stats.Vitality);
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(40 + 132, 2), Character.Stats.Luck);
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(42 + 132, 2), Character.Stats.Wisdom);
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(32, 2), Character.Stats.Strength);
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(34, 2), Character.Stats.Dexterity);
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(36, 2), Character.Stats.Intelligence);
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(38, 2), Character.Stats.Vitality);
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(40, 2), Character.Stats.Luck);
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(42, 2), Character.Stats.Wisdom);
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(44 + 132, 4), Character.Health);
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(48 + 132, 4), Character.Mana);
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(44, 4), Character.Health);
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(48, 4), Character.Mana);
for (var i = 0; i < 20; i++)
{
// Equipped Items
BinaryPrimitives.WriteUInt16LittleEndian(data.Slice(52 + 132 + i * 2, 2),
BinaryPrimitives.WriteUInt16LittleEndian(data.Slice(52 + i * 2, 2),
Character.EquippedItems.Length > i ? Character.EquippedItems[i] : (ushort)0);
// Equipped Cash Items
BinaryPrimitives.WriteUInt16LittleEndian(data.Slice(92 + 132 + i * 2, 2),
BinaryPrimitives.WriteUInt16LittleEndian(data.Slice(92 + i * 2, 2),
Character.EquippedCashItems.Length > i ? Character.EquippedCashItems[i] : (ushort)0);
}