From 5dfab238fab15e58bd9bc3799efe8c066bfac923 Mon Sep 17 00:00:00 2001 From: HungDK <> Date: Mon, 16 Mar 2026 17:39:30 +0700 Subject: [PATCH] Update UnityGameSession.cs --- .../Scripts/Network/UnityGameSession.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs b/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs index 4c3501d56f..5d024ef10c 100644 --- a/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs +++ b/Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs @@ -163,6 +163,9 @@ namespace BrewMonster.Network { BaseSecurity.Initizalize(); ProtocolFactory.RegisterAllProtocols(); + // Type 204 is used for both addfriendrqst (server→client request) and addfriendrqstres (client→server response). + // Client only receives addfriendrqst; ensure decode uses it so we don't get InvalidCastException. + Protocol.Register((uint)ProtocolType.RPC_ADDFRIENDRQST); _gameSession = new GameSession(); #if UNITY_EDITOR var path = Application.dataPath.Substring(0, Application.dataPath.LastIndexOf("Assets")); @@ -633,6 +636,10 @@ namespace BrewMonster.Network { Instance._gameSession.Friend_GetList(); } + public static void Friend_AddResponse(uint xid, bool agree) + { + Instance._gameSession.Friend_AddResponse(xid, agree); + } public static void c2s_CmdTeamKickMember(int idMember) { Instance._gameSession.c2s_SendCmdTeamKickMember(idMember); @@ -708,15 +715,15 @@ namespace BrewMonster.Network /// /// Handles unexpected server disconnections. Shows a message box and returns to login. /// - private void OnFriendRequestReceived(int srcroleid, string askerName) + private void OnFriendRequestReceived(uint xid, int srcroleid, string askerName) { string name = string.IsNullOrEmpty(askerName) ? ("Player " + srcroleid) : askerName; CECUIManager.Instance?.ShowMessageBox( title: "Friend Request", message: $"{name} wants to add you as a friend.", messageBoxType: MessageBoxType.BothYesNoButton, - onClickedYes: () => { /* TODO: accept and call friend_AddResponse */ }, - onClickedNo: () => { /* TODO: refuse */ }); + onClickedYes: () => Friend_AddResponse(xid, agree: true), + onClickedNo: () => Friend_AddResponse(xid, agree: false)); } private void OnAddFriendResultReceived(byte retcode, string message)