feat: implement ChannelSelectionResponse packet data
All checks were successful
Build, Package and Push Images / preprocess (push) Successful in 2s
Build, Package and Push Images / build (push) Successful in 26s
Build, Package and Push Images / sonarqube (push) Has been skipped
Build, Package and Push Images / sbom-scan (push) Successful in 35s
Build, Package and Push Images / container-build (push) Successful in 1m31s
Build, Package and Push Images / container-sbom-scan (push) Successful in 38s
All checks were successful
Build, Package and Push Images / preprocess (push) Successful in 2s
Build, Package and Push Images / build (push) Successful in 26s
Build, Package and Push Images / sonarqube (push) Has been skipped
Build, Package and Push Images / sbom-scan (push) Successful in 35s
Build, Package and Push Images / container-build (push) Successful in 1m31s
Build, Package and Push Images / container-sbom-scan (push) Successful in 38s
This commit is contained in:
parent
72cacab0ed
commit
9a827214fa
5 changed files with 115 additions and 1 deletions
|
@ -4,5 +4,6 @@ public enum OperationCode : ushort
|
||||||
{
|
{
|
||||||
LoginInfo = 11,
|
LoginInfo = 11,
|
||||||
LoginResponse = 12,
|
LoginResponse = 12,
|
||||||
ChannelSelection
|
ChannelSelection = 13,
|
||||||
|
ChannelSelectionResponse = 13
|
||||||
}
|
}
|
||||||
|
|
14
Wonderking/Packets/Outgoing/BaseStats.cs
Normal file
14
Wonderking/Packets/Outgoing/BaseStats.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Wonderking.Packets.Outgoing;
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Auto)]
|
||||||
|
public struct BaseStats
|
||||||
|
{
|
||||||
|
public required short Strength { get; set; }
|
||||||
|
public required short Dexterity { get; set; }
|
||||||
|
public required short Intelligence { get; set; }
|
||||||
|
public required short Vitality { get; set; }
|
||||||
|
public required short Luck { get; set; }
|
||||||
|
public required short Wisdom { get; set; }
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
using System.Buffers.Binary;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Wonderking.Packets.Outgoing;
|
||||||
|
|
||||||
|
[PacketId(OperationCode.ChannelSelectionResponse)]
|
||||||
|
public class ChannelSelectionResponsePacket : IPacket
|
||||||
|
{
|
||||||
|
public required byte UnknownFlag { get; set; }
|
||||||
|
public required string Endpoint { get; set; }
|
||||||
|
public required ushort Port { get; set; }
|
||||||
|
public required CharacterData[] Characters { get; set; }
|
||||||
|
|
||||||
|
public void Deserialize(byte[] data)
|
||||||
|
{
|
||||||
|
throw new NotSupportedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] Serialize()
|
||||||
|
{
|
||||||
|
Span<byte> data = stackalloc byte[1 + 16 + 2 + 2 + 132 * this.Characters.Length];
|
||||||
|
data.Clear();
|
||||||
|
data[0] = this.UnknownFlag;
|
||||||
|
Encoding.ASCII.GetBytes(this.Endpoint, data.Slice(1, 16));
|
||||||
|
BinaryPrimitives.WriteUInt16LittleEndian(data.Slice(17, 2), this.Port);
|
||||||
|
BinaryPrimitives.WriteUInt16LittleEndian(data.Slice(19, 2), (ushort)this.Characters.Length);
|
||||||
|
|
||||||
|
// Character Data
|
||||||
|
for (var i = 0; i < Characters.Length; i++)
|
||||||
|
{
|
||||||
|
var character = Characters[i];
|
||||||
|
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(21, 4), i);
|
||||||
|
Encoding.ASCII.GetBytes(character.Name, data.Slice(25 + (i * 132), 16));
|
||||||
|
|
||||||
|
// Job Data
|
||||||
|
data[41 + (i * 132)] = character.Job.FirstJob;
|
||||||
|
data[42 + (i * 132)] = character.Job.SecondJob;
|
||||||
|
data[43 + (i * 132)] = character.Job.ThirdJob;
|
||||||
|
data[44 + (i * 132)] = character.Job.FourthJob;
|
||||||
|
|
||||||
|
data[45 + (i * 132)] = character.Gender;
|
||||||
|
data[46 + (i * 132)] = character.Level;
|
||||||
|
data[47 + (i * 132)] = character.Unknown;
|
||||||
|
data[48 + (i * 132)] = (byte)character.Experience;
|
||||||
|
|
||||||
|
// Stats
|
||||||
|
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(49 + (i * 132), 2), character.Stats.Strength);
|
||||||
|
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(51 + (i * 132), 2), character.Stats.Dexterity);
|
||||||
|
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(53 + (i * 132), 2), character.Stats.Intelligence);
|
||||||
|
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(55 + (i * 132), 2), character.Stats.Vitality);
|
||||||
|
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(57 + (i * 132), 2), character.Stats.Luck);
|
||||||
|
BinaryPrimitives.WriteInt16LittleEndian(data.Slice(59 + (i * 132), 2), character.Stats.Wisdom);
|
||||||
|
|
||||||
|
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(61 + (i * 132), 4), character.Health);
|
||||||
|
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(65 + (i * 132), 4), character.Mana);
|
||||||
|
|
||||||
|
for (var j = 0; j < 20; j++)
|
||||||
|
{
|
||||||
|
// Equipped Items
|
||||||
|
BinaryPrimitives.WriteUInt16LittleEndian(data.Slice(69 + (i * 132) + (j * 2), 2),
|
||||||
|
character.EquippedItems[j] ?? 0);
|
||||||
|
|
||||||
|
// Equipped Cash Items
|
||||||
|
BinaryPrimitives.WriteUInt16LittleEndian(data.Slice(109 + (i * 132) + (j * 2), 2),
|
||||||
|
character.EquippedCashItems[j] ?? 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return data.ToArray();
|
||||||
|
}
|
||||||
|
}
|
16
Wonderking/Packets/Outgoing/CharacterData.cs
Normal file
16
Wonderking/Packets/Outgoing/CharacterData.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
namespace Wonderking.Packets.Outgoing;
|
||||||
|
|
||||||
|
public struct CharacterData
|
||||||
|
{
|
||||||
|
public required string Name { get; set; }
|
||||||
|
public required JobData Job { get; set; }
|
||||||
|
public required byte Gender { get; set; }
|
||||||
|
public required byte Level { get; set; }
|
||||||
|
public required byte Unknown { get; set; }
|
||||||
|
public required float Experience { get; set; }
|
||||||
|
public required BaseStats Stats { get; set; }
|
||||||
|
public required int Health { get; set; }
|
||||||
|
public required int Mana { get; set; }
|
||||||
|
public required ushort?[] EquippedItems { get; set; }
|
||||||
|
public required ushort?[] EquippedCashItems { get; set; }
|
||||||
|
}
|
12
Wonderking/Packets/Outgoing/JobData.cs
Normal file
12
Wonderking/Packets/Outgoing/JobData.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Wonderking.Packets.Outgoing;
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Auto)]
|
||||||
|
public struct JobData
|
||||||
|
{
|
||||||
|
public required byte FirstJob { get; set; }
|
||||||
|
public required byte SecondJob { get; set; }
|
||||||
|
public required byte ThirdJob { get; set; }
|
||||||
|
public required byte FourthJob { get; set; }
|
||||||
|
}
|
Loading…
Reference in a new issue