Core/Arenas: Refactor arena code and db layout
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -72,16 +72,6 @@ ERR_ARENA_TEAM_TOO_MANY_MEMBERS_S
|
||||
ERR_ARENA_TEAM_LEVEL_TOO_LOW_I
|
||||
*/
|
||||
|
||||
enum ArenaTeamStatTypes
|
||||
{
|
||||
STAT_TYPE_RATING = 0,
|
||||
STAT_TYPE_GAMES_WEEK = 1,
|
||||
STAT_TYPE_WINS_WEEK = 2,
|
||||
STAT_TYPE_GAMES_SEASON = 3,
|
||||
STAT_TYPE_WINS_SEASON = 4,
|
||||
STAT_TYPE_RANK = 5
|
||||
};
|
||||
|
||||
enum ArenaTeamTypes
|
||||
{
|
||||
ARENA_TEAM_2v2 = 2,
|
||||
@@ -91,15 +81,15 @@ enum ArenaTeamTypes
|
||||
|
||||
struct ArenaTeamMember
|
||||
{
|
||||
uint64 guid;
|
||||
std::string name;
|
||||
uint64 Guid;
|
||||
std::string Name;
|
||||
uint8 Class;
|
||||
uint32 games_week;
|
||||
uint32 wins_week;
|
||||
uint32 games_season;
|
||||
uint32 wins_season;
|
||||
uint32 personal_rating;
|
||||
uint32 matchmaker_rating;
|
||||
uint16 WeekGames;
|
||||
uint16 WeekWins;
|
||||
uint16 SeasonGames;
|
||||
uint16 SeasonWins;
|
||||
uint16 PersonalRating;
|
||||
uint16 MatchMakerRating;
|
||||
|
||||
void ModifyPersonalRating(Player* plr, int32 mod, uint32 slot);
|
||||
void ModifyMatchmakerRating(int32 mod, uint32 slot);
|
||||
@@ -107,12 +97,12 @@ struct ArenaTeamMember
|
||||
|
||||
struct ArenaTeamStats
|
||||
{
|
||||
uint32 rating;
|
||||
uint32 games_week;
|
||||
uint32 wins_week;
|
||||
uint32 games_season;
|
||||
uint32 wins_season;
|
||||
uint32 rank;
|
||||
uint16 Rating;
|
||||
uint16 WeekGames;
|
||||
uint16 WeekWins;
|
||||
uint16 SeasonGames;
|
||||
uint16 SeasonWins;
|
||||
uint32 Rank;
|
||||
};
|
||||
|
||||
#define MAX_ARENA_SLOT 3 // 0..2 slots
|
||||
@@ -123,109 +113,84 @@ class ArenaTeam
|
||||
ArenaTeam();
|
||||
~ArenaTeam();
|
||||
|
||||
bool Create(uint64 captainGuid, uint32 type, std::string ArenaTeamName);
|
||||
void Disband(WorldSession *session);
|
||||
bool Create(uint32 captainGuid, uint8 type, std::string teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor);
|
||||
void Disband(WorldSession* session);
|
||||
|
||||
typedef std::list<ArenaTeamMember> MemberList;
|
||||
|
||||
uint32 GetId() const { return m_TeamId; }
|
||||
uint32 GetType() const { return m_Type; }
|
||||
uint32 GetId() const { return TeamId; }
|
||||
uint32 GetType() const { return Type; }
|
||||
uint8 GetSlot() const { return GetSlotByType(GetType()); }
|
||||
static uint8 GetSlotByType(uint32 type);
|
||||
const uint64& GetCaptain() const { return m_CaptainGuid; }
|
||||
std::string GetName() const { return m_Name; }
|
||||
const ArenaTeamStats& GetStats() const { return m_stats; }
|
||||
void SetStats(uint32 stat_type, uint32 value);
|
||||
uint32 GetRating() const { return m_stats.rating; }
|
||||
uint32 GetAverageMMR(Group *group) const;
|
||||
const uint64& GetCaptain() const { return CaptainGuid; }
|
||||
std::string GetName() const { return TeamName; }
|
||||
const ArenaTeamStats& GetStats() const { return Stats; }
|
||||
|
||||
uint32 GetEmblemStyle() const { return m_EmblemStyle; }
|
||||
uint32 GetEmblemColor() const { return m_EmblemColor; }
|
||||
uint32 GetBorderStyle() const { return m_BorderStyle; }
|
||||
uint32 GetBorderColor() const { return m_BorderColor; }
|
||||
uint32 GetBackgroundColor() const { return m_BackgroundColor; }
|
||||
uint32 GetRating() const { return Stats.Rating; }
|
||||
uint32 GetAverageMMR(Group* group) const;
|
||||
|
||||
void SetCaptain(const uint64& guid);
|
||||
bool AddMember(const uint64& PlayerGuid);
|
||||
|
||||
// Shouldn't be const uint64& ed, because than can reference guid from members on Disband
|
||||
// and this method removes given record from list. So invalid reference can happen.
|
||||
void DelMember(uint64 guid);
|
||||
void DelMember(uint64 guid, bool cleanDb);
|
||||
|
||||
void SetEmblem(uint32 backgroundColor, uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor);
|
||||
size_t GetMembersSize() const { return Members.size(); }
|
||||
bool Empty() const { return Members.empty(); }
|
||||
MemberList::iterator m_membersBegin() { return Members.begin(); }
|
||||
MemberList::iterator m_membersEnd() { return Members.end(); }
|
||||
bool IsMember(const uint64& guid) const;
|
||||
|
||||
size_t GetMembersSize() const { return m_members.size(); }
|
||||
bool Empty() const { return m_members.empty(); }
|
||||
MemberList::iterator m_membersBegin() { return m_members.begin(); }
|
||||
MemberList::iterator m_membersEnd() { return m_members.end(); }
|
||||
bool HaveMember(const uint64& guid) const;
|
||||
|
||||
ArenaTeamMember* GetMember(const uint64& guid)
|
||||
{
|
||||
for (MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
|
||||
if (itr->guid == guid)
|
||||
return &(*itr);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ArenaTeamMember* GetMember(const std::string& name)
|
||||
{
|
||||
for (MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
|
||||
if (itr->name == name)
|
||||
return &(*itr);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
ArenaTeamMember* GetMember(const uint64& guid);
|
||||
ArenaTeamMember* GetMember(const std::string& name);
|
||||
|
||||
bool IsFighting() const;
|
||||
|
||||
bool LoadArenaTeamFromDB(QueryResult arenaTeamDataResult);
|
||||
bool LoadMembersFromDB(QueryResult arenaTeamMembersResult);
|
||||
void LoadStatsFromDB(uint32 ArenaTeamId);
|
||||
|
||||
void SaveToDB();
|
||||
|
||||
void BroadcastPacket(WorldPacket *packet);
|
||||
void BroadcastPacket(WorldPacket* packet);
|
||||
void BroadcastEvent(ArenaTeamEvents event, uint64 guid, uint8 strCount, std::string str1, std::string str2, std::string str3);
|
||||
void NotifyStatsChanged();
|
||||
|
||||
void Roster(WorldSession *session);
|
||||
void Query(WorldSession *session);
|
||||
void Stats(WorldSession *session);
|
||||
void InspectStats(WorldSession *session, uint64 guid);
|
||||
void Roster(WorldSession* session);
|
||||
void Query(WorldSession* session);
|
||||
void SendStats(WorldSession* session);
|
||||
void Inspect(WorldSession* session, uint64 guid);
|
||||
|
||||
uint32 GetPoints(uint32 MemberRating);
|
||||
int32 GetRatingMod(uint32 own_rating, uint32 enemy_rating, bool won, bool calculating_mmr = false);
|
||||
int32 GetPersonalRatingMod(int32 base_rating, uint32 own_rating, uint32 enemy_rating);
|
||||
float GetChanceAgainst(uint32 own_rating, uint32 enemy_rating);
|
||||
int32 WonAgainst(uint32 againstRating);
|
||||
void MemberWon(Player * plr, uint32 againstMatchmakerRating, int32 teamratingchange = 12);
|
||||
int32 LostAgainst(uint32 againstRating);
|
||||
void MemberLost(Player * plr, uint32 againstMatchmakerRating, int32 teamratingchange = -12);
|
||||
void OfflineMemberLost(uint64 guid, uint32 againstMatchmakerRating, int32 teamratingchange = -12);
|
||||
int32 GetRatingMod(uint32 ownRating, uint32 opponentRating, bool won, bool calculating_mmr = false);
|
||||
int32 GetPersonalRatingMod(int32 base_rating, uint32 ownRating, uint32 opponentRating);
|
||||
float GetChanceAgainst(uint32 ownRating, uint32 opponentRating);
|
||||
int32 WonAgainst(uint32 againstRating);
|
||||
void MemberWon(Player* plr, uint32 againstMatchmakerRating, int32 teamratingchange = 12);
|
||||
int32 LostAgainst(uint32 againstRating);
|
||||
void MemberLost(Player* plr, uint32 againstMatchmakerRating, int32 teamratingchange = -12);
|
||||
void OfflineMemberLost(uint64 guid, uint32 againstMatchmakerRating, int32 teamratingchange = -12);
|
||||
|
||||
void UpdateArenaPointsHelper(std::map<uint32, uint32> & PlayerPoints);
|
||||
|
||||
void NotifyStatsChanged();
|
||||
|
||||
void FinishWeek();
|
||||
void FinishGame(int32 mod);
|
||||
|
||||
protected:
|
||||
|
||||
uint32 m_TeamId;
|
||||
uint32 m_Type;
|
||||
std::string m_Name;
|
||||
uint64 m_CaptainGuid;
|
||||
uint32 TeamId;
|
||||
uint8 Type;
|
||||
std::string TeamName;
|
||||
uint64 CaptainGuid;
|
||||
|
||||
uint32 m_BackgroundColor; // ARGB format
|
||||
uint32 m_EmblemStyle; // icon id
|
||||
uint32 m_EmblemColor; // ARGB format
|
||||
uint32 m_BorderStyle; // border image id
|
||||
uint32 m_BorderColor; // ARGB format
|
||||
uint32 BackgroundColor; // ARGB format
|
||||
uint8 EmblemStyle; // icon id
|
||||
uint32 EmblemColor; // ARGB format
|
||||
uint8 BorderStyle; // border image id
|
||||
uint32 BorderColor; // ARGB format
|
||||
|
||||
MemberList m_members;
|
||||
ArenaTeamStats m_stats;
|
||||
MemberList Members;
|
||||
ArenaTeamStats Stats;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -775,7 +775,7 @@ void Battleground::EndBattleground(uint32 winner)
|
||||
// update achievement BEFORE personal rating update
|
||||
ArenaTeamMember* member = winner_arena_team->GetMember(plr->GetGUID());
|
||||
if (member)
|
||||
plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, member->personal_rating);
|
||||
plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, member->PersonalRating);
|
||||
|
||||
winner_arena_team->MemberWon(plr,loser_matchmaker_rating, winner_change);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user