chore: cleanup leftovers
This commit is contained in:
parent
e8b331059d
commit
e305ce49aa
13 changed files with 8 additions and 82 deletions
|
@ -1,8 +1,12 @@
|
|||
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
|
||||
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Rai.PacketMediator;
|
||||
|
||||
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
|
||||
public interface IIncomingPacket : IPacket
|
||||
{
|
||||
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
|
||||
public void Deserialize(byte[] data);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
|
||||
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Rai.PacketMediator;
|
||||
|
||||
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
|
||||
public interface IOutgoingPacket : IPacket
|
||||
{
|
||||
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
|
||||
public byte[] Serialize();
|
||||
}
|
||||
|
|
|
@ -15,9 +15,4 @@ public class ChannelSelectionPacket : IIncomingPacket
|
|||
ServerId = BitConverter.ToUInt16(data, 0);
|
||||
ChannelId = BitConverter.ToUInt16(data, 2);
|
||||
}
|
||||
|
||||
public byte[] Serialize()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,9 +34,4 @@ public class CharacterCreationPacket : IIncomingPacket
|
|||
Shirt = data[28];
|
||||
Pants = data[29];
|
||||
}
|
||||
|
||||
public byte[] Serialize()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,4 @@ public class CharacterDeletePacket : IIncomingPacket
|
|||
Name = Encoding.ASCII.GetString(span.Slice(1, 20)).TrimEnd('\0').TrimEnd('\n').TrimEnd('\0');
|
||||
Unknown = BitConverter.ToUInt32(span.Slice(21, 4));
|
||||
}
|
||||
|
||||
public byte[] Serialize()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,9 +14,4 @@ public class CharacterNameCheckPacket : IIncomingPacket
|
|||
{
|
||||
Name = Encoding.ASCII.GetString(data, 0, 20).TrimEnd('\0').TrimEnd('\n').TrimEnd('\0');
|
||||
}
|
||||
|
||||
public byte[] Serialize()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,22 +18,4 @@ public class LoginInfoPacket : IIncomingPacket
|
|||
// Remove unnecessary Symbols
|
||||
Password = Encoding.ASCII.GetString(data, 20, 31).TrimEnd('\0').TrimEnd('\n').TrimEnd('\0');
|
||||
}
|
||||
|
||||
public byte[] Serialize()
|
||||
{
|
||||
Span<byte> dataSpan = stackalloc byte[20 + 31];
|
||||
var usernameBytes = Encoding.ASCII.GetBytes(Username);
|
||||
var passwordBytes = Encoding.ASCII.GetBytes(Password);
|
||||
for (var i = 0; i < 20 || i < Username.Length; i++)
|
||||
{
|
||||
dataSpan[i] = usernameBytes[i];
|
||||
}
|
||||
|
||||
for (var i = 0; i < 31 || i < Password.Length; i++)
|
||||
{
|
||||
dataSpan[20 + i] = passwordBytes[i];
|
||||
}
|
||||
|
||||
return dataSpan.ToArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,11 +15,6 @@ public class ChannelSelectionResponsePacket : IOutgoingPacket
|
|||
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 + 1 + 132 * Characters.Length];
|
||||
|
|
|
@ -14,11 +14,6 @@ public class CharacterCreationResponsePacket : IOutgoingPacket
|
|||
public required int Slot { get; set; }
|
||||
public required bool isDuplicate { get; set; }
|
||||
|
||||
public void Deserialize(byte[] data)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public byte[] Serialize()
|
||||
{
|
||||
Span<byte> data = stackalloc byte[1 + 132];
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
|
||||
|
||||
using Rai.PacketMediator;
|
||||
using NotSupportedException = System.NotSupportedException;
|
||||
|
||||
namespace Wonderking.Packets.Outgoing;
|
||||
|
||||
|
@ -10,11 +9,6 @@ public class CharacterDeleteResponsePacket : IOutgoingPacket
|
|||
{
|
||||
public required byte HasToBeZero { get; set; }
|
||||
|
||||
public void Deserialize(byte[] data)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public byte[] Serialize()
|
||||
{
|
||||
Span<byte> data = stackalloc byte[1];
|
||||
|
|
|
@ -8,12 +8,6 @@ namespace Wonderking.Packets.Outgoing;
|
|||
public class CharacterNameCheckPacketResponse : IOutgoingPacket
|
||||
{
|
||||
public required bool IsTaken { get; set; }
|
||||
|
||||
public void Deserialize(byte[] data)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public byte[] Serialize()
|
||||
{
|
||||
Span<byte> data = stackalloc byte[1];
|
||||
|
|
|
@ -9,12 +9,6 @@ namespace Wonderking.Packets.Outgoing;
|
|||
public class CharacterSelectionSetGuildNamePacket : IOutgoingPacket
|
||||
{
|
||||
public required string[] GuildNames { get; set; }
|
||||
|
||||
public void Deserialize(byte[] data)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public byte[] Serialize()
|
||||
{
|
||||
Span<byte> data = stackalloc byte[1 + (1 + 16 + 1) * GuildNames.Length];
|
||||
|
|
|
@ -14,22 +14,6 @@ public class LoginResponsePacket : IOutgoingPacket
|
|||
public required bool IsGameMaster { get; set; }
|
||||
|
||||
public required ServerChannelData[] ChannelData { get; set; }
|
||||
|
||||
public void Deserialize(byte[] data)
|
||||
{
|
||||
ResponseReason = (LoginResponseReason)data[0];
|
||||
UnknownFlag = data[1];
|
||||
IsGameMaster = BitConverter.ToBoolean(data, 2);
|
||||
var channelAmount = BitConverter.ToUInt16(data, 3);
|
||||
const int sizeOfServerChannelData = 5;
|
||||
ChannelData = Enumerable.Repeat(0, channelAmount).Select(i => new ServerChannelData
|
||||
{
|
||||
ServerId = BitConverter.ToUInt16(data, 5 + 0 + i * sizeOfServerChannelData),
|
||||
ChannelId = BitConverter.ToUInt16(data, 5 + 2 + i * sizeOfServerChannelData),
|
||||
LoadPercentage = data[5 + 4 + i * sizeOfServerChannelData]
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
public byte[] Serialize()
|
||||
{
|
||||
const int sizeOfServerChannelData = 5;
|
||||
|
|
Loading…
Reference in a new issue