Merge branch 'develop' into feature/elseplayer

# Conflicts:
#	Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs
#	Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs
#	Assets/PerfectWorld/Scripts/UI/GamePlay/EC_GameUIMan.cs
This commit is contained in:
Tungdv
2026-03-18 12:54:34 +07:00
175 changed files with 17992 additions and 1722 deletions
@@ -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<addfriendrqst>((uint)ProtocolType.RPC_ADDFRIENDRQST);
_gameSession = new GameSession();
#if UNITY_EDITOR
var path = Application.dataPath.Substring(0, Application.dataPath.LastIndexOf("Assets"));
@@ -173,7 +176,9 @@ namespace BrewMonster.Network
// Subscribe to unexpected disconnects
_gameSession.Disconnected += OnUnexpectedDisconnect;
_gameSession.FriendRequestReceived += OnFriendRequestReceived;
_gameSession.AddFriendResultReceived += OnAddFriendResultReceived;
_isInitialized = true;
DontDestroyOnLoad(gameObject);
@@ -184,6 +189,8 @@ namespace BrewMonster.Network
// Tell LoginScene what to show next.
LogoutFlowState.NextLoginEntry = entryTarget;
_gameSession.Disconnected -= OnUnexpectedDisconnect;
_gameSession.FriendRequestReceived -= OnFriendRequestReceived;
_gameSession.AddFriendResultReceived -= OnAddFriendResultReceived;
EC_ManMessageMono.Instance.CECNPCMan.Release();
if (clearSavedCreds)
@@ -632,6 +639,20 @@ namespace BrewMonster.Network
{
Instance._gameSession.c2s_SendCmdDuelReply(accept, idInviter);
}
/// <summary>Send PROTOCOL_ADDFRIEND(202). Port of CECGameSession::friend_Add.</summary>
public static void Friend_Add(int idPlayer, string name)
{
Instance._gameSession.Friend_Add(idPlayer, name ?? "");
}
/// <summary>Send PROTOCOL_GETFRIENDS(206). Port of CECGameSession::friend_GetList().</summary>
public static void Friend_GetList()
{
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);
@@ -712,6 +733,26 @@ namespace BrewMonster.Network
/// <summary>
/// Handles unexpected server disconnections. Shows a message box and returns to login.
/// </summary>
private void OnFriendRequestReceived(uint xid, int srcroleid, string askerName)
{
string name = string.IsNullOrEmpty(askerName) ? ("Player " + srcroleid) : askerName;
CECUIManager.Instance?.ShowMessageBoxYesAndNo(
title: "Friend Request",
message: $"{name} wants to add you as a friend.",
dlg: null,
onClickedYes: () => Friend_AddResponse(xid, agree: true),
onClickedNo: () => Friend_AddResponse(xid, agree: false));
}
private void OnAddFriendResultReceived(byte retcode, string message)
{
CECUIManager.Instance?.ShowMessageBoxYes(
title: retcode == 0 ? "Friend added" : "Add friend failed",
message: message,
dlg: null,
null);
}
private void OnUnexpectedDisconnect()
{
// If this was an intentional disconnect (logout), skip UI
@@ -722,16 +763,13 @@ namespace BrewMonster.Network
}
// Show disconnect message box
CECUIManager.Instance?.ShowMessageBox(
title: "Disconnected",
message: "Connection to the server has been lost.",
messageBoxType: MessageBoxType.YesButton,
onClickedYes: () =>
CECUIManager.Instance?.ShowMessageBoxYes("Disconnected", "Connection to the server has been lost.", null,
() =>
{
// Return to login screen
LogoutAccount();
}
);
});
}
public static void c2s_CmdGoto(float x, float y, float z)