Пример #1
0
        public RPC.DataWriter GetPlanesServers()
        {
            RPC.DataWriter d = new RPC.DataWriter();

            Byte count = (Byte)mPlanesServers.Count;

            d.Write(count);
            foreach (var s in mPlanesServers)
            {
                if (s.Value.Id == 0)
                {
                    Log.Log.Server.Print("GetPlanesServers时有的PlanesSever的Id不合法");
                    RPC.PackageWriter pkg = new RPC.PackageWriter();
                    H_RPCRoot.smInstance.HGet_PlanesServer(pkg).GetPlanesServerId(pkg);
                    pkg.WaitDoCommand(s.Value.Connect, RPC.CommandTargetType.DefaultType, new System.Diagnostics.StackTrace(1, true)).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut)
                    {
                        _io.Read(out s.Value.Id);
                    };
                }
                d.Write(s.Value.Id);
                d.Write(s.Value.Ip);
                d.Write(s.Value.Port);
            }

            return(d);
        }
Пример #2
0
        public void RPC_Whisper(string targetName, string msg, RPC.DataReader hyperlink, 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);
                }
            }
            msg = CheckMaskWord(msg);
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            H_RPCRoot.smInstance.HGet_ComServer(pkg).HGet_UserRoleManager(pkg).RPC_SayToRole(pkg, this.Id, targetName, msg, data);
            pkg.WaitDoCommand(IPlanesServer.Instance.ComConnect, RPC.CommandTargetType.DefaultType, new System.Diagnostics.StackTrace(1, true)).OnFarCallFinished = delegate(RPC.PackageProxy _io, bool bTimeOut)
            {
                sbyte result = -1;
                _io.Read(out result);
                if (result < 0)
                {
                    SendTalkMsg2Client(this, (sbyte)CSCommon.eSayChannel.WhisperChannel, "", "无效发送对象", new RPC.DataWriter());
                }
                else
                {
                    SendTalkMsg2Client(this, (sbyte)CSCommon.eSayChannel.WhisperChannel, this.RoleName, msg, data);
                }
            };
        }
Пример #3
0
        public byte[] AchieveSerialize()
        {
            RPC.DataWriter dw    = new RPC.DataWriter();
            int            count = 0;

            foreach (var i in AchieveDict.Values)
            {
                foreach (var ave in i)
                {
                    if (ave.data.targetNum > 0)
                    {
                        count++;
                    }
                }
            }
            dw.Write(count);
            foreach (var i in AchieveDict.Values)
            {
                foreach (var ave in i)
                {
                    dw.Write(ave.data.id);
                    dw.Write(ave.data.targetNum);
                    dw.Write(ave.data.getReward);
                }
            }
            return(dw.Trim());
        }
Пример #4
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);
        }
Пример #5
0
 public byte[] CopySerialize()
 {
     RPC.DataWriter dw = new RPC.DataWriter();
     dw.Write(CopyList.Count);
     foreach (var i in CopyList)
     {
         dw.Write(i);
     }
     return(dw.Trim());
 }
Пример #6
0
        public RPC.DataWriter GetComServer()
        {
            RPC.DataWriter d = new RPC.DataWriter();
            if (mComServer == null)
            {
                return(d);
            }
            d.Write(mComServer.IpAddress);
            d.Write(mComServer.Port);

            return(d);
        }
Пример #7
0
 public RPC.DataWriter GetGateServers()
 {
     RPC.DataWriter d      = new RPC.DataWriter();
     System.Byte    nCount = (Byte)mGateServers.Count;
     d.Write(nCount);
     foreach (var l in mGateServers)
     {
         d.Write(l.Value.Ip);
         d.Write(l.Value.Port);
     }
     return(d);
 }
Пример #8
0
        public RPC.DataWriter GetAllActivePlanesInfo()
        {
            RPC.DataWriter result = new RPC.DataWriter();
            UInt16         count  = (UInt16)mPlanes.Count;

            result.Write(count);
            foreach (var i in mPlanes)
            {
                result.Write(i.Value.PlanesId);
                result.Write(i.Value.PlanesName);
            }
            return(result);
        }
Пример #9
0
        public static void DaraWriteList <T>(List <T> list, RPC.DataWriter pkg, bool bToClient)
            where T : RPC.IAutoSaveAndLoad
        {
            UInt16 count = (UInt16)list.Count;

            pkg.Write(count);
            foreach (var i in list)
            {
                RPC.DataWriter idr = new RPC.DataWriter();
                i.DataWrite(idr, bToClient);
                pkg.Write(idr);
            }
        }
