Ejemplo n.º 1
0
        public bool AddGuildInstance(GuildInstance guild)
        {
            if (mGuilds.ContainsValue(guild))
            {
                return(false);
            }

            mGuilds.Add(guild.GuildData.GuildId, guild);
            return(true);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public void DissolveGuild(ulong guildId)
        {
            GuildInstance guild = null;

            mGuilds.TryGetValue(guildId, out guild);
            if (guild == null)
            {
                return;
            }

            foreach (var i in guild.Members)
            {
                UserRoleManager.Instance.DissolveGuildMember(guild.GuildData.GuildId, i.Key);
            }
            guild.Members.Clear();
            RemoveGuildInstance(guildId);
            UserRoleManager.Instance.DB_DelGuildCom(guild.GuildData);
        }
Ejemplo n.º 4
0
        private GuildInstance DB_LoadGuild(ulong guildId)
        {
            GuildInstance guild = new GuildInstance();

            var condition = "GuildId=" + guildId;
            var dbOp      = ServerFrame.DB.DBConnect.SelectData(condition, guild.GuildData, "");
            var tab       = UserRoleManager.Instance.DBConnect._ExecuteSelect(dbOp, "GuildCom");

            if (tab == null || tab.Rows.Count != 1)
            {
                return(null);
            }

            if (false == ServerFrame.DB.DBConnect.FillObject(guild.GuildData, tab.Rows[0]))
            {
                return(null);
            }

            return(guild);
        }
Ejemplo n.º 5
0
        public void DB_InitAllGuildMember(GuildInstance guild)
        {
            ServerFrame.DB.DBOperator dbOp = new ServerFrame.DB.DBOperator();
            dbOp.SqlCode = "select RoleId from RoleCom where GuildId=\'" + guild.GuildData.GuildId + "\'";
            var tab = UserRoleManager.Instance.DBConnect._ExecuteSelect(dbOp, "RoleCom");

            if (tab == null || tab.Rows.Count < 1)
            {
                return;
            }

            for (int i = 0; i < tab.Rows.Count; i++)
            {
                ulong roleId = (ulong)tab.Rows[i]["RoleId"];
                if (roleId != 0)
                {
                    var role = UserRoleManager.Instance.GetRole(roleId);
                    if (role != null)
                    {
                        guild.Members.Add(roleId, role);
                    }
                }
            }
        }