Beispiel #1
0
        private void DB_RoleEnteInitMessages(UserRole role)//只有登录的时候调用
        {
            string condition = "OwnerId=" + role.RoleData.RoleId;

            ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.SelectData(condition, new CSCommon.Data.Message(), "");
            System.Data.DataTable     tab  = mDBConnect._ExecuteSelect(dbOp, "Message");
            if (tab != null)
            {
                foreach (System.Data.DataRow r in tab.Rows)
                {
                    CSCommon.Data.Message msg = new CSCommon.Data.Message();
                    if (false == ServerFrame.DB.DBConnect.FillObject(msg, r))
                    {
                        continue;
                    }
                    DB_DelMessage(msg);
                    //发送消息
                    RPC.PackageWriter pkg = new RPC.PackageWriter();
                    H_RPCRoot.smInstance.HGet_PlanesServer(pkg).RPC_SendPlayerMsg(pkg, role.RoleData.RoleId, msg);
                    pkg.DoCommand(role.PlanesConnect, RPC.CommandTargetType.DefaultType);
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("角色获取信息数据库执行失败:" + dbOp.SqlCode);
            }
        }
Beispiel #2
0
        public void Tick()
        {
            try
            {
                var lst = new List <ulong>();
                foreach (var i in mInstanceMaps)
                {
                    i.Value.Tick();
                    if (i.Value.NeedDestroy())
                    {
                        lst.Add(i.Key);
                    }
                }

                foreach (var i in lst)
                {
                    MapConnectInfo map;
                    if (mInstanceMaps.TryGetValue(i, out map))
                    {
                        //这里要RPC告诉位面,关闭这个副本
                        var pkg = new RPC.PackageWriter();
                        H_RPCRoot.smInstance.HGet_PlanesServer(pkg).RemoveInstanceMap(pkg, map.MapInstanceId);
                        pkg.DoCommand(map.mConnect.Connect, RPC.CommandTargetType.DefaultType);
                        mInstanceMaps.Remove(i);
                    }
                }
            }
            catch (Exception e)
            {
                Log.Log.Server.Error(e.ToString());
            }
        }
Beispiel #3
0
        public void LeavePlanes(ulong roleId)
        {
            OffPlayerData data = new OffPlayerData();

            lock (this)
            {
                var player = mPlayers[roleId];
                if (player != null)
                {
                    player.CalcAllOffValues();
                    data.value = player.FinalRoleValue;
                    var equip = player.EquipBag.FindItemByPos((int)CSCommon.eEquipType.Soul);
                    if (equip == null)
                    {
                        equip = player.EquipBag.FindItemByPos((int)CSCommon.eEquipType.Weapon);
                    }
                    data.WeapFacdeid = equip.ItemTemplate.id;
                    data.skills      = player.PlayerData.SkillDatas;

                    player.PlanesInstance = null;
                }
                mPlayers.Remove(roleId);
            }

            {
                if (data.value != null)
                {
                    byte[]            offvaluebytes = data.Serialize();
                    RPC.PackageWriter pkg           = new RPC.PackageWriter();
                    H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_RoleLogout(pkg, roleId, offvaluebytes);
                    pkg.DoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType);
                }
            }
        }
Beispiel #4
0
 public void RPC_OneKeyGetItems(RPC.RPCForwardInfo fwd)
 {
     RPC.PackageWriter pkg = new RPC.PackageWriter();
     H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_OneKeyGetItems(pkg, PlayerData.RoleDetail.RoleId);
     pkg.WaitDoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType, null).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool isTimeOut)
     {
         if (isTimeOut)
         {
             return;
         }
         RPC.PackageWriter             retPkg = new RPC.PackageWriter();
         List <CSCommon.Data.MailData> mails  = new List <CSCommon.Data.MailData>();
         int count = 0;
         _io.Read(out count);
         for (int i = 0; i < count; i++)
         {
             CSCommon.Data.MailData mail = new CSCommon.Data.MailData();
             _io.Read(mail);
             if (_GetMailItems(mail.StrItems) == false)
             {
                 retPkg.Write((sbyte)-1); //背包空间不足
                 retPkg.DoReturnPlanes2Client(fwd);
                 return;
             }
             _GetMailCurrencies(mail.StrCurrencies);
             //删除邮件
             RPC.PackageWriter delpkg = new RPC.PackageWriter();
             H_RPCRoot.smInstance.HGet_ComServer(delpkg).HGet_UserRoleManager(delpkg).RPC_DelMail(delpkg, mail.MailId);
             delpkg.DoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType);
         }
         retPkg.Write((sbyte)1);
         retPkg.DoReturnPlanes2Client(fwd);
     };
 }
