fix: adjustment to packet offsets
This commit is contained in:
parent
dd4ed0a67b
commit
873ab306a5
2 changed files with 32 additions and 22 deletions
|
@ -61,6 +61,9 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket>
|
|||
});
|
||||
await _wonderkingContext.SaveChangesAsync().ConfigureAwait(true);
|
||||
|
||||
var amountOfCharacters = await _wonderkingContext.Characters.AsNoTrackingWithIdentityResolution()
|
||||
.CountAsync(c => authSession != null && c.Account.Id == authSession.AccountId).ConfigureAwait(true);
|
||||
|
||||
var character = await _wonderkingContext.Characters.AsNoTrackingWithIdentityResolution()
|
||||
.Where(c => authSession != null && c.Account.Id == authSession.AccountId && c.Name == packet.Name)
|
||||
.Select(c =>
|
||||
|
@ -83,6 +86,11 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket>
|
|||
.Select(item => item.ItemId)
|
||||
.ToArray(),
|
||||
}).FirstAsync().ConfigureAwait(true);
|
||||
authSession?.Send(new CharacterCreationResponsePacket { Character = character });
|
||||
authSession?.Send(new CharacterCreationResponsePacket
|
||||
{
|
||||
Character = character,
|
||||
Slot = amountOfCharacters - 1,
|
||||
isDuplicate = false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ namespace Wonderking.Packets.Outgoing;
|
|||
public class CharacterCreationResponsePacket : IPacket
|
||||
{
|
||||
public required CharacterData Character { get; set; }
|
||||
public required int Slot { get; set; }
|
||||
public required bool isDuplicate { get; set; }
|
||||
|
||||
public void Deserialize(byte[] data)
|
||||
{
|
||||
|
@ -16,40 +18,40 @@ public class CharacterCreationResponsePacket : IPacket
|
|||
|
||||
public byte[] Serialize()
|
||||
{
|
||||
Span<byte> data = stackalloc byte[132];
|
||||
|
||||
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(0, 4), 0);
|
||||
Encoding.ASCII.GetBytes(Character.Name, data.Slice(4, 20));
|
||||
Span<byte> data = stackalloc byte[1 + 132];
|
||||
data[0] = isDuplicate ? (byte)1 : (byte)0;
|
||||
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(1, 4), Slot);
|
||||
Encoding.ASCII.GetBytes(Character.Name, data.Slice(5, 20));
|
||||
|
||||
// Job Data
|
||||
data[24] = Character.Job.FirstJob;
|
||||
data[25] = Character.Job.SecondJob;
|
||||
data[26] = Character.Job.ThirdJob;
|
||||
data[27] = Character.Job.FourthJob;
|
||||
data[25] = Character.Job.FirstJob;
|
||||
data[26] = Character.Job.SecondJob;
|
||||
data[27] = Character.Job.ThirdJob;
|
||||
data[28] = Character.Job.FourthJob;
|
||||
|
||||
data[28] = (byte)Character.Gender;
|
||||
BinaryPrimitives.WriteUInt16LittleEndian(data.Slice(49, 2), Character.Level);
|
||||
data[31] = (byte)Character.Experience;
|
||||
data[29] = (byte)Character.Gender;
|
||||
BinaryPrimitives.WriteUInt16LittleEndian(data.Slice(30, 2), Character.Level);
|
||||
data[32] = (byte)Character.Experience;
|
||||
|
||||
// Stats
|
||||
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.WriteInt16LittleEndian(data.Slice(33, 2), Character.Stats.Strength);
|
||||
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(35, 2), Character.Stats.Dexterity);
|
||||
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(37, 2), Character.Stats.Intelligence);
|
||||
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(39, 2), Character.Stats.Vitality);
|
||||
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(41, 2), Character.Stats.Luck);
|
||||
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(43, 2), Character.Stats.Wisdom);
|
||||
|
||||
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(44, 4), Character.Health);
|
||||
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(48, 4), Character.Mana);
|
||||
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(45, 4), Character.Health);
|
||||
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(49, 4), Character.Mana);
|
||||
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
// Equipped Items
|
||||
BinaryPrimitives.WriteUInt16LittleEndian(data.Slice(52 + i * 2, 2),
|
||||
BinaryPrimitives.WriteUInt16LittleEndian(data.Slice(53 + i * 2, 2),
|
||||
Character.EquippedItems.Length > i ? Character.EquippedItems[i] : (ushort)0);
|
||||
|
||||
// Equipped Cash Items
|
||||
BinaryPrimitives.WriteUInt16LittleEndian(data.Slice(92 + i * 2, 2),
|
||||
BinaryPrimitives.WriteUInt16LittleEndian(data.Slice(93 + i * 2, 2),
|
||||
Character.EquippedCashItems.Length > i ? Character.EquippedCashItems[i] : (ushort)0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue