chore: cleanup leftovers

This commit is contained in:
Timothy Schenk 2024-02-04 20:05:39 +01:00
parent e8b331059d
commit e305ce49aa
Signed by: rainote
SSH key fingerprint: SHA256:pnkNSDwpAnaip00xaZlVFHKKsS7T8UtOomMzvs0yITE
13 changed files with 8 additions and 82 deletions

View file

@ -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);
}

View file

@ -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();
}

View file

@ -15,9 +15,4 @@ public class ChannelSelectionPacket : IIncomingPacket
ServerId = BitConverter.ToUInt16(data, 0);
ChannelId = BitConverter.ToUInt16(data, 2);
}
public byte[] Serialize()
{
throw new NotSupportedException();
}
}

View file

@ -34,9 +34,4 @@ public class CharacterCreationPacket : IIncomingPacket
Shirt = data[28];
Pants = data[29];
}
public byte[] Serialize()
{
throw new NotSupportedException();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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];

View file

@ -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];

View file

@ -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];

View file

@ -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];

View file

@ -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];

View file

@ -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;