Пример #10
0
        public RPC.DataWriter GetLogServer()
        {
            RPC.DataWriter d = new RPC.DataWriter();
            if (mLogServer == null)
            {
                d.Write((sbyte)(-1));
                return(d);
            }
            d.Write((sbyte)(1));
            d.Write(mLogServer.IpAddress);
            d.Write(mLogServer.Port);

            return(d);
        }
Пример #11
0
 public void RPC_Say(sbyte channel, string msg, RPC.DataReader hyperlink, RPC.RPCForwardInfo fwd)
 {
     msg = CheckMaskWord(msg);
     RPC.DataWriter data = new RPC.DataWriter();
     data.Write(hyperlink.mHandle);
     RPC.PackageWriter pkg = new RPC.PackageWriter();
     SayToComServer(channel, msg, data);
 }
Пример #12
0
 public byte[] Serialize()
 {
     RPC.DataWriter dw = new RPC.DataWriter();
     value.Serialize(dw);
     dw.Write(WeapFacdeid);
     RPC.IAutoSaveAndLoad.DaraWriteList <CSCommon.Data.SkillData>(skills, dw, false);
     return(dw.Trim());
 }
Пример #13
0
        public byte[] SerializeArms()
        {
            RPC.DataWriter dw = new RPC.DataWriter();
            dw.Write((byte)HoldPoints.Count);
            foreach (var i in HoldPoints)
            {
                dw.Write(i.ArmsCount);
                dw.Write((byte)i.Camp);
            }
            dw.Write((byte)Defender.Length);
            foreach (var i in Defender)
            {
                dw.Write(i);
            }

            dw.Write((byte)AdvanceArms.Length);
            foreach (var i in AdvanceArms)
            {
                dw.Write(i);
            }

            if (dw.Length >= 255)
            {
                Log.Log.Common.Error("City 序列化数据最大不能超过255!");
            }

            return(dw.Trim());
        }
Пример #14
0
        //保存数据库调用
        public void VisitDataSerialize()
        {
            RPC.DataWriter dw    = new RPC.DataWriter();
            byte           count = (byte)VisitTopList.Count;

            dw.Write(count);
            foreach (var i in VisitTopList)
            {
                dw.Write(i);
            }
            count = (byte)VisitFriendList.Count;
            dw.Write(count);
            foreach (var i in VisitFriendList)
            {
                dw.Write(i);
            }
            RoleData.VisitPlayers = dw.Trim();
        }
Пример #15
0
        public RPC.DataWriter GetRoleDetailData(ulong accountID)
        {
            RPC.DataWriter dw = new RPC.DataWriter();

            var acInfo = mPlayerManager.FindPlayerData(accountID);

            if (acInfo != null)
            {
                dw.Write((SByte)1);
                dw.Write(acInfo.RoleDetail, false);
            }
            else
            {
                dw.Write((SByte)(-1));
            }

            return(dw);
        }
Пример #16
0
        public RPC.DataWriter GetAccountInfoData(ulong accountID)
        {
            RPC.DataWriter dw = new RPC.DataWriter();

            var account = mPlayerManager.FindAccountInfo(accountID);

            if (account != null)
            {
                dw.Write((SByte)1);
                dw.Write(account, false);
            }
            else
            {
                dw.Write((SByte)(-1));
            }

            return(dw);
        }
Пример #17
0
        public RPC.DataWriter RegPlanesServer(string ip, UInt16 port, ulong id, Iocp.NetConnection connect)
        {
            ServerFrame.NetEndPoint nep = new ServerFrame.NetEndPoint(ip, port);
            nep.Id      = id;
            nep.Connect = connect;

            PlanesServerInfo oldnep;

            if (mPlanesServers.TryGetValue(connect, out oldnep) == true)
            {
                mPlanesServers[connect].EndPoint = nep;
            }
            else
            {
                oldnep          = new PlanesServerInfo();
                oldnep.EndPoint = nep;
                mPlanesServers.Add(connect, oldnep);
            }

            Log.Log.Server.Print("yzb id = {0}", id);


            RPC.DataWriter lret = new RPC.DataWriter();

            //启动该planesserver对应的世界地图和国战地图
            AllMapManager.Instance.StartupWorldMap((int)id);

            //位面信息
            int count = this.PlanesMgr.Planes.Count;

            lret.Write(count);
            Log.Log.Server.Print("count = {0}", count);
            foreach (var i in this.PlanesMgr.Planes)
            {
                lret.Write(i.Value.PlanesId);
                lret.Write(i.Value.PlanesName);
            }

            count = 0;
            //将要启动的地图id返回给PlanesServer
            if (CSCommon.Data.CDbConfig.m_PlanesConfig.ContainsKey((int)id))
            {
                count = CSCommon.Data.CDbConfig.m_PlanesConfig[(int)id].ListMap.Count;
                lret.Write(count);
                Log.Log.Server.Print("map count = {0}", count);
                foreach (CSCommon.Data.CAreaMap lAreaMap in CSCommon.Data.CDbConfig.m_PlanesConfig[(int)id].ListMap)
                {
                    lret.Write(lAreaMap.Area);
                    lret.Write(lAreaMap.Map);
                }
            }
            else
            {
                lret.Write(count);
                Log.Log.Server.Print("map count 0 = {0}", count);
            }
            return(lret);
        }
