Пример #1
0
        public void TryCreatePlayer(UInt16 lnk, ulong accountId, string planeName, string plyName, Byte pro, Byte sex, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            //planesName = ServerFrame.DB.DBConnect.SqlSafeString(planesName);
            plyName = ServerFrame.DB.DBConnect.SqlSafeString(plyName);
            ulong         roleId         = ServerFrame.Util.GenerateObjID(ServerFrame.GameObjectType.Player);
            AsyncExecuter exe            = AsyncExecuteThreadManager.Instance.AsyncExe(false);
            UInt16        returnSerialId = fwd.ReturnSerialId;

            exe.Exec = delegate()
            {
                RPC.PackageWriter        retPkg = new RPC.PackageWriter();
                CSCommon.Data.PlayerData result = mPlayerManager.TryCreatePlayer(Thread.PlayerEnterThread.Instance.DBConnect, mPlanesMgr, accountId, roleId, planeName, plyName, pro, sex);

                //告诉GateServer,创建是否成功
                if (result != null)
                {
                    retPkg.Write((sbyte)1);
                    retPkg.Write(result.RoleDetail);
                    retPkg.DoReturnCommand2(connect, returnSerialId);
                }
                else
                {
                    retPkg.Write((sbyte)-1);
                    retPkg.DoReturnCommand2(connect, returnSerialId);
                }
            };
            //这里要放到一个专门的队列创建
            Thread.PlayerEnterThread.Instance.PushRoleCreator(exe);
        }
Пример #2
0
        public void RPC_BuyConsignItem(ulong roleId, ulong itemId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            var role = GetRole(roleId);

            if (role == null)
            {
                pkg.Write((sbyte)CSCommon.eRet_BuyConsignItem.NoRole);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            var gird = GetGird(itemId);

            if (gird == null)
            {
                pkg.Write((sbyte)CSCommon.eRet_BuyConsignItem.NoItem);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }

            string items = GetStr(gird.TemplateId, gird.StackNum);

            CreateMailAndSend(roleId, CSCommon.eMailFromType.BuyConsignSucceed, "", items);
            DB_DelGird(gird);
            pkg.Write((sbyte)CSCommon.eRet_BuyConsignItem.Succeed);
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #3
0
        public void RPC_LeaveGuild(ulong roleId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter retPkg = new RPC.PackageWriter();
            var role = GetRole(roleId);

            if (role == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_LeaveGuild.NoRole);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.RoleData.GuildId == 0 || role.GuildInstance == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_LeaveGuild.RoleNoGuild);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.RoleData.GuildPost == (byte)CSCommon.eGuildPost.BangZhu)
            {
                retPkg.Write((sbyte)CSCommon.eRet_LeaveGuild.RoleIsBangZhu);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }

            retPkg.Write((sbyte)CSCommon.eRet_LeaveGuild.Succeed);
            LeaveGuild(role);
            retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #4
0
        public void RPC_DonateGold(ulong roleId, int gold, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter retPkg = new RPC.PackageWriter();
            var role = GetRole(roleId);

            if (role == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_DonateGold.NoRole);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.GuildInstance == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_DonateGold.RoleNoGuild);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }

            role.GuildInstance.GuildData.GuildGold += (ulong)gold;

            int contribute = (int)gold;//贡献换算公式未定

            AddRoleGuildContribute(role, contribute);
            retPkg.Write((sbyte)CSCommon.eRet_DonateGold.Succeed);
            retPkg.Write(role.RoleData.TodayGuildContribute);
            retPkg.Write(role.RoleData.GuildContribute);
            retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #5
