chore: I don't know right now
All checks were successful
Build, Package and Push Images / preprocess (push) Successful in 2s
Build, Package and Push Images / build (push) Successful in 25s
Build, Package and Push Images / sonarqube (push) Has been skipped
Build, Package and Push Images / sbom-scan (push) Successful in 32s
Build, Package and Push Images / container-build (push) Successful in 1m23s
Build, Package and Push Images / container-sbom-scan (push) Successful in 37s

This commit is contained in:
Timothy Schenk 2023-11-16 23:51:30 +01:00
parent 4b7f0b6f00
commit 0077d380f3
6 changed files with 21 additions and 15 deletions

View file

@ -62,7 +62,7 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket>
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<CharacterCreationPacket>
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()

View file

@ -18,15 +18,16 @@ public class CharacterDeletionHandler : IPacketHandler<CharacterDeletePacket>
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<CharacterDeletePacket>
_wonderkingContext.Characters.Remove(character);
await _wonderkingContext.SaveChangesAsync().ConfigureAwait(false);
response.Response = CharacterDeletionResponse.Ok;
authSession.Send(response);
}

View file

@ -108,7 +108,7 @@ public class LoginHandler : IPacketHandler<LoginInfoPacket>
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
};

View file

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

View file

@ -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<byte> data = stackalloc byte[1];
data[0] = (byte)Response;
data[0] = IsDeleted;
return data.ToArray();
}
}

View file

@ -1,7 +0,0 @@
namespace Wonderking.Packets.Outgoing;
public enum CharacterDeletionResponse : byte
{
Ok = 0,
MakeClientStuck = 1,
}