From fff88605045693c2f9af008d89b5e57565ac0129 Mon Sep 17 00:00:00 2001 From: Ryan Yappert Date: Fri, 1 Nov 2024 01:37:29 -0700 Subject: [PATCH] Overhaul contacts/friends list stuff. --- Arrowgene.Ddon.Database/IDatabase.cs | 1 + .../Sql/Core/DdonSqlDbContactList.cs | 64 +++++++++++++- .../Characters/ContactListManager.cs | 2 +- ...acterCommunityCharacterStatusGetHandler.cs | 49 +++++------ .../Handler/FriendApplyFriendListHandler.cs | 73 +++++---------- .../Handler/FriendGetFriendListHandler.cs | 66 ++++++-------- .../FriendRegisterFavoriteFriendHandler.cs | 37 +++----- .../Handler/FriendRemoveFriendHandler.cs | 88 +++++++------------ .../Entity/EntitySerializer.cs | 1 + .../C2SFriendGetFriendListReq.cs | 24 +++++ .../C2SFriendRegisterFavoriteFriendReq.cs | 12 +-- .../C2SFriendRemoveFriendReq.cs | 6 +- ...CharacterCommunityCharacterStatusGetRes.cs | 12 +-- .../S2CFriendGetFriendListRes.cs | 13 +-- .../Entity/Structure/CDataFriendInfo.cs | 18 ++-- .../Database/DatabaseMigratorTest.cs | 1 + 16 files changed, 241 insertions(+), 226 deletions(-) create mode 100644 Arrowgene.Ddon.Shared/Entity/PacketStructure/C2SFriendGetFriendListReq.cs diff --git a/Arrowgene.Ddon.Database/IDatabase.cs b/Arrowgene.Ddon.Database/IDatabase.cs index 8bc51669a..17b832857 100644 --- a/Arrowgene.Ddon.Database/IDatabase.cs +++ b/Arrowgene.Ddon.Database/IDatabase.cs @@ -382,6 +382,7 @@ bool requestedFavorite List SelectContactsByCharacterId(uint characterId); ContactListEntity SelectContactsByCharacterId(uint characterId1, uint characterId2); ContactListEntity SelectContactListById(uint id); + List<(ContactListEntity, CDataCharacterListElement)> SelectFullContactListByCharacterId(uint characterId, DbConnection? connectionIn = null); // Dragon Force Augmentation bool InsertIfNotExistsDragonForceAugmentation( diff --git a/Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbContactList.cs b/Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbContactList.cs index 0370328b7..a39dd6354 100644 --- a/Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbContactList.cs +++ b/Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbContactList.cs @@ -1,6 +1,9 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Data.Common; +using System.Security.Claims; +using Arrowgene.Ddon.Shared.Entity.Structure; using Arrowgene.Ddon.Shared.Model; +using Arrowgene.Ddon.Shared.Model.Clan; namespace Arrowgene.Ddon.Database.Sql.Core { @@ -31,6 +34,22 @@ public abstract partial class DdonSqlDb : SqlDb SelectFullContactListByCharacterId(uint characterId, DbConnection? connectionIn = null) + { + List<(ContactListEntity, CDataCharacterListElement)> list = new(); + + bool isTransaction = connectionIn is not null; + TCon connection = (TCon)(connectionIn ?? OpenNewConnection()); + try + { + ExecuteReader( + connection, + SqlSelectFullContactsByCharacterId, + command => + { + AddParameter(command, "@character_id", characterId); + }, + reader => + { + while (reader.Read()) + { + var contactListEntity = ReadContactListEntity(reader); + var characterListElement = new CDataCharacterListElement(); + + characterListElement.CommunityCharacterBaseInfo.CharacterId = GetUInt32(reader, "other_id"); + characterListElement.CommunityCharacterBaseInfo.CharacterName.FirstName = GetString(reader, "first_name"); + characterListElement.CommunityCharacterBaseInfo.CharacterName.LastName = GetString(reader, "last_name"); + characterListElement.CommunityCharacterBaseInfo.ClanName = GetStringNullable(reader, "clan_name") ?? string.Empty; + characterListElement.CurrentJobBaseInfo.Job = (JobId)GetByte(reader, "job"); + characterListElement.CurrentJobBaseInfo.Level = GetByte(reader, "lv"); + characterListElement.EntryJobBaseInfo = characterListElement.CurrentJobBaseInfo; + characterListElement.MatchingProfile = GetString(reader, "comment"); + + list.Add((contactListEntity, characterListElement)); + } + }); + } + finally + { + if (!isTransaction) connection.Dispose(); + } + + return list; + } + private ContactListEntity ReadContactListEntity(TReader reader) { ContactListEntity e = new ContactListEntity(); diff --git a/Arrowgene.Ddon.GameServer/Characters/ContactListManager.cs b/Arrowgene.Ddon.GameServer/Characters/ContactListManager.cs index 3bcc84720..d1bddfb1d 100644 --- a/Arrowgene.Ddon.GameServer/Characters/ContactListManager.cs +++ b/Arrowgene.Ddon.GameServer/Characters/ContactListManager.cs @@ -65,7 +65,7 @@ public static CDataFriendInfo CharacterToFriend(Character c, uint unFriendNo, bo { IsFavorite = isFavorite, PendingStatus = 0x00, // TODO - UnFriendNo = unFriendNo, + FriendNo = unFriendNo, CharacterListElement = CharacterToListEml(c) }; diff --git a/Arrowgene.Ddon.GameServer/Handler/CharacterCommunityCharacterStatusGetHandler.cs b/Arrowgene.Ddon.GameServer/Handler/CharacterCommunityCharacterStatusGetHandler.cs index 89fe0f9c5..eb5d0a7b8 100644 --- a/Arrowgene.Ddon.GameServer/Handler/CharacterCommunityCharacterStatusGetHandler.cs +++ b/Arrowgene.Ddon.GameServer/Handler/CharacterCommunityCharacterStatusGetHandler.cs @@ -1,60 +1,59 @@ -using System.Collections.Generic; -using Arrowgene.Ddon.GameServer.Characters; using Arrowgene.Ddon.Server; using Arrowgene.Ddon.Shared.Entity.PacketStructure; using Arrowgene.Ddon.Shared.Entity.Structure; using Arrowgene.Ddon.Shared.Model; -using Arrowgene.Ddon.Shared.Network; using Arrowgene.Logging; +using System.Collections.Generic; namespace Arrowgene.Ddon.GameServer.Handler { - public class CharacterCommunityCharacterStatusGetHandler : GameStructurePacketHandler + public class CharacterCommunityCharacterStatusGetHandler : GameRequestPacketHandler { private static readonly ServerLogger Logger = LogProvider.Logger(typeof(CharacterCommunityCharacterStatusGetHandler)); - public CharacterCommunityCharacterStatusGetHandler(DdonGameServer server) : base(server) { } - // public override PacketId Id => PacketId.C2S_CHARACTER_COMMUNITY_CHARACTER_STATUS_GET_REQ; - - public override void Handle(GameClient client, StructurePacket packet) + public override S2CCharacterCommunityCharacterStatusGetRes Handle(GameClient client, C2SCharacterCommunityCharacterStatusGetReq request) { - // client.Send(InGameDump.Dump_65); - List updateCharacterList = new List(); List updateMatchingProfileList = new List(); - - List friends = Database.SelectContactsByCharacterId(client.Character.CharacterId); - - foreach (var f in friends) + + List<(ContactListEntity, CDataCharacterListElement)> friends = Database.SelectFullContactListByCharacterId(client.Character.CharacterId); + + foreach ((ContactListEntity contact, CDataCharacterListElement character) in friends) { - if (f.Type != ContactListType.FriendList || f.Status != ContactListStatus.Accepted) + if (contact.Type != ContactListType.FriendList || contact.Status != ContactListStatus.Accepted) { continue; } - Character otherCharacter = - ContactListManager.getCharWithOnlineStatus(Server,Database, f.GetOtherCharacterId(client.Character.CharacterId)); - updateCharacterList.Add(ContactListManager.CharacterToListEml(otherCharacter)); + + var matchClient = Server.ClientLookup.GetClientByCharacterId(character.CommunityCharacterBaseInfo.CharacterId); + if (matchClient != null) + { + character.OnlineStatus = matchClient.Character?.OnlineStatus ?? OnlineStatus.Offline; + character.ServerId = (ushort)Server.Id; + } + + updateCharacterList.Add(character); updateMatchingProfileList.Add(new CDataUpdateMatchingProfileInfo() { - CharacterId = otherCharacter.CharacterId, - Comment = otherCharacter.MatchingProfile.Comment + CharacterId = character.CommunityCharacterBaseInfo.CharacterId, + Comment = character.MatchingProfile, }); } - + client.Send(new S2CCharacterCommunityCharacterStatusUpdateNtc() { UpdateCharacterList = updateCharacterList, UpdateMatchingProfileList = updateMatchingProfileList }); - - client.Send(new S2CCharacterCommunityCharacterStatusGetRes() + + return new S2CCharacterCommunityCharacterStatusGetRes() { - Result = updateCharacterList.Count + 1 - }); + Result = (uint)(updateCharacterList.Count + 1) // ??? + }; } } } diff --git a/Arrowgene.Ddon.GameServer/Handler/FriendApplyFriendListHandler.cs b/Arrowgene.Ddon.GameServer/Handler/FriendApplyFriendListHandler.cs index 7ed21827c..11b5b7955 100644 --- a/Arrowgene.Ddon.GameServer/Handler/FriendApplyFriendListHandler.cs +++ b/Arrowgene.Ddon.GameServer/Handler/FriendApplyFriendListHandler.cs @@ -1,14 +1,13 @@ -using Arrowgene.Ddon.GameServer.Characters; +using Arrowgene.Ddon.GameServer.Characters; using Arrowgene.Ddon.Server; using Arrowgene.Ddon.Shared.Entity.PacketStructure; using Arrowgene.Ddon.Shared.Entity.Structure; using Arrowgene.Ddon.Shared.Model; -using Arrowgene.Ddon.Shared.Network; using Arrowgene.Logging; namespace Arrowgene.Ddon.GameServer.Handler { - public class FriendApplyFriendListHandler : GameStructurePacketHandler + public class FriendApplyFriendListHandler : GameRequestPacketHandler { private static readonly ServerLogger Logger = LogProvider.Logger(typeof(FriendApplyFriendListHandler)); @@ -17,70 +16,52 @@ public FriendApplyFriendListHandler(DdonGameServer server) : base(server) { } - public override void Handle(GameClient client, StructurePacket packet) + public override S2CFriendApplyFriendRes Handle(GameClient client, C2SFriendApplyFriendReq request) { - - ContactListEntity existingFriend = Server.Database.SelectContactsByCharacterId(packet.Structure.CharacterId, client.Character.CharacterId); + + ContactListEntity existingFriend = Server.Database.SelectContactsByCharacterId(request.CharacterId, client.Character.CharacterId); if (existingFriend != null) { - uint errorCode = (uint)ErrorCode.ERROR_CODE_FAIL; + ErrorCode errorCode = ErrorCode.ERROR_CODE_FAIL; if (existingFriend.Type == ContactListType.BlackList && client.Character.CharacterId == existingFriend.RequesterCharacterId) { - errorCode = (uint)ErrorCode.ERROR_CODE_FRIEND_TARGET_IN_BLACK_LIST; + errorCode = ErrorCode.ERROR_CODE_FRIEND_TARGET_IN_BLACK_LIST; } else if (existingFriend.Status == ContactListStatus.Accepted) { - errorCode = (uint)ErrorCode.ERROR_CODE_FRIEND_TARGET_ALREADY_FRIEND; + errorCode = ErrorCode.ERROR_CODE_FRIEND_TARGET_ALREADY_FRIEND; } else if (existingFriend.Status == ContactListStatus.PendingApproval && client.Character.CharacterId == existingFriend.RequesterCharacterId) { - errorCode = (uint)ErrorCode.ERROR_CODE_FRIEND_TARGET_ALREADY_APPLYING; + errorCode = ErrorCode.ERROR_CODE_FRIEND_TARGET_ALREADY_APPLYING; } else if (existingFriend.Status == ContactListStatus.PendingApproval && client.Character.CharacterId == existingFriend.RequestedCharacterId) { - errorCode = (uint)ErrorCode.ERROR_CODE_FRIEND_TARGET_ALREADY_APPROVING; + errorCode = ErrorCode.ERROR_CODE_FRIEND_TARGET_ALREADY_APPROVING; } - var res = new S2CFriendApplyFriendRes() - { - FriendInfo = new CDataFriendInfo(), - Error = errorCode - }; - Logger.Error(client, $"already in contact list: {packet.Structure.CharacterId} - friend invitation"); - client.Send(res); - return; - } - - Character requestedChar = ContactListManager.getCharWithOnlineStatus(Server, Database, packet.Structure.CharacterId); - if (requestedChar == null) - { - var res = new S2CFriendApplyFriendRes(); - Logger.Error(client, $"not found CharacterId:{packet.Structure.CharacterId} for friend invitation"); - res.Error = (uint)ErrorCode.ERROR_CODE_FRIEND_TARGET_PARAM_NOT_FOUND; - client.Send(res); - return; + + throw new ResponseErrorException(errorCode, $"already in contact list: {request.CharacterId} - friend invitation."); } + Character requestedChar = Server.ClientLookup.GetClientByCharacterId(request.CharacterId)?.Character + ?? ContactListManager.getCharWithOnlineStatus(Server, Database, request.CharacterId) + ?? throw new ResponseErrorException(ErrorCode.ERROR_CODE_FRIEND_TARGET_PARAM_NOT_FOUND, $"not found CharacterId:{request.CharacterId} for friend invitation."); + int id = Database.InsertContact(client.Character.CharacterId, requestedChar.CharacterId, ContactListStatus.PendingApproval, ContactListType.FriendList, false, false); - + if (id < 1) { - var res = new S2CFriendApplyFriendRes() - { - FriendInfo = new CDataFriendInfo() - }; - Logger.Error(client, $"Problem saving friend request"); - res.Error = (uint)ErrorCode.ERROR_CODE_FAIL; - client.Send(res); - return; + throw new ResponseErrorException(ErrorCode.ERROR_CODE_FAIL, $"Problem saving friend request."); } + CDataFriendInfo requester = ContactListManager.CharacterToFriend(client.Character, (uint)id, false); CDataFriendInfo requested = ContactListManager.CharacterToFriend(requestedChar, (uint)id, false); - requester.UnFriendNo = (uint)id; - requested.UnFriendNo = (uint)id; + requester.FriendNo = (uint)id; + requested.FriendNo = (uint)id; - GameClient requestedClient = Server.ClientLookup.GetClientByCharacterId(packet.Structure.CharacterId); + GameClient requestedClient = Server.ClientLookup.GetClientByCharacterId(request.CharacterId); if (requestedClient != null) { var ntc = new S2CFriendApplyFriendNtc() @@ -90,16 +71,10 @@ public override void Handle(GameClient client, StructurePacket + public class FriendGetFriendListHandler : GameRequestPacketHandler { private static readonly ServerLogger Logger = LogProvider.Logger(typeof(FriendGetFriendListHandler)); - public FriendGetFriendListHandler(DdonGameServer server) : base(server) { } - public override PacketId Id => PacketId.C2S_FRIEND_GET_FRIEND_LIST_REQ; - - public override void Handle(GameClient client, IPacket packet) + public override S2CFriendGetFriendListRes Handle(GameClient client, C2SFriendGetFriendListReq request) { - // client.Send(InGameDump.Dump_60); - List fList = new List(); - List applList = new List(); - List apprList = new List(); - List friends = Database.SelectContactsByCharacterId(client.Character.CharacterId); - - foreach (var f in friends) + + S2CFriendGetFriendListRes res = new(); + + List<(ContactListEntity, CDataCharacterListElement)> friends = Database.SelectFullContactListByCharacterId(client.Character.CharacterId); + + foreach ((ContactListEntity contact, CDataCharacterListElement character) in friends) { - if (f.Type != ContactListType.FriendList) + if (contact.Type != ContactListType.FriendList) { continue; } - Character otherCharacter = - Database.SelectCharacter(f.GetOtherCharacterId(client.Character.CharacterId)); - - if (f.Status == ContactListStatus.Accepted) + + if (contact.Status == ContactListStatus.Accepted) { - fList.Add(ContactListManager.CharacterToFriend(otherCharacter, f.Id, f.IsFavoriteForCharacter(client.Character.CharacterId))); - } - else if (f.Status == ContactListStatus.PendingApproval) + res.FriendInfoList.Add(new CDataFriendInfo() + { + CharacterListElement = character, + PendingStatus = 0, // TODO + IsFavorite = contact.IsFavoriteForCharacter(client.Character.CharacterId), + FriendNo = contact.Id, + }); + } + else if (contact.Status == ContactListStatus.PendingApproval) { - if (f.RequesterCharacterId == client.Character.CharacterId) + if (contact.RequesterCharacterId == client.Character.CharacterId) { - applList.Add(ContactListManager.CharacterToCommunityInfo(otherCharacter)); + res.ApplyingCharacterList.Add(character.CommunityCharacterBaseInfo); } - else if (f.RequestedCharacterId == client.Character.CharacterId) + else if (contact.RequestedCharacterId == client.Character.CharacterId) { - apprList.Add(ContactListManager.CharacterToCommunityInfo(otherCharacter)); + res.ApprovingCharacterList.Add(character.CommunityCharacterBaseInfo); } } } - - var result = new S2CFriendGetFriendListRes() - { - FriendInfoList = fList, - ApplyingCharacterList = applList, - ApprovingCharacterList = apprList, - Result = 0, - Error = 0, - - }; - - client.Send(result); + return res; } } } diff --git a/Arrowgene.Ddon.GameServer/Handler/FriendRegisterFavoriteFriendHandler.cs b/Arrowgene.Ddon.GameServer/Handler/FriendRegisterFavoriteFriendHandler.cs index 203d0020d..09b94070d 100644 --- a/Arrowgene.Ddon.GameServer/Handler/FriendRegisterFavoriteFriendHandler.cs +++ b/Arrowgene.Ddon.GameServer/Handler/FriendRegisterFavoriteFriendHandler.cs @@ -1,4 +1,4 @@ -using Arrowgene.Ddon.Server; +using Arrowgene.Ddon.Server; using Arrowgene.Ddon.Shared.Entity.PacketStructure; using Arrowgene.Ddon.Shared.Model; using Arrowgene.Ddon.Shared.Network; @@ -6,7 +6,7 @@ namespace Arrowgene.Ddon.GameServer.Handler { - public class FriendRegisterFavoriteFriendHandler : GameStructurePacketHandler + public class FriendRegisterFavoriteFriendHandler : GameRequestPacketHandler { private static readonly ServerLogger Logger = LogProvider.Logger(typeof(FriendRegisterFavoriteFriendHandler)); @@ -15,32 +15,19 @@ public FriendRegisterFavoriteFriendHandler(DdonGameServer server) : base(server) { } - public override void Handle(GameClient client, StructurePacket packet) + public override S2CFriendRegisterFavoriteFriendRes Handle(GameClient client, C2SFriendRegisterFavoriteFriendReq request) { - ContactListEntity r = Database.SelectContactListById(packet.Structure.unFriendNo); - if (r == null) - { - Logger.Error(client, $"ContactListEntity not found"); - client.Send( - new S2CFriendRegisterFavoriteFriendRes() - { - Result = -1, - Error = (uint)ErrorCode.ERROR_CODE_FRIEND_INVARID_FRIEND_NO - } - ); - return; - } - - r.SetFavoriteForCharacter(client.Character.CharacterId, packet.Structure.isFavorite); + ContactListEntity r = Database.SelectContactListById(request.FriendNo) + ?? throw new ResponseErrorException(ErrorCode.ERROR_CODE_FRIEND_INVARID_FRIEND_NO, "ContactListEntity not found"); + + r.SetFavoriteForCharacter(client.Character.CharacterId, request.IsFavorite); Database.UpdateContact(r.RequesterCharacterId, r.RequestedCharacterId, r.Status, r.Type, r.RequesterFavorite, r.RequestedFavorite); - - client.Send( - new S2CFriendRegisterFavoriteFriendRes() - { - Result = 1 - } - ); + + return new S2CFriendRegisterFavoriteFriendRes() + { + Result = 1 + }; } } } diff --git a/Arrowgene.Ddon.GameServer/Handler/FriendRemoveFriendHandler.cs b/Arrowgene.Ddon.GameServer/Handler/FriendRemoveFriendHandler.cs index 63d644613..e94f39dbb 100644 --- a/Arrowgene.Ddon.GameServer/Handler/FriendRemoveFriendHandler.cs +++ b/Arrowgene.Ddon.GameServer/Handler/FriendRemoveFriendHandler.cs @@ -1,69 +1,45 @@ -using Arrowgene.Ddon.Server; +using Arrowgene.Ddon.Server; using Arrowgene.Ddon.Shared.Entity.PacketStructure; using Arrowgene.Ddon.Shared.Model; -using Arrowgene.Ddon.Shared.Network; using Arrowgene.Logging; namespace Arrowgene.Ddon.GameServer.Handler { - public class FriendRemoveFriendHandler : GameStructurePacketHandler - { - private static readonly ServerLogger Logger = LogProvider.Logger(typeof(FriendRemoveFriendHandler)); + public class FriendRemoveFriendHandler : GameRequestPacketHandler + { + private static readonly ServerLogger Logger = LogProvider.Logger(typeof(FriendRemoveFriendHandler)); - public FriendRemoveFriendHandler(DdonGameServer server) : base(server) - { - } + public FriendRemoveFriendHandler(DdonGameServer server) : base(server) + { + } - public override void Handle(GameClient client, StructurePacket packet) - { + public override S2CFriendRemoveFriendRes Handle(GameClient client, C2SFriendRemoveFriendReq request) + { - ContactListEntity relationship = Database.SelectContactListById(packet.Structure.unFriendNo); - if (relationship == null) - { - Logger.Error(client, $"ContactListEntity not found"); - client.Send( - new S2CFriendRemoveFriendRes() - { - Result = -1, - Error = (uint)ErrorCode.ERROR_CODE_FRIEND_INVARID_FRIEND_NO - } - ); - return; - } + ContactListEntity relationship = Database.SelectContactListById(request.FriendNo) + ?? throw new ResponseErrorException(ErrorCode.ERROR_CODE_FRIEND_INVARID_FRIEND_NO, "ContactListEntity not found"); - if (Database.DeleteContactById(relationship.Id) < 1) - { - Logger.Error(client, $"Problem deleting contact"); - client.Send( - new S2CFriendRemoveFriendRes() - { - Result = -1, - Error = (uint)ErrorCode.ERROR_CODE_FRIEND_INVARID_FRIEND_NO - } - ); - return; - } - - client.Send( - new S2CFriendRemoveFriendRes() - { - Result = 1 - } - ); + if (Database.DeleteContactById(relationship.Id) < 1) + { + throw new ResponseErrorException(ErrorCode.ERROR_CODE_FRIEND_INVARID_FRIEND_NO, "Problem deleting contact"); + } - uint otherCharId = relationship.GetOtherCharacterId(client.Character.CharacterId); - - GameClient otherClient = Server.ClientLookup.GetClientByCharacterId(otherCharId); - if (otherClient != null) - { - otherClient.Send( - new S2CFriendRemoveFriendNtc() - { - CharacterId = client.Character.CharacterId - } - ); - } - } - } + uint otherCharId = relationship.GetOtherCharacterId(client.Character.CharacterId); + + GameClient otherClient = Server.ClientLookup.GetClientByCharacterId(otherCharId); + if (otherClient != null) + { + otherClient.Send(new S2CFriendRemoveFriendNtc() + { + CharacterId = client.Character.CharacterId + }); + } + + return new S2CFriendRemoveFriendRes() + { + Result = 1 + }; + } + } } diff --git a/Arrowgene.Ddon.Shared/Entity/EntitySerializer.cs b/Arrowgene.Ddon.Shared/Entity/EntitySerializer.cs index a18441773..e3f18bc1d 100644 --- a/Arrowgene.Ddon.Shared/Entity/EntitySerializer.cs +++ b/Arrowgene.Ddon.Shared/Entity/EntitySerializer.cs @@ -803,6 +803,7 @@ static EntitySerializer() Create(new C2SFriendRemoveFriendReq.Serializer()); Create(new C2SFriendRegisterFavoriteFriendReq.Serializer()); Create(new C2SFriendCancelFriendApplicationReq.Serializer()); + Create(new C2SFriendGetFriendListReq.Serializer()); Create(new C2SCharacterCommunityCharacterStatusGetReq.Serializer()); Create(new C2SBinarySaveSetCharacterBinSaveDataReq.Serializer()); diff --git a/Arrowgene.Ddon.Shared/Entity/PacketStructure/C2SFriendGetFriendListReq.cs b/Arrowgene.Ddon.Shared/Entity/PacketStructure/C2SFriendGetFriendListReq.cs new file mode 100644 index 000000000..200d4bdbc --- /dev/null +++ b/Arrowgene.Ddon.Shared/Entity/PacketStructure/C2SFriendGetFriendListReq.cs @@ -0,0 +1,24 @@ +using Arrowgene.Buffers; +using Arrowgene.Ddon.Shared.Network; + +namespace Arrowgene.Ddon.Shared.Entity.PacketStructure +{ + public class C2SFriendGetFriendListReq : IPacketStructure + { + public PacketId Id => PacketId.C2S_FRIEND_GET_FRIEND_LIST_REQ; + + public class Serializer : PacketEntitySerializer + { + public override void Write(IBuffer buffer, C2SFriendGetFriendListReq obj) + { + } + + public override C2SFriendGetFriendListReq Read(IBuffer buffer) + { + C2SFriendGetFriendListReq obj = new C2SFriendGetFriendListReq(); + return obj; + } + } + + } +} diff --git a/Arrowgene.Ddon.Shared/Entity/PacketStructure/C2SFriendRegisterFavoriteFriendReq.cs b/Arrowgene.Ddon.Shared/Entity/PacketStructure/C2SFriendRegisterFavoriteFriendReq.cs index 424dfce75..2bd8874aa 100644 --- a/Arrowgene.Ddon.Shared/Entity/PacketStructure/C2SFriendRegisterFavoriteFriendReq.cs +++ b/Arrowgene.Ddon.Shared/Entity/PacketStructure/C2SFriendRegisterFavoriteFriendReq.cs @@ -10,22 +10,22 @@ public class C2SFriendRegisterFavoriteFriendReq : IPacketStructure { public PacketId Id => PacketId.C2S_FRIEND_REGISTER_FAVORITE_FRIEND_REQ; - public UInt32 unFriendNo { get; set; } - public bool isFavorite { get; set; } + public uint FriendNo { get; set; } + public bool IsFavorite { get; set; } public class Serializer : PacketEntitySerializer { public override void Write(IBuffer buffer, C2SFriendRegisterFavoriteFriendReq obj) { - WriteUInt32(buffer, obj.unFriendNo); - WriteBool(buffer, obj.isFavorite); + WriteUInt32(buffer, obj.FriendNo); + WriteBool(buffer, obj.IsFavorite); } public override C2SFriendRegisterFavoriteFriendReq Read(IBuffer buffer) { C2SFriendRegisterFavoriteFriendReq obj = new C2SFriendRegisterFavoriteFriendReq(); - obj.unFriendNo = ReadUInt32(buffer); - obj.isFavorite = ReadBool(buffer); + obj.FriendNo = ReadUInt32(buffer); + obj.IsFavorite = ReadBool(buffer); return obj; } } diff --git a/Arrowgene.Ddon.Shared/Entity/PacketStructure/C2SFriendRemoveFriendReq.cs b/Arrowgene.Ddon.Shared/Entity/PacketStructure/C2SFriendRemoveFriendReq.cs index bafc149a0..eb363f46c 100644 --- a/Arrowgene.Ddon.Shared/Entity/PacketStructure/C2SFriendRemoveFriendReq.cs +++ b/Arrowgene.Ddon.Shared/Entity/PacketStructure/C2SFriendRemoveFriendReq.cs @@ -10,19 +10,19 @@ public class C2SFriendRemoveFriendReq : IPacketStructure { public PacketId Id => PacketId.C2S_FRIEND_REMOVE_FRIEND_REQ; - public UInt32 unFriendNo { get; set; } + public uint FriendNo { get; set; } public class Serializer : PacketEntitySerializer { public override void Write(IBuffer buffer, C2SFriendRemoveFriendReq obj) { - WriteUInt32(buffer, obj.unFriendNo); + WriteUInt32(buffer, obj.FriendNo); } public override C2SFriendRemoveFriendReq Read(IBuffer buffer) { C2SFriendRemoveFriendReq obj = new C2SFriendRemoveFriendReq(); - obj.unFriendNo = ReadUInt32(buffer); + obj.FriendNo = ReadUInt32(buffer); return obj; } } diff --git a/Arrowgene.Ddon.Shared/Entity/PacketStructure/S2CCharacterCommunityCharacterStatusGetRes.cs b/Arrowgene.Ddon.Shared/Entity/PacketStructure/S2CCharacterCommunityCharacterStatusGetRes.cs index 6b49df646..9989b35f9 100644 --- a/Arrowgene.Ddon.Shared/Entity/PacketStructure/S2CCharacterCommunityCharacterStatusGetRes.cs +++ b/Arrowgene.Ddon.Shared/Entity/PacketStructure/S2CCharacterCommunityCharacterStatusGetRes.cs @@ -1,27 +1,23 @@ -using System; using Arrowgene.Buffers; -using Arrowgene.Ddon.Shared.Entity.Structure; using Arrowgene.Ddon.Shared.Network; namespace Arrowgene.Ddon.Shared.Entity.PacketStructure { - public class S2CCharacterCommunityCharacterStatusGetRes : IPacketStructure + public class S2CCharacterCommunityCharacterStatusGetRes : ServerResponse { - public PacketId Id => PacketId.S2C_CHARACTER_COMMUNITY_CHARACTER_STATUS_GET_RES; - public Int32 Result { get; set; } - + public override PacketId Id => PacketId.S2C_CHARACTER_COMMUNITY_CHARACTER_STATUS_GET_RES; public class Serializer : PacketEntitySerializer { public override void Write(IBuffer buffer, S2CCharacterCommunityCharacterStatusGetRes obj) { - WriteInt32(buffer, obj.Result); + WriteServerResponse(buffer, obj); } public override S2CCharacterCommunityCharacterStatusGetRes Read(IBuffer buffer) { S2CCharacterCommunityCharacterStatusGetRes obj = new S2CCharacterCommunityCharacterStatusGetRes(); - obj.Result = ReadInt32(buffer); + ReadServerResponse(buffer, obj); return obj; } diff --git a/Arrowgene.Ddon.Shared/Entity/PacketStructure/S2CFriendGetFriendListRes.cs b/Arrowgene.Ddon.Shared/Entity/PacketStructure/S2CFriendGetFriendListRes.cs index 168766e1e..b1623d7a7 100644 --- a/Arrowgene.Ddon.Shared/Entity/PacketStructure/S2CFriendGetFriendListRes.cs +++ b/Arrowgene.Ddon.Shared/Entity/PacketStructure/S2CFriendGetFriendListRes.cs @@ -1,16 +1,19 @@ using Arrowgene.Buffers; -using Arrowgene.Ddon.Shared.Model; +using Arrowgene.Ddon.Shared.Entity.Structure; using Arrowgene.Ddon.Shared.Network; -using Arrowgene.Logging; -using System; using System.Collections.Generic; -using System.Net.Sockets; -using Arrowgene.Ddon.Shared.Entity.Structure; namespace Arrowgene.Ddon.Shared.Entity.PacketStructure { public class S2CFriendGetFriendListRes : ServerResponse { + public S2CFriendGetFriendListRes() + { + FriendInfoList = new(); + ApplyingCharacterList = new(); + ApprovingCharacterList = new(); + } + public override PacketId Id => PacketId.S2C_FRIEND_GET_FRIEND_LIST_RES; public List FriendInfoList { get; set; } diff --git a/Arrowgene.Ddon.Shared/Entity/Structure/CDataFriendInfo.cs b/Arrowgene.Ddon.Shared/Entity/Structure/CDataFriendInfo.cs index e1b9e888f..c3f23c262 100644 --- a/Arrowgene.Ddon.Shared/Entity/Structure/CDataFriendInfo.cs +++ b/Arrowgene.Ddon.Shared/Entity/Structure/CDataFriendInfo.cs @@ -1,14 +1,18 @@ -using System; using Arrowgene.Buffers; namespace Arrowgene.Ddon.Shared.Entity.Structure { public class CDataFriendInfo { - public CDataCharacterListElement CharacterListElement { get; set; } = new(); - public byte PendingStatus { get; set; } = 0; - public UInt32 UnFriendNo { get; set; } = 0; - public bool IsFavorite { get; set; } = false; + public CDataFriendInfo() + { + CharacterListElement = new(); + } + + public CDataCharacterListElement CharacterListElement { get; set; } + public byte PendingStatus { get; set; } + public uint FriendNo { get; set; } + public bool IsFavorite { get; set; } public class Serializer : EntitySerializer { @@ -16,7 +20,7 @@ public override void Write(IBuffer buffer, CDataFriendInfo obj) { WriteEntity(buffer, obj.CharacterListElement); WriteByte(buffer, obj.PendingStatus); - WriteUInt32(buffer, obj.UnFriendNo); + WriteUInt32(buffer, obj.FriendNo); WriteBool(buffer, obj.IsFavorite); } @@ -25,7 +29,7 @@ public override CDataFriendInfo Read(IBuffer buffer) CDataFriendInfo obj = new CDataFriendInfo(); obj.CharacterListElement = ReadEntity(buffer); obj.PendingStatus = ReadByte(buffer); - obj.UnFriendNo = ReadUInt32(buffer); + obj.FriendNo = ReadUInt32(buffer); obj.IsFavorite = ReadBool(buffer); return obj; } diff --git a/Arrowgene.Ddon.Test/Database/DatabaseMigratorTest.cs b/Arrowgene.Ddon.Test/Database/DatabaseMigratorTest.cs index f8dd065a8..57ae6f742 100644 --- a/Arrowgene.Ddon.Test/Database/DatabaseMigratorTest.cs +++ b/Arrowgene.Ddon.Test/Database/DatabaseMigratorTest.cs @@ -289,6 +289,7 @@ public void Execute(DbConnection conn, string sql) {} public ContactListEntity SelectContactListById(uint id) { return new ContactListEntity(); } public List SelectContactsByCharacterId(uint characterId) { return new List(); } public ContactListEntity SelectContactsByCharacterId(uint characterId1, uint characterId2) { return new ContactListEntity(); } + public List<(ContactListEntity, CDataCharacterListElement)> SelectFullContactListByCharacterId(uint characterId, DbConnection? connectionIn = null) { return new(); } public Item SelectStorageItemByUId(string uId, DbConnection? connectionIn = null) { return new Item(); } public List SelectNormalSkillParam(uint commonId, JobId job) { return new List(); } public CDataOrbGainExtendParam SelectOrbGainExtendParam(uint commonId) { return new CDataOrbGainExtendParam(); }