Пример #18
0
        public void RPC_DSTalkMsg(ulong planesId, string sender, sbyte channel, ulong targetId, string msg, RPC.DataReader hyperlink)
        {
            RPC.DataWriter data = new RPC.DataWriter();
            var            link = hyperlink.ReadDataReader();

            data.Write(link.mHandle);
            var player = Planes.PlanesServerDataManager.Instance.FindPlayerInstance(targetId);

            if (null != player)
            {
                Planes.PlayerInstance.SendTalkMsg2Client(player, channel, sender, msg, data);
            }
        }
Пример #19
0
        // 将格子中的信息同步给某个玩家,返回值是实际同步的玩家数量
        public int AsyncMapCellDataToClient(PlayerInstance player, int maxCount, Random rand, RPC.DataWriter data)
        {
            int retValue = maxCount;

            if (Players.Count <= maxCount)
            {
                if (Players.Contains(player))
                {
                    retValue = Players.Count - 1;
                }
                else
                {
                    retValue = Players.Count;
                }

                data.Write((Byte)retValue);

                foreach (var role in Players)
                {
                    if (role.Id == player.Id)
                    {
                        continue;
                    }

                    data.Write(role.PlayerData.RoleDetail, true);
                    data.Write(role.Id);
                }
            }
            else
            {
                int startIdx = rand.Next(Players.Count - maxCount);

                if (Players.IndexOf(player) >= startIdx)
                {
                    retValue = maxCount - 1;
                }
                else
                {
                    retValue = maxCount;
                }

                data.Write((Byte)retValue);

                for (int i = startIdx; i < startIdx + maxCount; i++)
                {
                    if (Players[i].Id == player.Id)
                    {
                        continue;
                    }

                    data.Write(Players[i].PlayerData.RoleDetail, true);
                    data.Write(Players[i].Id);
                }
            }

            return(retValue);
        }
Пример #20
0
        public RPC.DataWriter GetLowGateServer(Iocp.NetConnection connect)
        {
            RPC.DataWriter d = new RPC.DataWriter();
            if (mGateServers.Count == 0)
            {
                return(d);
            }

            var linkedInfo = connect.m_BindData as ClientLinkedInfo;

            if (linkedInfo == null)
            {
                return(d);
            }

            int        minValue   = Int32.MaxValue;
            ServerInfo serverInfo = null;

            foreach (var l in mGateServers)
            {
                if (l.Value.LinkNumber < minValue)
                {
                    minValue   = l.Value.LinkNumber;
                    serverInfo = l.Value;
                }
            }

            if (serverInfo != null)
            {
                d.Write(serverInfo.Ip);
                d.Write(serverInfo.Port);
            }

            linkedInfo.LandStep = 1;

            return(d);
        }
Пример #21
0
        //保存数据库调用
        public void MartialSerialize()
        {
            ClearTimeHandlers();
            RPC.DataWriter dw        = new RPC.DataWriter();
            byte           itemCount = (byte)mOutDict.Count;

            dw.Write(itemCount);
            foreach (var i in mOutDict.Values)
            {
                dw.Write(i.mType);
                dw.Write(i.mStartTime);
                dw.Write(i.mOutCount);
                dw.Write(i.mUpOutIndex);
                dw.Write(i.mUpStartTime);
                dw.Write(i.mOutPutTotalNum);
            }
            mRole.PlayerData.MartialData.OutPutInfo = dw.Trim();
        }