0
        public void RPC_GetRoleGirdByType(ulong roleId, byte itemType, byte page, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            var role = GetRole(roleId);

            if (role == null)
            {
                pkg.Write((sbyte)-1);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            pkg.Write((sbyte)1);
            byte   pageNum = 5;
            int    start   = (page - 1) * pageNum;
            string strSQL  = "select * from ConsignGirdData where Type = " + itemType.ToString() + "limit start,pageNum";
            List <CSCommon.Data.ConsignGridData> datas = SelectGird(strSQL);
            int count = datas.Count;

            pkg.Write(count);
            for (int i = 0; i < count; i++)
            {
                pkg.Write(datas[i]);
            }
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #6
0
        public void RPC_CreateTeam(ulong roleId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            var role = GetRole(roleId);

            if (role == null)
            {
                pkg.Write((sbyte)CSCommon.eRet_Team.NoRole);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.TeamHeaderId != 0)
            {
                pkg.Write((sbyte)CSCommon.eRet_Team.RoleHasTeam);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (_CreateTeam(roleId) == false)
            {
                pkg.Write((sbyte)CSCommon.eRet_Team.NewTeamError);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (_AddTeam(role, roleId) == false)
            {
                pkg.Write((sbyte)CSCommon.eRet_Team.OverTeamCount);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            pkg.Write((sbyte)CSCommon.eRet_Team.Succeed);
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #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);
        }
Пример #8
0
        public void RPC_GetTopAndFriend(ulong roleId, ushort planesId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            TopList.Clear();
            FriendList.Clear();
            var role = this.GetRole(roleId);

            if (role == null)
            {
                Log.Log.Server.Print("RPC_GetTopAndFriend role is null , {0}", roleId);
                pkg.Write((sbyte)-1);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            pkg.Write((sbyte)1);
            InitVisitTimes(role);
            pkg.Write(role.RoleData.WorldVisitCount);
            pkg.Write(role.RoleData.FriendVisitCount);
            pkg.Write(role.RoleData.BuyVisitCount);
            pkg.Write(role.RoleData.ByVisitCount);
            List <RankData> rds = _GetFightTopPlayer(planesId);

            pkg.Write((byte)rds.Count);
            foreach (var i in rds)
            {
                pkg.Write(i.RoleId);
                pkg.Write(i.RoleName);
                if (role.VisitTopList.Contains(i.RoleId))
                {
                    pkg.Write((byte)CSCommon.eBoolState.True);
                }
                else
                {
                    pkg.Write((byte)CSCommon.eBoolState.False);
                }
                TopList.Add(i.RoleId);
            }
            UpdateSocialInfoList(CSCommon.eSocialType.Friend, role);
            pkg.Write((byte)role.mSocialInfoList.Count);
            foreach (var j in role.mSocialInfoList.Values)
            {
                pkg.Write(j.id);
                pkg.Write(j.name);
                if (role.VisitFriendList.Contains(j.id))
                {
                    pkg.Write((byte)CSCommon.eBoolState.True);
                }
                else
                {
                    pkg.Write((byte)CSCommon.eBoolState.False);
                }
                FriendList.Add(j.id);
            }
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #9
0
        public void RPC_GetGuilds(ulong roleId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter retPkg = new RPC.PackageWriter();
            retPkg.SetSinglePkg();
            var role = GetRole(roleId);

            if (role == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_GetGuilds.NoRole);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.RoleData.GuildId == 0)//没有帮会,返回帮会列表信息
            {
                retPkg.Write((sbyte)CSCommon.eRet_GetGuilds.ReturnGuilds);
                List <CSCommon.Data.GuildCom> guilds = new List <CSCommon.Data.GuildCom>();
                foreach (var guild in GuildManager.Instance.Guilds)
                {
                    if (guild.Value.GuildData.PlanesId == role.RoleData.PlanesId && guild.Value.GuildData.Camp == role.RoleData.Camp)
                    {
                        guilds.Add(guild.Value.GuildData);
                    }
                }

                int count = guilds.Count;
                retPkg.Write(count);
                foreach (var i in guilds)
                {
                    retPkg.Write(i);
                }
            }
            else //有帮会,返回帮会成员信息
            {
                if (role.GuildInstance == null)
                {
                    Log.Log.Guild.Print("role.GuildInstance is null {0}", role.RoleData.GuildId);
                    retPkg.Write((sbyte)CSCommon.eRet_GetGuilds.NoGuild);
                    retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                    return;
                }
                else
                {
                    retPkg.Write((sbyte)CSCommon.eRet_GetGuilds.ReturnGuildMembers);
                    retPkg.Write(role.GuildInstance.GuildData);
                    retPkg.Write(role.GuildInstance.Members.Count);
                    foreach (var member in role.GuildInstance.Members)
                    {
                        retPkg.Write(member.Value.RoleData);
                    }
                }
            }
            retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #10
0
 public void RPC_OneKeyDelMails(ulong roleId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
 {
     RPC.PackageWriter pkg = new RPC.PackageWriter();
     if (DB_DelMails(roleId) == false)
     {
         pkg.Write((sbyte)-1);
         pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
         return;
     }
     pkg.Write((sbyte)1);
     pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
 }
Пример #11
0
 public void RPC_GetMailItems(ulong mailId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
 {
     RPC.PackageWriter      pkg  = new RPC.PackageWriter();
     CSCommon.Data.MailData mail = DB_GetMail(mailId);
     if (mail == null)
     {
         pkg.Write((sbyte)-1);
         pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
         return;
     }
     pkg.Write((sbyte)1);
     pkg.Write(mail);
     pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
 }
Пример #12
0
 public void GetPlanesInfo(ushort planesId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
 {
     RPC.PackageWriter        retPkg = new RPC.PackageWriter();
     CSCommon.Data.PlanesData data;
     if (false == this.PlanesMgr.Planes.TryGetValue(planesId, out data))
     {
         retPkg.Write((SByte)(-1));
         retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
         return;
     }
     retPkg.Write((SByte)(1));
     retPkg.Write(data);
     retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
     return;
 }
Пример #13
0
 public void RPC_OpenMail(ulong mailId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
 {
     RPC.PackageWriter      pkg  = new RPC.PackageWriter();
     CSCommon.Data.MailData mail = DB_GetMail(mailId);
     if (mail == null)
     {
         pkg.Write((sbyte)-1);
         pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
         return;
     }
     mail.State = (byte)CSCommon.eMailState.Opened;
     DB_UpdateMail(mail);
     pkg.Write((sbyte)1);
     pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
 }
Пример #14
0
        public void RPC_SearchPlayerByName(string roleName, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter retPkg = new RPC.PackageWriter();
            var role = GetRole(roleName);

            if (role == null)
            {
                retPkg.Write((sbyte)-2);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            retPkg.Write((sbyte)1);
            retPkg.Write(role.RoleData);
            retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
            return;
        }
Пример #15
0
        public void RPC_InviteToGuild(ulong roleId, string tarName, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter retPkg = new RPC.PackageWriter();
            var role = GetRole(roleId);

            if (role == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_InviteToGuild.NoRole);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            var targetRole = GetRole(tarName);

            if (targetRole == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_InviteToGuild.NoTargetRole);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.GuildInstance == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_InviteToGuild.RoleNoGuild);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (targetRole.GuildInstance != null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_InviteToGuild.TargetRoleHasGuild);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }

            if (role.RoleData.GuildPost <= (byte)CSCommon.eGuildPost.JingYing)
            {
                retPkg.Write((sbyte)CSCommon.eRet_InviteToGuild.RoleNoPower);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (targetRole.PlanesConnect == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_InviteToGuild.TargetRoleNotInPlay);
                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_InviteToGuild.OverMaxNum);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            retPkg.Write((sbyte)CSCommon.eRet_InviteToGuild.Succeed);
            CSCommon.Data.Message msg = CreateMessage(CSCommon.eMessageFrom.Guild, CSCommon.eMessageType.Guild_Invite, role.RoleData.Name, targetRole.RoleData.RoleId);
            msg.ShowInfo = string.Format("玩家{0}邀请您加入{1}帮会", role.RoleData.Name, role.GuildInstance.GuildData.GuildName);
            SendMessageToOther(targetRole, msg);

            retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #16
0
        public void RPC_RandRoleName(Byte sex, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter pkg  = new RPC.PackageWriter();
            string            name = _RandRoleName(sex);

            pkg.Write(name);
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #17
0
        public void RPC_GetOffPlayerData(ulong roleId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            var getRole           = GetRoleRand();

            pkg.Write(getRole.RoleData);
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #18
0
        public void RPC_RemoveSocial(ulong roleId, ulong otherId, byte type, 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.eRet_RemoveSocial.NoRole);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            var other = this.GetRole(otherId);

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

            if (role.SocialManager.IsSocial(otherId, (CSCommon.eSocialType)type) == false)
            {
                pkg.Write((sbyte)CSCommon.eRet_RemoveSocial.NotSocial);  //不是这种关系
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.SocialManager.RemoveSocial(otherId, (CSCommon.eSocialType)type) == false)
            {
                pkg.Write((sbyte)CSCommon.eRet_RemoveSocial.RemoveError);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (type == (byte)CSCommon.eSocialType.Friend && role.SocialManager.IsCouple(otherId))
            {
                //删除双方亲人关系
                role.SocialManager.RemoveCouple(otherId);
                other.SocialManager.RemoveCouple(roleId);
                CSCommon.Data.Message msg = CreateMessage(CSCommon.eMessageFrom.Social, CSCommon.eMessageType.Couple_Remove, role.RoleData.Name, other.RoleData.RoleId);
                msg.ShowInfo = string.Format("玩家{0}与你成为解除亲人关系", role.RoleData.Name);
                SendMessageToOther(other, msg);
            }
            pkg.Write((sbyte)CSCommon.eRet_RemoveSocial.Succeed);
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #19
0
        public void RPC_DissolveGuild(ulong roleId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter retPkg = new RPC.PackageWriter();

            var role = GetRole(roleId);

            if (role == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_DissolveGuild.NoRole);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.GuildInstance == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_DissolveGuild.RoleNoGuild);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.RoleData.GuildPost != (byte)CSCommon.eGuildPost.BangZhu)
            {
                retPkg.Write((sbyte)CSCommon.eRet_DissolveGuild.RoleIsNotBangZhu);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            retPkg.Write((sbyte)CSCommon.eRet_DissolveGuild.Succeed);
            foreach (var i in role.GuildInstance.Members)
            {
                var member = GetRole(i.Key);
                if (member == null)
                {
                    continue;
                }
                if (member.RoleData.GuildPost == (byte)CSCommon.eGuildPost.BangZhu)
                {
                    continue;
                }
                RoleLeave(member);
                CreateMailAndSend(i.Key, CSCommon.eMailFromType.RoleDissolveGuild, role.RoleData.Name);
            }
            role.GuildInstance.Members.Clear();
            GuildManager.Instance.RemoveGuildInstance(role.GuildInstance.GuildData.GuildId);
            DB_DelGuildCom(role.GuildInstance.GuildData);
            RoleLeave(role);
            retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #20
0
        public void RPC_CreateGuild(ulong roleId, string GuildName, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter retPkg = new RPC.PackageWriter();
            var role = GetRole(roleId);

            if (role == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_CreateGuild.NoRole);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.GuildInstance != null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_CreateGuild.RoleHasGuild);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }

            GuildInstance GuildInstance = new GuildInstance();

            CSCommon.Data.GuildCom guild = new CSCommon.Data.GuildCom();
            guild.GuildName     = GuildName;
            guild.PlanesId      = role.RoleData.PlanesId;
            guild.PresidentName = role.RoleData.Name;
            guild.MemberNum     = 1;
            if (DB_CreatGuildCom(guild) == false)
            {
                retPkg.Write((sbyte)CSCommon.eRet_CreateGuild.SameGuildName);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            role.RoleData.GuildId   = guild.GuildId;
            role.RoleData.GuildPost = (byte)CSCommon.eGuildPost.BangZhu;
            role.GuildInstance      = GuildInstance;

            GuildInstance.GuildData = guild;
            GuildInstance.Members.Add(roleId, role);
            GuildManager.Instance.AddGuildInstance(GuildInstance);

            //存盘,这里后面要改成异步执行
            DB_SaveRoleData(role);

            retPkg.Write((sbyte)CSCommon.eRet_CreateGuild.Succeed);
            retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #21
0
        public void RPC_IssueGold(ulong roleId, int gold, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter retPkg = new RPC.PackageWriter();
            var role = GetRole(roleId);

            if (role == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_IssueGold.NoRole);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.GuildInstance == null)
            {
                retPkg.Write((sbyte)CSCommon.eRet_IssueGold.RoleNoGuild);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.RoleData.GuildPost < (byte)CSCommon.eGuildPost.ZhangLao)
            {
                retPkg.Write((sbyte)CSCommon.eRet_IssueGold.RoleNoPower);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }

            ulong need = (ulong)(role.GuildInstance.GuildData.MemberNum * gold);

            if (need > role.GuildInstance.GuildData.GuildGold)
            {
                retPkg.Write((sbyte)CSCommon.eRet_IssueGold.GuildLessGold);
                retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }

            role.GuildInstance.GuildData.GuildGold -= need;

            //通过邮件发送给所有帮会成员
            string currencies = GetStr((int)CSCommon.eCurrenceType.Gold, gold);

            foreach (var i in role.GuildInstance.Members)
            {
                CreateMailAndSend(i.Key, CSCommon.eMailFromType.GuildSendGold, "", "", currencies);
            }
            retPkg.Write((sbyte)CSCommon.eRet_IssueGold.Succeed);
            retPkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #22
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);
        }
Пример #23
0
        public void RPC_LeaveTeam(ulong roleId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            var role = GetRole(roleId);

            if (role == null)
            {
                pkg.Write((sbyte)CSCommon.eRet_Team.NoRole);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (role.TeamHeaderId == 0)
            {
                pkg.Write((sbyte)CSCommon.eRet_Team.RoleNoTeam);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            _LeaveTeam(role, role.TeamHeaderId);
            pkg.Write((sbyte)CSCommon.eRet_Team.Succeed);
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #24
0
        public void RPC_ConsignItem(ulong roleId, int templateId, int stack, int price, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            var role = GetRole(roleId);

            if (role == null)
            {
                pkg.Write((sbyte)CSCommon.eRet_ConsignItem.NoRole);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (CSCommon.ItemCommon.Instance == null)
            {
                Log.Log.Item.Print("CSCommon.ItemCommon.Instance == null");
                pkg.Write((sbyte)CSCommon.eRet_ConsignItem.LessTemp);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            byte roleMaxGirdNum = CSCommon.ItemCommon.Instance.MaxConsignNum;

            string strSQL = "select * from ConsignGirdData where OwnerId = " + roleId;
            List <CSCommon.Data.ConsignGridData> datas = SelectGird(strSQL);

            if (datas.Count >= roleMaxGirdNum)
            {
                pkg.Write((sbyte)CSCommon.eRet_ConsignItem.OverMaxNum);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            var gird = CreateConsignGird(roleId, templateId, stack, price);

            if (gird == null)
            {
                pkg.Write((sbyte)CSCommon.eRet_ConsignItem.DBError);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            pkg.Write((sbyte)CSCommon.eRet_ConsignItem.Succeed);
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #25
0
        public void RPC_GetMyRank(ulong id, byte type, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            var rank = GetRank(id);

            if (rank == null)
            {
                Log.Log.Common.Info("RPC_GetMyRank GetRank null{0}", id);
                pkg.Write((sbyte)-1);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            if (type >= (byte)CSCommon.eRankType.Max)
            {
                Log.Log.Common.Info("RPC_GetMyRank type error{0}", type);
                pkg.Write((sbyte)-2);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            pkg.Write((sbyte)1);
            string sort = "";

            _GetSort(type, ref sort);
            int             nowrank   = 0;//现在排名
            List <RankData> toplist   = new List <RankData>();
            string          condition = "PlanesId = \'" + rank.PlanesId + "\'";

            nowrank = _GetMyRank(id, toplist, condition, sort, 10);
            pkg.Write(nowrank);
            pkg.Write((byte)toplist.Count);
            foreach (var i in toplist)
            {
                pkg.Write(i.RoleName);
                pkg.Write(i.Level);
                int value = _GetReturnRankValue(type, i);
                pkg.Write(value);
            }
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #26
0
        public void RPC_OneKeyGetItems(ulong roleId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter             pkg   = new RPC.PackageWriter();
            List <CSCommon.Data.MailData> mails = GetMailsWithItems(roleId);

            pkg.Write(mails.Count);
            for (int i = 0; i < mails.Count; i++)
            {
                pkg.Write(mails[i]);
            }
            mails.Clear();
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #27
0
        public void RPC_GetRoleGird(ulong roleId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            var role = GetRole(roleId);

            if (role == null)
            {
                pkg.Write((sbyte)-1);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            pkg.Write((sbyte)1);
            string strSQL = "select * from ConsignGirdData where OwnerId = " + roleId;
            List <CSCommon.Data.ConsignGridData> datas = SelectGird(strSQL);
            int count = datas.Count;

            pkg.Write(count);
            for (int i = 0; i < count; i++)
            {
                pkg.Write(datas[i]);
            }
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #28
0
        public void RPC_GetConsignItem(ulong roleId, ulong itemId, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            var role = GetRole(roleId);

            if (role == null)
            {
                pkg.Write((sbyte)CSCommon.eRet_BuyConsignItem.NoRole);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            var gird = GetGird(itemId);

            if (gird == null)
            {
                pkg.Write((sbyte)CSCommon.eRet_BuyConsignItem.NoItem);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            pkg.Write((sbyte)CSCommon.eRet_BuyConsignItem.Succeed);
            pkg.Write(gird.Price);
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #29
0
        public void RPC_GetSocialList(ulong roleId, byte type, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            RPC.PackageWriter pkg = new RPC.PackageWriter();
            pkg.SetSinglePkg();
            var role = this.GetRole(roleId);

            if (role == null)
            {
                Log.Log.Social.Print("role is null , {0}", roleId);
                pkg.Write((sbyte)-1);
                pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
                return;
            }
            UpdateSocialInfoList((CSCommon.eSocialType)type, role);
            pkg.Write((sbyte)1);
            pkg.Write(role.mSocialInfoList.Count);
            foreach (var s in role.mSocialInfoList.Values)
            {
                pkg.Write(s);
                pkg.Write(s.socialData);
            }
            pkg.DoReturnCommand2(connect, fwd.ReturnSerialId);
        }
Пример #30
0
        public void GetRoleDetailByName(ushort planesId, string roleName, Iocp.NetConnection connect, RPC.RPCForwardInfo fwd)
        {
            roleName = ServerFrame.DB.DBConnect.SqlSafeString(roleName);
            UInt16 returnSerialId = fwd.ReturnSerialId;

            AsyncExecuteThreadManager.Instance.AsyncExe(true).Exec = delegate()
            {
                RPC.PackageWriter retPkg = new RPC.PackageWriter();
                var acInfo = mPlayerManager.FindPlayerData(planesId, roleName);

                if (acInfo != null)
                {
                    retPkg.Write((SByte)1);
                    retPkg.Write(acInfo.RoleDetail);
                    retPkg.DoReturnCommand2(connect, returnSerialId);
                }
                else
                {
                    CSCommon.Data.RoleDetail rd    = new CSCommon.Data.RoleDetail();
                    string condition               = "RoleName = \'" + roleName + "\'";
                    ServerFrame.DB.DBOperator dbOp = ServerFrame.DB.DBConnect.SelectData(condition, rd, null);
                    System.Data.DataTable     tab  = DBLoaderConnect._ExecuteSelect(dbOp, "RoleInfo");
                    if (tab == null || tab.Rows.Count != 1)
                    {
                        retPkg.Write((SByte)(-1));
                        retPkg.DoReturnCommand2(connect, returnSerialId);
                    }
                    else
                    {
                        ServerFrame.DB.DBConnect.FillObject(rd, tab.Rows[0]);
                        retPkg.Write((SByte)1);
                        retPkg.Write(rd);
                        retPkg.DoReturnCommand2(connect, returnSerialId);
                    }
                }
            };
        }