Beispiel #5
0
        public UInt16 RegPlanesServer(ulong id, Iocp.NetConnection connect)
        {
            if (id == 0)
            {
                Log.Log.Server.Print("RegPlanesServer id is Empty");
            }

            ServerInfo si = connect.m_BindData as ServerInfo;

            si.Id = id;
            Iocp.TcpConnect tcpConnect = connect as Iocp.TcpConnect;
            si.Ip                   = tcpConnect.IpAddress;
            si.LinkNumber           = 0;
            mPlanesServers[connect] = si;

            Log.Log.Server.Print("Planes服务器{0}注册,{1}:{2}", si.Id, si.Ip, si.Port);

            foreach (var i in mGateServers)
            {
                //i.Value.Connect
                RPC.PackageWriter pkg = new RPC.PackageWriter();
                H_RPCRoot.smInstance.HGet_GateServer(pkg).NewPlanesServerStarted(pkg);
                pkg.DoCommand(i.Value.Connect, RPC.CommandTargetType.DefaultType);
            }
            return(si.Port);
        }
Beispiel #6
0
        public bool OnComValueChanged(string name, RPC.DataWriter value)
        {
            var pkg = new RPC.PackageWriter();

            H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_UpdateRoleComValue(pkg, this.Id, name, value);
            pkg.DoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType);
            return(true);
        }
