From 3d95287f3c292fb68e1fa217ad15108e0adfdac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Boh=C3=A1=C4=8Dek?= Date: Mon, 3 Jan 2022 21:01:50 +0100 Subject: [PATCH] feat: implement cinfo packet --- .../Login/CListPacketResponder.cs | 50 ------------- .../Server/Players/CInfoPacket.cs | 73 +++++++++++++++++-- 2 files changed, 68 insertions(+), 55 deletions(-) delete mode 100644 Core/NosSmooth.Game/PacketHandlers/Login/CListPacketResponder.cs diff --git a/Core/NosSmooth.Game/PacketHandlers/Login/CListPacketResponder.cs b/Core/NosSmooth.Game/PacketHandlers/Login/CListPacketResponder.cs deleted file mode 100644 index e088958..0000000 --- a/Core/NosSmooth.Game/PacketHandlers/Login/CListPacketResponder.cs +++ /dev/null @@ -1,50 +0,0 @@ -// -// CListPacketResponder.cs -// -// Copyright (c) František Boháček. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using NosSmooth.Core.Packets; -using NosSmooth.Game.Events.Core; -using NosSmooth.Game.Events.Login; -using Remora.Results; - -namespace NosSmooth.Game.PacketHandlers.Login; - -/// -/// Handles FStashEnd packet to remove game data. -/// -public class CListPacketResponder : IPacketResponder -{ - private readonly EventDispatcher _eventDispatcher; - private readonly Game _game; - - /// - /// Initializes a new instance of the class. - /// - /// The events dispatcher. - /// The nostale game. - public CListPacketResponder(EventDispatcher eventDispatcher, Game game) - { - _eventDispatcher = eventDispatcher; - _game = game; - } - - /// - public async Task Respond(PacketEventArgs packetArgs, CancellationToken ct = default) - { - await _game.SetSemaphore.WaitAsync(ct); - bool logout = _game.Character is not null || _game.CurrentMap is not null; - _game.Character = null; - _game.CurrentMap = null; - _game.CurrentRaid = null; - _game.SetSemaphore.Release(); - - if (logout) - { - return await _eventDispatcher.DispatchEvent(new LogoutEvent(), ct); - } - - return Result.FromSuccess(); - } -} \ No newline at end of file diff --git a/Packets/NosSmooth.Packets/Server/Players/CInfoPacket.cs b/Packets/NosSmooth.Packets/Server/Players/CInfoPacket.cs index ce3e8ad..46efe57 100644 --- a/Packets/NosSmooth.Packets/Server/Players/CInfoPacket.cs +++ b/Packets/NosSmooth.Packets/Server/Players/CInfoPacket.cs @@ -4,11 +4,74 @@ // Copyright (c) František Boháček. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace NosSmooth.Packets.Server.Players; +using NosSmooth.Packets.Attributes; +using NosSmooth.Packets.Enums; +using NosSmooth.Packets.Enums.Players; + +namespace NosSmooth.Packets.Packets.Server.Players; /// -/// Character information. +/// Information about the playing character. /// -// [PacketHeader()] -// [GenerateSerializer(true)] -public record CInfoPacket(); \ No newline at end of file +/// +/// Sent on login and when changing map. +/// +/// The name of the character. +/// Unknown TODO +/// The id of the group the player is in, if any. +/// The id of the family the player is in, if any. +/// The name of the family the player is in, if any. +/// The id of the character. +/// The authority of the character. +/// The sex of the character. +/// The hair style of the character. +/// The hair color of the character. +/// The class of the character. +/// Unknown TODO +/// Unknown TODO +/// The vnum of the morph (used for special cards, vehicles and such). +/// Whether the character is invisible. +/// The level of the family, if any. +/// The upgrade of the morph (wings) +/// Whether the character is an arena winner. +[PacketHeader("c_info", PacketSource.Server)] +[GenerateSerializer(true)] +public record CInfoPacket +( + [PacketIndex(0)] + string Name, + [PacketIndex(1)] + string? Unknown, + [PacketIndex(2)] + short? GroupId, + [PacketIndex(3)] + string? FamilyId, + [PacketIndex(4)] + string? FamilyName, + [PacketIndex(5)] + long CharacterId, + [PacketIndex(6)] + AuthorityType Authority, + [PacketIndex(7)] + SexType Sex, + [PacketIndex(8)] + HairStyle HairStyle, + [PacketIndex(9)] + HairColor HairColor, + [PacketIndex(10)] + PlayerClass Class, + [PacketIndex(11)] + byte Icon, + [PacketIndex(12)] + short Compliment, + [PacketIndex(13)] + short MorphVNum, + [PacketIndex(14)] + bool IsInvisible, + [PacketIndex(15)] + byte? FamilyLevel, + [PacketIndex(16)] + byte MorphUpgrade, + [PacketIndex(17)] + bool ArenaWinner +) : IPacket; -- 2.48.1