From 0077d380f38ab053ed6242b52101f9ffa0635007 Mon Sep 17 00:00:00 2001 From: Timothy Schenk Date: Thu, 16 Nov 2023 23:51:30 +0100 Subject: [PATCH] chore: I don't know right now --- Server/PacketHandlers/CharacterCreationHandler.cs | 5 +++-- Server/PacketHandlers/CharacterDeletionHandler.cs | 6 +++--- Server/PacketHandlers/LoginHandler.cs | 2 +- Server/Services/WonderkingAuthServer.cs | 12 ++++++++++++ .../Outgoing/CharacterDeleteResponsePacket.cs | 4 ++-- .../Packets/Outgoing/CharacterDeletionResponse.cs | 7 ------- 6 files changed, 21 insertions(+), 15 deletions(-) delete mode 100644 Wonderking/Packets/Outgoing/CharacterDeletionResponse.cs diff --git a/Server/PacketHandlers/CharacterCreationHandler.cs b/Server/PacketHandlers/CharacterCreationHandler.cs index 85f2a26..7e9dcb4 100644 --- a/Server/PacketHandlers/CharacterCreationHandler.cs +++ b/Server/PacketHandlers/CharacterCreationHandler.cs @@ -62,7 +62,7 @@ public class CharacterCreationHandler : IPacketHandler var calculateCurrentMana = CalculateCurrentMana(1, firstJobConfig); var calculateCurrentHealth = CalculateCurrentHealth(1, firstJobConfig); - account?.Characters.Add(new Character + var toBeAddedCharacter = new Character { Account = account, MapId = 300, @@ -78,7 +78,8 @@ public class CharacterCreationHandler : IPacketHandler JobData = new JobData { FirstJob = packet.FirstJob, SecondJob = 0, ThirdJob = 0, FourthJob = 0 }, Health = calculateCurrentHealth, Mana = calculateCurrentMana - }); + }; + account?.Characters.Add(toBeAddedCharacter); await _wonderkingContext.SaveChangesAsync().ConfigureAwait(true); var amountOfCharacters = await _wonderkingContext.Characters.AsNoTrackingWithIdentityResolution() diff --git a/Server/PacketHandlers/CharacterDeletionHandler.cs b/Server/PacketHandlers/CharacterDeletionHandler.cs index f5de8d9..920131a 100644 --- a/Server/PacketHandlers/CharacterDeletionHandler.cs +++ b/Server/PacketHandlers/CharacterDeletionHandler.cs @@ -18,15 +18,16 @@ public class CharacterDeletionHandler : IPacketHandler public async Task HandleAsync(CharacterDeletePacket packet, TcpSession session) { using var authSession = session as AuthSession; - var response = new CharacterDeleteResponsePacket { Response = CharacterDeletionResponse.MakeClientStuck }; if (authSession == null) { + session.Disconnect(); return; } var character = await _wonderkingContext.Characters.FirstOrDefaultAsync(x => x.Name == packet.Name && x.Account.Id == authSession.AccountId) - .ConfigureAwait(false); + .ConfigureAwait(true); + var response = new CharacterDeleteResponsePacket { IsDeleted = 0 }; if (character == null) { authSession.Send(response); @@ -35,7 +36,6 @@ public class CharacterDeletionHandler : IPacketHandler _wonderkingContext.Characters.Remove(character); await _wonderkingContext.SaveChangesAsync().ConfigureAwait(false); - response.Response = CharacterDeletionResponse.Ok; authSession.Send(response); } diff --git a/Server/PacketHandlers/LoginHandler.cs b/Server/PacketHandlers/LoginHandler.cs index a79cf44..1d60f1b 100644 --- a/Server/PacketHandlers/LoginHandler.cs +++ b/Server/PacketHandlers/LoginHandler.cs @@ -108,7 +108,7 @@ public class LoginHandler : IPacketHandler var loginResponsePacket = new LoginResponsePacket { ResponseReason = loginResponseReason, - ChannelData = new[] { new ServerChannelData { ChannelId = 0, LoadPercentage = 75, ServerId = 0 } }, + ChannelData = new[] { new ServerChannelData { ChannelId = 0, LoadPercentage = 0, ServerId = 0 } }, UnknownFlag = 1, IsGameMaster = true }; diff --git a/Server/Services/WonderkingAuthServer.cs b/Server/Services/WonderkingAuthServer.cs index fd9d6e1..30ae4e8 100644 --- a/Server/Services/WonderkingAuthServer.cs +++ b/Server/Services/WonderkingAuthServer.cs @@ -58,5 +58,17 @@ public class WonderkingAuthServer : TcpServer, IHostedService base.OnStopped(); } + protected override void OnConnected(TcpSession session) + { + this._logger.LogInformation("Client connected {Session}", session.Id); + base.OnConnected(session); + } + + protected override void OnDisconnected(TcpSession session) + { + this._logger.LogInformation("Client disconnected {Session}", session.Id); + base.OnDisconnected(session); + } + protected override void OnError(SocketError error) => this._logger.LogError("An error has occured {Error}", error); } diff --git a/Wonderking/Packets/Outgoing/CharacterDeleteResponsePacket.cs b/Wonderking/Packets/Outgoing/CharacterDeleteResponsePacket.cs index 72392c3..d467c06 100644 --- a/Wonderking/Packets/Outgoing/CharacterDeleteResponsePacket.cs +++ b/Wonderking/Packets/Outgoing/CharacterDeleteResponsePacket.cs @@ -3,7 +3,7 @@ namespace Wonderking.Packets.Outgoing; [PacketId(OperationCode.CharacterDeletionResponse)] public class CharacterDeleteResponsePacket : IPacket { - public required CharacterDeletionResponse Response { get; set; } + public required byte IsDeleted { get; set; } public void Deserialize(byte[] data) { @@ -13,7 +13,7 @@ public class CharacterDeleteResponsePacket : IPacket public byte[] Serialize() { Span data = stackalloc byte[1]; - data[0] = (byte)Response; + data[0] = IsDeleted; return data.ToArray(); } } diff --git a/Wonderking/Packets/Outgoing/CharacterDeletionResponse.cs b/Wonderking/Packets/Outgoing/CharacterDeletionResponse.cs deleted file mode 100644 index 8676416..0000000 --- a/Wonderking/Packets/Outgoing/CharacterDeletionResponse.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Wonderking.Packets.Outgoing; - -public enum CharacterDeletionResponse : byte -{ - Ok = 0, - MakeClientStuck = 1, -}