Beispiel #7
0
        public void RPC_SayToRole(ulong roleId, string tarName, string msg, RPC.DataReader hyperlink, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            sbyte success = 0;

            RPC.DataWriter data = new RPC.DataWriter();
            if (hyperlink != null)
            {
                hyperlink.Read(out success);
                data.Write(success);
                if (success == (sbyte)1)//物品
                {
                    CSCommon.Data.ItemData item = new CSCommon.Data.ItemData();
                    hyperlink.Read(item, true);
                    data.Write(item, true);
                }
            }
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            var tarRole           = GetRole(tarName);

            if (tarRole == null)
            {
                pkg.Write((sbyte)-1);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }

            if (tarRole.PlanesConnect == null)
            {
                pkg.Write((sbyte)-2);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }

            var role = GetRole(roleId);

            if (role == null)
            {
                Log.Log.Common.Print("RPC_SayToRole role is null,{0}", roleId);
                pkg.Write((sbyte)-3);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }

            if (tarRole.RoleData.RoleId == roleId)
            {
                pkg.Write((sbyte)-4);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }

            RPC.PackageWriter retPkg = new RPC.PackageWriter();
            H_RPCRoot.smInstance.HGet_PlanesServer(retPkg).RPC_DSTalkMsg(retPkg, tarRole.RoleData.PlanesId, role.RoleData.Name,
                                                                         (sbyte)CSCommon.eSayChannel.WhisperChannel, tarRole.RoleData.RoleId, msg, data);
            retPkg.DoCommand(tarRole.PlanesConnect, RPC.CommandTargetType.DefaultType);

            pkg.Write((sbyte)1);
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Beispiel #8
0
        public void DestroyFromDB(RoleActor role)
        {
            sbyte destroy = 1;

            //以后这里要根据物品重要程度决定是否真实从数据库删除
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            ServerCommon.H_RPCRoot.smInstance.HGet_DataServer(pkg).DelItem(pkg, role.Id, ItemData.ItemId, destroy);
            pkg.DoCommand(IPlanesServer.Instance.DataConnect, RPC.CommandTargetType.DefaultType);
        }
Beispiel #9
0
 public void SayToWorld(UserRole role, sbyte channel, string msg, RPC.DataWriter data)
 {
     foreach (var i in Roles)
     {
         if (i.Value.PlanesConnect != null)
         {
             RPC.PackageWriter retPkg = new RPC.PackageWriter();
             H_RPCRoot.smInstance.HGet_PlanesServer(retPkg).RPC_DSTalkMsg(retPkg, i.Value.RoleData.PlanesId, role.RoleData.Name, channel, i.Value.RoleData.RoleId, msg, data);
             retPkg.DoCommand(i.Value.PlanesConnect, RPC.CommandTargetType.DefaultType);
         }
     }
 }
Beispiel #10
0
        public void SendTeamInfoToPlayers(Team team)
        {
            RPC.DataWriter dw    = new RPC.DataWriter();
            List <RoleCom> infos = team.GetPlayerInfos();

            RPC.IAutoSaveAndLoad.DaraWriteList <RoleCom>(infos, dw, false);
            foreach (var i in team.GetPlayers())
            {
                RPC.PackageWriter pkg = new RPC.PackageWriter();
                H_RPCRoot.smInstance.HGet_PlanesServer(pkg).RPC_SendPlayerTeamInfo(pkg, i.RoleData.RoleId, dw);
                pkg.DoCommand(i.PlanesConnect, RPC.CommandTargetType.DefaultType);
            }
        }
Beispiel #11
0
 public void SendMessageToOther(UserRole other, CSCommon.Data.Message msg)
 {
     if (other.PlanesConnect != null)
     {
         RPC.PackageWriter pkg = new RPC.PackageWriter();
         H_RPCRoot.smInstance.HGet_PlanesServer(pkg).RPC_SendPlayerMsg(pkg, other.RoleData.RoleId, msg);
         pkg.DoCommand(other.PlanesConnect, RPC.CommandTargetType.DefaultType);
     }
     else
     {
         DB_CreateMessage(msg);
     }
 }
Beispiel #12
0
        public enEnterMapResult PlayerEnterMap(PlayerInstance role, SlimDX.Vector3 pos, bool bTellClient)
        {
            if (mPlayerPool == null)
            {
                return(enEnterMapResult.Error_InvalidMap);
            }

            if (mFreeSlot.Count == 0)
            {
                return(enEnterMapResult.Error_PlayerFull);
            }

            role.Placement.SetLocation(ref pos);

            if (role.HostMap != this)
            {
                if (!role.HostMap.IsNullMap)
                {
                    role.HostMap.PlayerLeaveMap(role, false);
                }
                role._SetIndexInMap(mFreeSlot.Pop());
                System.Diagnostics.Debug.Assert(mPlayerPool[role.IndexInMap] == null);
                mPlayerPool[role.IndexInMap] = role;
                mPlayerDictionary[role.Id]   = role;

                if (AllMapManager.IsInstanceMap(this.MapSourceId) == false)
                {
                    //role.PlayerData.RoleDetail.MapName = this.MapName;
                    role.PlayerData.RoleDetail.DungeonID   = 0;
                    role.PlayerData.RoleDetail.MapSourceId = this.MapSourceId;
                }
                else
                {
                    role.PlayerData.RoleDetail.DungeonID = this.MapInstanceId;
                }

                role.OnEnterMap(this);
            }

            OnRoleEnterMap(role);

            RPC.PackageWriter pkg = new RPC.PackageWriter();
            H_RPCRoot.smInstance.HGet_GateServer(pkg).PlayerEnterMapInPlanes(pkg, role.Id, role.ClientLinkId, role.IndexInMap, this.IndexInServer);
            pkg.DoCommand(role.Planes2GateConnect, RPC.CommandTargetType.DefaultType);

            role.HostMap = this;
            return(enEnterMapResult.Success);
        }
Beispiel #13
0
        public void SendPlayerMail(ulong roleId)
        {
            var role = GetRole(roleId);

            if (role == null)
            {
                return;
            }

            if (role.PlanesConnect != null)
            {
                RPC.PackageWriter pkg = new RPC.PackageWriter();
                H_RPCRoot.smInstance.HGet_PlanesServer(pkg).RPC_SendPlayerMail(pkg, roleId);
                pkg.DoCommand(role.PlanesConnect, RPC.CommandTargetType.DefaultType);
            }
        }
Beispiel #14
0
 public PlanesInstance CreatePlanes()
 {
     for (Byte i = 0; i < PlanesNumMax; i++)
     {
         if (mPlanesInstance[i] == null)
         {
             PlanesInstance planes = new PlanesInstance();
             mPlanesInstance[i]         = planes;
             planes.IndexInPlanesServer = i;
             RPC.PackageWriter pkg = new RPC.PackageWriter();
             H_RPCRoot.smInstance.HGet_DataServer(pkg).UpdatePlanesServerPlanesNumber(pkg, (int)i);
             pkg.DoCommand(IPlanesServer.Instance.DataConnect, RPC.CommandTargetType.DefaultType);
             return(planes);
         }
     }
     return(null);
 }
Beispiel #15
0
 public bool SayToCamp(UserRole role, sbyte channel, string msg, RPC.DataWriter data)
 {
     if (role.RoleData.Camp == (byte)CSCommon.eCamp.None)
     {
         return(false);
     }
     foreach (var i in Roles)
     {
         if (i.Value.PlanesConnect != null && i.Value.RoleData.Camp == role.RoleData.Camp)
         {
             RPC.PackageWriter retPkg = new RPC.PackageWriter();
             H_RPCRoot.smInstance.HGet_PlanesServer(retPkg).RPC_DSTalkMsg(retPkg, i.Value.RoleData.PlanesId, role.RoleData.Name, channel, i.Value.RoleData.RoleId, msg, data);
             retPkg.DoCommand(i.Value.PlanesConnect, RPC.CommandTargetType.DefaultType);
         }
     }
     return(true);
 }
Beispiel #16
0
        public bool PlayerLeaveMap(PlayerInstance role, bool bTellGateSver)
        {
            if (mPlayerPool == null)
            {
                return(false);
            }

            if (role.IndexInMap >= mPlayerPool.Length)
            {
                //System.Diagnostics.Debugger.Break();
                for (UInt16 i = 0; i < mPlayerPool.Length; i++)
                {
                    if (mPlayerPool[i] == role)
                    {
                        role._SetIndexInMap(i);
                        break;
                    }
                }
                return(false);
            }
            else
            {
                if (mPlayerPool[role.IndexInMap] != role)
                {
                    return(false);
                }
            }

            //先存盘
            role.OnLeaveMap();

            //后清理
            mPlayerDictionary.Remove(role.Id);
            mPlayerPool[role.IndexInMap] = null;
            mFreeSlot.Push(role.IndexInMap);
            role._SetIndexInMap(System.UInt16.MaxValue);

            if (bTellGateSver)
            {
                RPC.PackageWriter pkg = new RPC.PackageWriter();
                H_RPCRoot.smInstance.HGet_GateServer(pkg).PlayerLeaveMapInPlanes(pkg, role.ClientLinkId);
                pkg.DoCommand(role.Planes2GateConnect, RPC.CommandTargetType.DefaultType);
            }

            return(true);
        }
Beispiel #17
0
        public MapInstance CreateMap()
        {
            for (UInt16 i = 0; i < MapNumMax; i++)
            {
                if (mMapInstance[i] == null)
                {
                    MapInstance map = new MapInstance();
                    mMapInstance[i]         = map;
                    map.IndexInPlanesServer = i;

                    RPC.PackageWriter pkg = new RPC.PackageWriter();
                    H_RPCRoot.smInstance.HGet_DataServer(pkg).UpdatePlanesServerGlobalMapNumber(pkg, (int)i);
                    pkg.DoCommand(IPlanesServer.Instance.DataConnect, RPC.CommandTargetType.DefaultType);
                    return(map);
                }
            }
            return(null);
        }
Beispiel #18
0
 public void SaveAll()
 {
     // 物品背包
     mPlayerData.BagItems      = Bag.GetBagSaver();
     mPlayerData.EquipedItems  = EquipBag.GetBagSaver();
     mPlayerData.FashionItems  = FashionBag.GetBagSaver();
     mPlayerData.EquipGemItems = EquipGemBag.GetBagSaver();
     mPlayerData.GemItems      = GemBag.GetBagSaver();
     // 任务
     mPlayerData.TaskData = mCurTask.TaskData;
     mRecordMgr.Save(mPlayerData.AchieveData);
     mPlayerData.SkillDatas = mSkillMgr.GetBagSaver();
     SaveMartial();
     //发送存盘数据给数据服务器保存
     RPC.PackageWriter pkg = new RPC.PackageWriter();
     H_RPCRoot.smInstance.HGet_DataServer(pkg).HGet_PlayerManager(pkg).SaveRole(pkg, mPlayerData.RoleDetail.RoleId, mPlayerData);
     pkg.DoCommand(IPlanesServer.Instance.DataConnect, RPC.CommandTargetType.DefaultType);
 }
Beispiel #19
0
        public void RPC_SendGift(ulong roleId, ulong otherId, int index, int count, int addvalue, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            var role = this.GetRole(roleId);

            if (role == null)
            {
                Log.Log.Social.Print("role is null , {0}", roleId);
                pkg.Write((sbyte)CSCommon.sRet_SendGift.NoRole);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            var other = this.GetRole(otherId);

            if (other == null)
            {
                pkg.Write((sbyte)CSCommon.sRet_SendGift.NoOther);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }

            if (role.SocialManager.IsCouple(otherId) == false)
            {
                pkg.Write((sbyte)CSCommon.sRet_SendGift.NotCouple);  //不是这种关系
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            role.SocialManager.AddIntimacy(otherId, addvalue);
            other.GiftData.AddGiftCount(index, count);

            if (other.PlanesConnect == null)
            {
                DB_SaveGiftData(other);
            }
            else
            {
                RPC.PackageWriter retPkg = new RPC.PackageWriter();
                H_RPCRoot.smInstance.HGet_PlanesServer(retPkg).RPC_AddGiftCount(retPkg, otherId, index, count);
                retPkg.DoCommand(other.PlanesConnect, RPC.CommandTargetType.DefaultType);
            }
            pkg.Write((sbyte)CSCommon.sRet_SendGift.Succeed);
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Beispiel #20
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 #21
0
        public bool SayToGuild(UserRole role, sbyte channel, string msg, RPC.DataWriter data)
        {
            if (role.GuildInstance == null)
            {
                return(false);
            }
            var members = role.GuildInstance.Members;

            foreach (var i in members)
            {
                if (i.Value.PlanesConnect == null)
                {
                    continue;
                }
                RPC.PackageWriter retPkg = new RPC.PackageWriter();
                H_RPCRoot.smInstance.HGet_PlanesServer(retPkg).RPC_DSTalkMsg(retPkg, i.Value.RoleData.PlanesId, role.RoleData.Name, channel, i.Value.RoleData.RoleId, msg, data);
                retPkg.DoCommand(i.Value.PlanesConnect, RPC.CommandTargetType.DefaultType);
            }
            return(true);
        }
Beispiel #22
0
        public bool SayToTeam(UserRole role, sbyte channel, string msg, RPC.DataWriter data)
        {
            var team = GetTeam(role.TeamHeaderId);

            if (team == null)
            {
                return(false);
            }
            foreach (var id in team.TeamMembers)
            {
                var teamRole = GetRole(id);
                if (teamRole == null)
                {
                    continue;
                }
                RPC.PackageWriter pkg = new RPC.PackageWriter();
                H_RPCRoot.smInstance.HGet_PlanesServer(pkg).RPC_DSTalkMsg(pkg, teamRole.RoleData.PlanesId, role.RoleData.Name, channel, teamRole.RoleData.RoleId, msg, data);
                pkg.DoCommand(teamRole.PlanesConnect, RPC.CommandTargetType.DefaultType);
            }
            return(true);
        }
Beispiel #23
0
        public void EnterPlanes(PlayerInstance player)
        {
            if (player.PlanesInstance == this)
            {
                return;
            }

            lock (this)
            {
                mPlayers[player.Id]   = player;
                player.PlanesInstance = this;
                if (this.PlanesId != 0)//没有在副本里面,副本没有PlanesId
                {
                    player.PlayerData.RoleDetail.PlanesId = this.PlanesId;
                }
            }

            {
                RPC.PackageWriter pkg = new RPC.PackageWriter();
                H_RPCRoot.smInstance.HGet_DataServer(pkg).HGet_PlayerManager(pkg).RoleEnterPlanesSuccessed(pkg, player.Id);
                pkg.DoCommand(IPlanesServer.Instance.DataConnect, RPC.CommandTargetType.DefaultType);
            }

            {
                RPC.PackageWriter pkg = new RPC.PackageWriter();
                H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_RoleEnterPlanes(pkg, player.PlayerData.RoleDetail);
                pkg.WaitDoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType, null).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool isTimeOut)
                {
                    if (isTimeOut)
                    {
                        return;
                    }
                    CSCommon.Data.RankData rd = new CSCommon.Data.RankData();
                    _io.Read(rd);
                    player.PlayerData.RankData = rd;
                    player.PlayerData.RankData._SetHostPlayer(player);
                };
            }
        }
Beispiel #24
0
        public void EventDispacthAutoRemove(ServerFrame.TimerEvent ev)
        {
            ServerCommon.Planes.EventDispatcher.AutoRemoveNoRefEventListener();

            if (mLastPlayerCount != AllPlayerCount)
            {
                RPC.PackageWriter pkg0 = new RPC.PackageWriter();
                H_RPCRoot.smInstance.HGet_DataServer(pkg0).UpdatePlanesServerPlayerNumber(pkg0, AllPlayerCount);
                pkg0.DoCommand(mDataConnect, RPC.CommandTargetType.DefaultType);

                mLastPlayerCount = AllPlayerCount;
            }

            if (mLastPlaneCount != PlanesCount)
            {
                RPC.PackageWriter pkg0 = new RPC.PackageWriter();
                H_RPCRoot.smInstance.HGet_DataServer(pkg0).UpdatePlanesServerPlanesNumber(pkg0, PlanesCount);
                pkg0.DoCommand(mDataConnect, RPC.CommandTargetType.DefaultType);

                mLastPlaneCount = PlanesCount;
            }
        }
Beispiel #25
0
        public void RPC_GetMailItems(ulong mailId, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_GetMailItems(pkg, mailId);
            pkg.WaitDoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType, null).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool isTimeOut)
            {
                if (isTimeOut)
                {
                    return;
                }
                RPC.PackageWriter retPkg = new RPC.PackageWriter();
                sbyte             result;
                _io.Read(out result);
                if (result == 1)
                {
                    CSCommon.Data.MailData mail = new CSCommon.Data.MailData();
                    _io.Read(mail);
                    if (_GetMailItems(mail.StrItems) == false)
                    {
                        pkg.Write((sbyte)-2); //背包空间不足
                        pkg.DoReturnPlanes2Client(fwd);
                        return;
                    }
                    _GetMailCurrencies(mail.StrCurrencies);
                    retPkg.Write((sbyte)1);

                    //删除邮件
                    RPC.PackageWriter delpkg = new RPC.PackageWriter();
                    H_RPCRoot.smInstance.HGet_ComServer(delpkg).HGet_UserRoleManager(delpkg).RPC_DelMail(delpkg, mailId);
                    delpkg.DoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType);
                }
                else
                {
                    retPkg.Write((sbyte)-1);
                }
                retPkg.DoReturnPlanes2Client(fwd);
            };
        }