Пример #22
0
        public void RPC_Say(ulong roleId, sbyte channel, string msg, RPC.DataReader hyperlink, RPC.RPCForwardInfo fwd)
        {
            RPC.DataWriter data = new RPC.DataWriter();
            var            link = hyperlink.ReadDataReader();

            data.Write(link.mHandle);
            var role = GetRole(roleId);

            if (role == null)
            {
                return;
            }

            switch ((CSCommon.eSayChannel)channel)
            {
            case CSCommon.eSayChannel.WorldChannel:
            case CSCommon.eSayChannel.SystemChannel:
                SayToWorld(role, channel, msg, data);
                break;

            case CSCommon.eSayChannel.CampChannel:
                if (!SayToCamp(role, channel, msg, data))
                {
                    SayError(role, channel, "未加入国家", new RPC.DataWriter());
                }
                break;

            case CSCommon.eSayChannel.GuildChannel:
                if (!SayToGuild(role, channel, msg, data))
                {
                    SayError(role, channel, "未加入帮派", new RPC.DataWriter());
                }
                break;

            case CSCommon.eSayChannel.TeamChannel:
                if (!SayToTeam(role, channel, msg, data))
                {
                    SayError(role, channel, "未加入队伍", new RPC.DataWriter());
                }
                break;
            }
        }
Пример #23
0
        protected void OnComPropertyChanged(string proName)
        {
            if (mHostPlayer == null)
            {
                return;
            }
            var proInfo = this.GetType().GetProperty(proName);

            RPC.PackageWriter pkg = new RPC.PackageWriter();

            RPC.DataWriter dw = new RPC.DataWriter();
            if (proInfo.PropertyType == typeof(Byte))
            {
                dw.Write(System.Convert.ToByte(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(UInt16))
            {
                dw.Write(System.Convert.ToUInt16(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(UInt32))
            {
                dw.Write(System.Convert.ToUInt32(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(UInt64))
            {
                dw.Write(System.Convert.ToUInt64(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(SByte))
            {
                dw.Write(System.Convert.ToSByte(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(Int16))
            {
                dw.Write(System.Convert.ToInt16(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(Int32))
            {
                dw.Write(System.Convert.ToInt32(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(Int64))
            {
                dw.Write(System.Convert.ToInt64(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(float))
            {
                dw.Write(System.Convert.ToSingle(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(double))
            {
                dw.Write(System.Convert.ToDouble(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(System.Guid))
            {
                dw.Write(System.Guid.Parse(proInfo.GetValue(this, null).ToString()));
            }
            else
            {
                return;
            }


            var host = mHostPlayer as ServerCommon.Planes.PlayerInstance;

            if (host != null)
            {
                host.OnComValueChanged(proName, dw);
            }
        }
Пример #24
0
        protected void SendPackage(string proName)
        {
            if (mHostNpc == null)
            {
                return;
            }
            var proInfo = this.GetType().GetProperty(proName);

            RPC.PackageWriter pkg = new RPC.PackageWriter();

            RPC.DataWriter dw = new RPC.DataWriter();
            if (proInfo.PropertyType == typeof(Byte))
            {
                dw.Write(System.Convert.ToByte(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(UInt16))
            {
                dw.Write(System.Convert.ToUInt16(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(UInt32))
            {
                dw.Write(System.Convert.ToUInt32(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(UInt64))
            {
                dw.Write(System.Convert.ToUInt64(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(SByte))
            {
                dw.Write(System.Convert.ToSByte(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(Int16))
            {
                dw.Write(System.Convert.ToInt16(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(Int32))
            {
                dw.Write(System.Convert.ToInt32(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(Int64))
            {
                dw.Write(System.Convert.ToInt64(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(float))
            {
                dw.Write(System.Convert.ToSingle(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(double))
            {
                dw.Write(System.Convert.ToDouble(proInfo.GetValue(this, null)));
            }
            else if (proInfo.PropertyType == typeof(System.Guid))
            {
                dw.Write(System.Guid.Parse(proInfo.GetValue(this, null).ToString()));
            }
            else
            {
                return;
            }

            mHostNpc.OnValueChanged(proName, dw);
        }
Пример #25
0
 public void Serialize(RPC.DataWriter dw)
 {
     for (var i = eElemType.Gold; i < eElemType.MAX; i++)
     {
         dw.Write(GetDef(i));
     }
     dw.Write(AllDefRate);
     dw.Write(MaxHPRate);
     dw.Write(MaxHP);
     dw.Write(MaxMP);
     dw.Write(Atk);
     dw.Write(Crit);
     dw.Write(CritRate);
     dw.Write(CritDef);
     dw.Write(CritDefRate);
     dw.Write(DeadlyHit);
     dw.Write(DeadlyHitRate);
     dw.Write(Hit);
     dw.Write(Dodge);
     dw.Write(UpHurtRate);
     dw.Write(DownHurtRate);
     dw.Write(UnusualDefRate);
     dw.Write(Block);
     dw.Write(BlockRate);
     dw.Write(HPRecover);
     dw.Write(MPRecover);
     dw.Write(UpExpRate);
     dw.Write(Speed);
     dw.Write(DamageReflect);
 }