public bool LoadMembersFromDB(SQLResult result) { if (result.IsEmpty()) { return(false); } bool captainPresentInTeam = false; do { uint arenaTeamId = result.Read <uint>(0); // We loaded all members for this arena_team already, break cycle if (arenaTeamId > teamId) { break; } ArenaTeamMember newMember = new ArenaTeamMember(); newMember.Guid = ObjectGuid.Create(HighGuid.Player, result.Read <ulong>(1)); newMember.WeekGames = result.Read <ushort>(2); newMember.WeekWins = result.Read <ushort>(3); newMember.SeasonGames = result.Read <ushort>(4); newMember.SeasonWins = result.Read <ushort>(5); newMember.Name = result.Read <string>(6); newMember.Class = result.Read <byte>(7); newMember.PersonalRating = result.Read <ushort>(8); newMember.MatchMakerRating = (ushort)(result.Read <ushort>(9) > 0 ? result.Read <ushort>(9) : 1500); // Delete member if character information is missing if (string.IsNullOrEmpty(newMember.Name)) { Log.outError(LogFilter.Sql, "ArenaTeam {0} has member with empty name - probably {1} doesn't exist, deleting him from memberlist!", arenaTeamId, newMember.Guid.ToString()); DelMember(newMember.Guid, true); continue; } // Check if team team has a valid captain if (newMember.Guid == GetCaptain()) { captainPresentInTeam = true; } // Put the player in the team Members.Add(newMember); Global.CharacterCacheStorage.UpdateCharacterArenaTeamId(newMember.Guid, GetSlot(), GetId()); }while (result.NextRow()); if (Empty() || !captainPresentInTeam) { // Arena team is empty or captain is not in team, delete from db Log.outDebug(LogFilter.Arena, "ArenaTeam {0} does not have any members or its captain is not in team, disbanding it...", teamId); return(false); } return(true); }
public void Inspect(WorldSession session, ObjectGuid guid) { ArenaTeamMember member = GetMember(guid); if (member == null) { return; } WorldPacket data = new WorldPacket(ServerOpcodes.InspectPvp); data.WritePackedGuid(guid); // player guid data.WriteUInt8(GetSlot()); // slot (0...2) data.WriteUInt32(GetId()); // arena team id data.WriteUInt32(stats.Rating); // rating data.WriteUInt32(stats.SeasonGames); // season played data.WriteUInt32(stats.SeasonWins); // season wins data.WriteUInt32(member.SeasonGames); // played (count of all games, that the inspected member participated...) data.WriteUInt32(member.PersonalRating); // personal rating //session.SendPacket(data); }
public bool AddMember(ObjectGuid playerGuid) { string playerName; Class playerClass; // Check if arena team is full (Can't have more than type * 2 players) if (GetMembersSize() >= GetArenaType() * 2) { return(false); } // Get player name and class either from db or ObjectMgr CharacterInfo characterInfo; Player player = Global.ObjAccessor.FindPlayer(playerGuid); if (player) { playerClass = player.GetClass(); playerName = player.GetName(); } else if ((characterInfo = Global.WorldMgr.GetCharacterInfo(playerGuid)) != null) { playerName = characterInfo.Name; playerClass = characterInfo.ClassID; } else { return(false); } // Check if player is already in a similar arena team if ((player && player.GetArenaTeamId(GetSlot()) != 0) || Player.GetArenaTeamIdFromDB(playerGuid, GetArenaType()) != 0) { Log.outDebug(LogFilter.Arena, "Arena: {0} {1} already has an arena team of type {2}", playerGuid.ToString(), playerName, GetArenaType()); return(false); } // Set player's personal rating uint personalRating = 0; if (WorldConfig.GetIntValue(WorldCfg.ArenaStartPersonalRating) > 0) { personalRating = WorldConfig.GetUIntValue(WorldCfg.ArenaStartPersonalRating); } else if (GetRating() >= 1000) { personalRating = 1000; } // Try to get player's match maker rating from db and fall back to config setting if not found PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_MATCH_MAKER_RATING); stmt.AddValue(0, playerGuid.GetCounter()); stmt.AddValue(1, GetSlot()); SQLResult result = DB.Characters.Query(stmt); uint matchMakerRating; if (!result.IsEmpty()) { matchMakerRating = result.Read <ushort>(0); } else { matchMakerRating = WorldConfig.GetUIntValue(WorldCfg.ArenaStartMatchmakerRating); } // Remove all player signatures from other petitions // This will prevent player from joining too many arena teams and corrupt arena team data integrity //Player.RemovePetitionsAndSigns(playerGuid, GetArenaType()); // Feed data to the struct ArenaTeamMember newMember = new ArenaTeamMember(); newMember.Name = playerName; newMember.Guid = playerGuid; newMember.Class = (byte)playerClass; newMember.SeasonGames = 0; newMember.WeekGames = 0; newMember.SeasonWins = 0; newMember.WeekWins = 0; newMember.PersonalRating = (ushort)(uint)0; newMember.MatchMakerRating = (ushort)matchMakerRating; Members.Add(newMember); // Save player's arena team membership to db stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_ARENA_TEAM_MEMBER); stmt.AddValue(0, teamId); stmt.AddValue(1, playerGuid.GetCounter()); DB.Characters.Execute(stmt); // Inform player if online if (player) { player.SetInArenaTeam(teamId, GetSlot(), GetArenaType()); player.SetArenaTeamIdInvited(0); // Hide promote/remove buttons if (CaptainGuid != playerGuid) { player.SetArenaTeamInfoField(GetSlot(), ArenaTeamInfoType.Member, 1); } } Log.outDebug(LogFilter.Arena, "Player: {0} [{1}] joined arena team type: {2} [Id: {3}, Name: {4}].", playerName, playerGuid.ToString(), GetArenaType(), GetId(), GetName()); return(true); }