Beispiel #26
0
        public void RPC_OperateGuildAsk(ulong roleId, ulong messageId, byte operate, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter retPkg = new RPC.PackageWriter();
            var role = GetRole(roleId);

            if (role == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_OperateGuildAsk.NoRole);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.GuildInstance == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_OperateGuildAsk.RoleNoGuild);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.RoleData.GuildPost <= (byte)CSCommon.eGuildPost.JingYing)
            {
                retPkg.Write((sbyte)CSCommon.eRet_OperateGuildAsk.RoleNoPower);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            CSCommon.Data.Message msg = null;
            role.GuildInstance.Messages.TryGetValue(messageId, out msg);
            if (msg == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_OperateGuildAsk.YetOperate);//已审批
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            var targetRole = GetRole(msg.Sender);

            if (targetRole == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_OperateGuildAsk.NoTargetRole);
                role.GuildInstance.Messages.Remove(messageId);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (targetRole.GuildInstance != null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_OperateGuildAsk.TargetRoleHasGuild);//已加入其他帮会
                role.GuildInstance.Messages.Remove(messageId);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.GuildInstance.GuildData.MemberNum >= CSCommon.GuildCommon.Instance.GuildLvUpList[role.GuildInstance.GuildData.Level - 1].MaxMemberNum)
            {
                retPkg.Write((sbyte)CSCommon.eRet_OperateGuildAsk.OverMaxNum);
                role.GuildInstance.Messages.Remove(messageId);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            retPkg.Write((sbyte)CSCommon.eRet_OperateGuildAsk.Succeed);
            role.GuildInstance.Messages.Remove(messageId);

            CSCommon.Data.Message operatemsg = null;
            if (operate == (byte)CSCommon.eOperateAsk.Accept)
            {
                role.GuildInstance.Members.Add(targetRole.RoleData.RoleId, targetRole);
                role.GuildInstance.GuildData.MemberNum = role.GuildInstance.Members.Count;
                targetRole.RoleData.GuildId            = role.GuildInstance.GuildData.GuildId;
                targetRole.RoleData.GuildPost          = (byte)CSCommon.eGuildPost.BangZhong;
                targetRole.GuildInstance = role.GuildInstance;
                operatemsg   = CreateMessage(CSCommon.eMessageFrom.Guild, CSCommon.eMessageType.Guild_AcceptAsk, role.RoleData.Name, targetRole.RoleData.RoleId);
                msg.ShowInfo = string.Format("申请被接受");
            }
            else
            {
                operatemsg   = CreateMessage(CSCommon.eMessageFrom.Guild, CSCommon.eMessageType.Guild_RefuseAsk, role.RoleData.Name, targetRole.RoleData.RoleId);
                msg.ShowInfo = string.Format("申请被拒绝");
            }
            if (targetRole.PlanesConnect != null)
            {
                RPC.PackageWriter pkg = new RPC.PackageWriter();
                H_RPCRoot.smInstance.HGet_PlanesServer(pkg).RPC_SendPlayerMsg(pkg, targetRole.RoleData.RoleId, operatemsg);
                pkg.DoCommand(targetRole.PlanesConnect, RPC.CommandTargetType.DefaultType);
            }
            else
            {
                DB_CreateMessage(operatemsg);
            }
            retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Beispiel #27
0
        public void RPC_AskToGuild(ulong roleId, ulong guildId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter retPkg = new RPC.PackageWriter();
            var role = GetRole(roleId);

            if (role == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_AskToGuild.NoRole);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            var guild = GuildManager.Instance.GetGuild(guildId);

            if (guild == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_AskToGuild.NoGuild);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.GuildInstance != null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_AskToGuild.RoleHasGuild);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            int count = guild.GuildData.MemberNum;

            if (CSCommon.GuildCommon.Instance.GuildLvUpList.Count < guild.GuildData.Level)
            {
                retPkg.Write((sbyte)CSCommon.eRet_AskToGuild.OverMaxNum);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (count >= (int)CSCommon.GuildCommon.Instance.GuildLvUpList[guild.GuildData.Level - 1].MaxMemberNum)
            {
                retPkg.Write((sbyte)CSCommon.eRet_AskToGuild.OverMaxNum);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            //生成消息
            CSCommon.Data.Message msg = CreateMessage(CSCommon.eMessageFrom.Guild, CSCommon.eMessageType.Guild_Ask, role.RoleData.Name, guildId);
            msg.ShowInfo = string.Format("玩家{0}申请加入帮会", role.RoleData.Name);
            //发送消息
            bool isSend = false;

            foreach (var i in guild.Members)
            {
                var member = GetRole(i.Key);
                if (member.RoleData.GuildPost > (byte)CSCommon.eGuildPost.JingYing)
                {
                    if (member.PlanesConnect != null)
                    {
                        isSend = true;
                        RPC.PackageWriter pkg = new RPC.PackageWriter();
                        H_RPCRoot.smInstance.HGet_PlanesServer(pkg).RPC_SendPlayerMsg(pkg, i.Key, msg);
                        pkg.DoCommand(member.PlanesConnect, RPC.CommandTargetType.DefaultType);
                    }
                }
            }
            if (isSend)
            {
                guild.Messages.Add(msg.MessageId, msg);
            }
            //申请成功
            retPkg.Write((sbyte)CSCommon.eRet_AskToGuild.Succeed);
            retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Beispiel #28
0
//         public bool CheckEverGet(byte reward, int pindex)
//         {
//             int isget = this.PlayerData.RankData.KillEnemyReward & pindex;//2
//             if (isget > 0)
//             {
//                 //已领取
//                 return true;
//             }
//             return false;
//         }

//         public DayRewardInfo GetRewardInfo(int id, byte index)
//         {
//             string reward = CSTable.StaticDataManager.DayRank.GetReward(id);
//             DayRewardInfos RewardInfo = new DayRewardInfos(reward);
//             if (index >= RewardInfo.infos.Count)
//             {
//                 //index错误
//                 return null;
//             }
//             var info = RewardInfo.infos[index];
//             return info;
//         }

        public void OnRankValueChanged(string name, RPC.DataWriter dw)//变了之后,告诉rankdata
        {
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_UpdateRankDataValue(pkg, this.Id, name, dw);
            pkg.DoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType);
        }
Beispiel #29
0
        public void EnterMap(CSCommon.Data.PlayerData pd, CSCommon.Data.PlanesData planesData, ushort mapSourceId, ulong instanceId, SlimDX.Vector3 pos, UInt16 cltHandle, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
//             var map = Planes.PlanesManager.Instance.GetGlobalMap(planesData, pd.RoleDetail.MapSourceId);
//             if (map == null)
//                 return;

            Planes.PlayerInstance player = Planes.PlanesServerDataManager.Instance.FindPlayerInstance(pd.RoleDetail.RoleId);
            if (player != null)
            {                                                                                                  //玩家就在这个服务器
                Planes.MapInstanceManager.Instance.PlayerLeaveMap(player, false);                              //离开地图
                player.PlanesInstance.LeavePlanes(player.Id);                                                  //离开位面
                var planes = Planes.MapInstanceManager.Instance.PlanesManager.GetPlanesInstance(planesData);
                planes.EnterPlanes(player);                                                                    //进位面

                Planes.MapInstanceManager.Instance.PlayerEnterMap(player, mapSourceId, instanceId, pos, true); //进地图
            }
            else
            {
                #region CreatePlayerInstance
                try
                {
                    player = Planes.PlayerInstance.CreatePlayerInstance(pd, connect as Iocp.TcpConnect, cltHandle);
                    if (player == null)//创建角色
                    {
                        RPC.PackageWriter pkg = new RPC.PackageWriter();
                        H_RPCRoot.smInstance.HGet_GateServer(pkg).DisconnectPlayer(pkg, pd.RoleDetail.AccountId, (sbyte)eServerType.Planes);
                        pkg.DoCommand(connect, RPC.CommandTargetType.DefaultType);

                        RPC.PackageWriter retPkg = new RPC.PackageWriter();
                        retPkg.Write((sbyte)eRet_GotoMap.CreatePlayerFailed);
                        retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);

                        Log.Log.Server.Print("DataServer1 force disconnect player!");
                        Log.Log.Server.Print(new System.Diagnostics.StackTrace(0, true).ToString());
                        return;
                    }
                }
                catch (System.Exception ex)
                {
                    Log.Log.Server.Print(ex.ToString());
                    Log.Log.Server.Print(ex.StackTrace.ToString());
                    RPC.PackageWriter pkg = new RPC.PackageWriter();
                    H_RPCRoot.smInstance.HGet_GateServer(pkg).DisconnectPlayer(pkg, pd.RoleDetail.AccountId, (sbyte)eServerType.Planes);
                    pkg.DoCommand(connect, RPC.CommandTargetType.DefaultType);
                    RPC.PackageWriter retPkg = new RPC.PackageWriter();
                    retPkg.Write((sbyte)eRet_GotoMap.CreatePlayerFailed);
                    retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);

                    Log.Log.Server.Print("PlanesServer2 force disconnect player!");
                    Log.Log.Server.Print(new System.Diagnostics.StackTrace(0, true).ToString());
                    return;
                }
                #endregion
                Planes.PlanesServerDataManager.Instance.AddPlayerInstance(player);                             //进服务器
                var planes = Planes.MapInstanceManager.Instance.PlanesManager.GetPlanesInstance(planesData);
                planes.EnterPlanes(player);                                                                    //进位面

                Planes.MapInstanceManager.Instance.PlayerEnterMap(player, mapSourceId, instanceId, pos, true); //进地图

                var overPkg = new RPC.PackageWriter();
                Wuxia.H_RpcRoot.smInstance.RPC_OnJumpMapOver(overPkg, (int)mapSourceId, pos.X, pos.Z);
                overPkg.DoCommandPlanes2Client(player.Planes2GateConnect, player.ClientLinkId);
            }

            {
                RPC.PackageWriter retPkg = new RPC.PackageWriter();
                retPkg.Write((sbyte)eRet_GotoMap.EnterMap);
                retPkg.Write(pd.RoleDetail.LocationX);
                retPkg.Write(pd.RoleDetail.LocationY);
                retPkg.Write(pd.RoleDetail.LocationZ);
                //retPkg.Write(player.Id);
                retPkg.Write(player.PlayerData.RoleDetail.RoleHp);
                retPkg.Write(player.PlayerData.RoleDetail.RoleMaxHp);
                retPkg.Write(player.PlayerData.RoleDetail.RoleSpeed);
                retPkg.Write(player.IndexInMap);
                retPkg.Write(player.HostMap.IndexInServer);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
            }

            return;
        }
Beispiel #30
0
 public void SayError(UserRole role, sbyte channel, string msg, RPC.DataWriter data)
 {
     RPC.PackageWriter retPkg = new RPC.PackageWriter();
     H_RPCRoot.smInstance.HGet_PlanesServer(retPkg).RPC_DSTalkMsg(retPkg, role.RoleData.PlanesId, "", channel, role.RoleData.RoleId, msg, data);
     retPkg.DoCommand(role.PlanesConnect, RPC.CommandTargetType.DefaultType);
 }