From 32cb5229700ec3641ae1ad4e31d2e157a85a77d7 Mon Sep 17 00:00:00 2001 From: NguyenVanDat Date: Fri, 27 Feb 2026 11:09:47 +0700 Subject: [PATCH] add logic player exit game --- Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs | 10 ++++++++++ .../Scripts/Network/CSNetwork/GPDataType.cs | 7 +++++++ .../Scripts/Network/CSNetwork/GameSession.cs | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs b/Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs index 8c93446808..f387e0a2ca 100644 --- a/Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs +++ b/Assets/PerfectWorld/Scripts/Managers/EC_ManPlayer.cs @@ -109,6 +109,9 @@ namespace PerfectWorld.Scripts.Managers } TransmitMessage(Msg); break; + case EC_MsgDef.MSG_PM_PLAYEREXIT: + OnMsgPlayerExit(Msg); + break; } } else @@ -819,6 +822,13 @@ namespace PerfectWorld.Scripts.Managers } } } + // Handler of MSG_PM_PLAYEREXIT + public bool OnMsgPlayerExit(ECMSG Msg) + { + cmd_player_leave_world pCmd = GPDataTypeHelper.FromBytes((byte[])Msg.dwParam1); + ElsePlayerLeave(pCmd.id, true); + return true; + } } } public struct EC_PLAYERLOADRESULT diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs index d661617ad6..a2f2c05aea 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs @@ -2589,5 +2589,12 @@ namespace CSNetwork.GPDataType public ushort equip_idx; public uint cost; }; + + // player leaves the world + [StructLayout(LayoutKind.Sequential, Pack = 1)] + public struct cmd_player_leave_world + { + public int id; + }; } diff --git a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs index 9829b93d88..9556956883 100644 --- a/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs +++ b/Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs @@ -1140,6 +1140,15 @@ namespace CSNetwork case CommandID.CLEAR_TESSERA: EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_CLEARTESSERA, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader); break; + case CommandID.PLAYER_LEAVE_WORLD: + { + cmd_player_leave_world pCmd = GPDataTypeHelper.FromBytes(pDataBuf); + if (ISPLAYERID(pCmd.id)) + { + EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYEREXIT, MANAGER_INDEX.MAN_PLAYER, -1, pDataBuf, pCmdHeader); + } + break; + } default: #if UNITY_EDITOR if (isDebug)