Beispiel #1
0
        public void ClientDisConnect(ulong roleId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            //清理干净角色后,返回给DS玩家的PlayerData
            Planes.PlayerInstance player = Planes.PlanesServerDataManager.Instance.FindPlayerInstance(roleId);
            if (player == null)
            {
                Log.Log.Server.Print("ClientDisConnect:找不到角色");
                return;
            }
            Planes.MapInstance    map    = player.HostMap;
            Planes.PlanesInstance planes = player.PlanesInstance;

            if (map != null)
            {
                planes = player.PlanesInstance;
                map.PlayerLeaveMap(player, true);//退出地图,并且存盘
            }
            else
            {
                Log.Log.Server.Print("ClientDisConnect:找不到地图");
                return;
            }

            if (planes != null)
            {
                planes.LeavePlanes(roleId);//退出位面
            }
            else
            {
                Log.Log.Server.Print("ClientDisConnect:位面ID不正确");
                return;
            }

            Planes.PlanesServerDataManager.Instance.RemovePlayerInstance(player);//退出服务器

            //客户端连接断开,需要告诉数据服务器,登出账号
            RPC.PackageWriter pkg0 = new RPC.PackageWriter();
            H_RPCRoot.smInstance.HGet_DataServer(pkg0).HGet_PlayerManager(pkg0).LogoutAccount(pkg0, player.AccountId, (sbyte)eServerType.Planes);
            pkg0.DoCommand(mDataConnect, RPC.CommandTargetType.DefaultType);

            return;
        }
Beispiel #2
0
        public void ReturnToRoleSelect(ulong planesId, ulong roleId, ulong accountId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {//这里的fwd只能用ReturnSerialId
            Planes.PlayerInstance player = Planes.PlanesServerDataManager.Instance.FindPlayerInstance(roleId);
            if (player == null)
            {
                RPC.PackageWriter retPkg = new RPC.PackageWriter();
                retPkg.Write((sbyte)-1);//找不到角色
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            Planes.MapInstance    map    = player.HostMap;
            Planes.PlanesInstance planes = null;

            if (map != null)
            {
                planes = map.Planes;
                map.PlayerLeaveMap(player, true);//退出地图
            }
            else
            {
                RPC.PackageWriter retPkg = new RPC.PackageWriter();
                retPkg.Write((sbyte)-2);//找不到地图
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }

            if (planes != null)
            {
                planes.LeavePlanes(roleId);//退出位面
            }
            else
            {
                RPC.PackageWriter retPkg = new RPC.PackageWriter();
                retPkg.Write((sbyte)-3);//位面ID不正确
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }

            Planes.PlanesServerDataManager.Instance.RemovePlayerInstance(player);//退出服务器

            UInt16 SavedReturnSerialId = fwd.ReturnSerialId;

            RPC.PackageWriter pkg = new RPC.PackageWriter();
            H_RPCRoot.smInstance.HGet_DataServer(pkg).HGet_PlayerManager(pkg).LogoutRole(pkg, roleId, player.PlayerData);
            pkg.WaitDoCommand(mDataConnect, RPC.CommandTargetType.DefaultType, new System.Diagnostics.StackTrace(1, true)).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut)
            {
                sbyte successed = -1;
                _io.Read(out successed);

                RPC.PackageWriter retPkg = new RPC.PackageWriter();
                switch (successed)
                {
                case -1:
                    retPkg.Write((sbyte)-2);    //数据服务器LogoutPlayer失败
                    retPkg.DoReturnCommand2(connect, SavedReturnSerialId);
                    break;

                case 1:
                case 2:
                    retPkg.Write((sbyte)1);
                    retPkg.DoReturnCommand2(connect, SavedReturnSerialId);
                    break;

                default:
                    retPkg.Write((sbyte)2);
                    retPkg.DoReturnCommand2(connect, SavedReturnSerialId);
                    break;
                }
            };
        }