private void Validate() { foreach (Guild guild in guildList.Values) { if (guild.GetRankSize() < Guild.MinRanks || guild.GetRankSize() > Guild.MaxRanks) { Log.outError("Guild {0} has invalid number of ranks, Creating new...", guild.Guid); guild.RankList.Clear(); guild.CreateDefaultRanks(); } List <Guild.Member> brokenrank = guild.MemberList.Where(m => m.RankId > guild.GetRankSize()).ToList(); foreach (Guild.Member member in brokenrank) { member.ChangeRank((uint)(guild.GetLowestRank())); } Guild.Member leader = guild.GetMember(guild.GetLeaderGuid()); if (leader == null) { guild.DeleteMember(guild.GetLeaderGuid()); if (guild.MemberList.Count == 0) { guild.Disband(); return; } } else if (leader.RankId != (uint)GuildDefaultRanks.Master) { guild.SetLeader(leader); } } }
private void LoadGuildMembers() { //guid, rank, pnote, offnote, BankResetTimeMoney, BankRemMoney, BankResetTimeTab0, BankRemSlotsTab0, BankResetTimeTab1, BankRemSlotsTab1, BankResetTimeTab2, BankRemSlotsTab2, //BankResetTimeTab3, BankRemSlotsTab3, BankResetTimeTab4, BankRemSlotsTab4, BankResetTimeTab5, BankRemSlotsTab5, BankResetTimeTab6, BankRemSlotsTab6, BankResetTimeTab7, BankRemSlotsTab7, //FirstProffLevel, FirstProffSkill, FirstProffRank, SecondProffLevel, SecondProffSkill, SecondProffRank SQLResult result = DB.Characters.Select("SELECT gm.*, c.name, c.level, c.class, c.zone FROM guild_members gm LEFT JOIN characters c ON c.guid = gm.CharGuid ORDER by gm.GuildGuid ASC"); if (result.Count == 0) { Log.outError("Loaded 0 guild_members. DB table `guild_members` is empty."); return; } for (int i = 0; i < result.Count; i++) { Guild g = GetGuildByGuid(result.Read <ulong>(i, "GuildGuid")); if (g == null) { continue; } Guild.Member m = new Guild.Member(); m.CharGuid = new ObjectGuid(result.Read <ulong>(i, 1)); m.RankId = result.Read <uint>(i, 2); m.PublicNote = result.Read <string>(i, 3); m.OfficerNote = result.Read <string>(i, 4); m.BankResetTimeMoney = result.Read <uint>(i, 5); m.BankRemainingMoney = result.Read <uint>(i, 6); for (int j = 0; j < Guild.MaxBankTabs; j++) { Guild.Member.BankTabs tab = new Guild.Member.BankTabs(); tab.ResetTime = result.Read <uint>(i, (byte)(7 + (j * 2))); tab.SlotsLeft = result.Read <uint>(i, (byte)(8 + (j * 2))); m.BanksTabs.Add(tab); } for (int k = 0; k < 2; k++) { Guild.Member.Profession prof = new Guild.Member.Profession(); prof.Level = result.Read <uint>(i, (byte)(23 + (k * 3))); prof.SkillId = result.Read <uint>(i, (byte)(24 + (k * 3))); prof.Rank = result.Read <uint>(i, (byte)(25 + (k * 3))); m.ProfessionList.Add(prof); } m.Name = result.Read <string>(i, 29); m.Level = result.Read <Byte>(i, 30); m.Class = result.Read <Byte>(i, 31); m.ZoneId = result.Read <uint>(i, 32); //m.LogoutTime = result.Read<ulong>(i, 33); m.Flags = (uint)GuildMemberFlags.Online; g.MemberList.Add(m); } }