Core/ObjectMgr: Refactor arena team related functions into dedicated class
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "DBCEnums.h"
|
#include "DBCEnums.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
#include "ArenaTeamMgr.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
#include "DatabaseEnv.h"
|
#include "DatabaseEnv.h"
|
||||||
@@ -1515,7 +1516,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
|
|||||||
{
|
{
|
||||||
for (uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot)
|
for (uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot)
|
||||||
if (uint32 arena_team_id = GetPlayer()->GetArenaTeamId(arena_slot))
|
if (uint32 arena_team_id = GetPlayer()->GetArenaTeamId(arena_slot))
|
||||||
if (ArenaTeam * at = sObjectMgr->GetArenaTeamById(arena_team_id))
|
if (ArenaTeam * at = sArenaTeamMgr->GetArenaTeamById(arena_team_id))
|
||||||
if (at->GetType() == reqTeamType)
|
if (at->GetType() == reqTeamType)
|
||||||
{
|
{
|
||||||
SetCriteriaProgress(achievementCriteria, at->GetStats().Rating, PROGRESS_HIGHEST);
|
SetCriteriaProgress(achievementCriteria, at->GetStats().Rating, PROGRESS_HIGHEST);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "ArenaTeam.h"
|
#include "ArenaTeam.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
|
#include "ArenaTeamMgr.h"
|
||||||
|
|
||||||
ArenaTeam::ArenaTeam()
|
ArenaTeam::ArenaTeam()
|
||||||
{
|
{
|
||||||
@@ -52,12 +53,12 @@ bool ArenaTeam::Create(uint32 captainGuid, uint8 type, std::string teamName, uin
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check if arena team name is already taken
|
// Check if arena team name is already taken
|
||||||
if (sObjectMgr->GetArenaTeamByName(TeamName))
|
if (sArenaTeamMgr->GetArenaTeamByName(TeamName))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
// Generate new arena team id
|
// Generate new arena team id
|
||||||
TeamId = sObjectMgr->GenerateArenaTeamId();
|
TeamId = sArenaTeamMgr->GenerateArenaTeamId();
|
||||||
|
|
||||||
// Assign member variables
|
// Assign member variables
|
||||||
CaptainGuid = captainGuid;
|
CaptainGuid = captainGuid;
|
||||||
@@ -360,7 +361,7 @@ void ArenaTeam::Disband(WorldSession* session)
|
|||||||
CharacterDatabase.CommitTransaction(trans);
|
CharacterDatabase.CommitTransaction(trans);
|
||||||
|
|
||||||
// Remove arena team from ObjectMgr
|
// Remove arena team from ObjectMgr
|
||||||
sObjectMgr->RemoveArenaTeam(TeamId);
|
sArenaTeamMgr->RemoveArenaTeam(TeamId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArenaTeam::Roster(WorldSession* session)
|
void ArenaTeam::Roster(WorldSession* session)
|
||||||
@@ -662,8 +663,8 @@ void ArenaTeam::FinishGame(int32 mod)
|
|||||||
|
|
||||||
// Update team's rank, start with rank 1 and increase until no team with more rating was found
|
// Update team's rank, start with rank 1 and increase until no team with more rating was found
|
||||||
Stats.Rank = 1;
|
Stats.Rank = 1;
|
||||||
ObjectMgr::ArenaTeamMap::const_iterator i = sObjectMgr->GetArenaTeamMapBegin();
|
ArenaTeamMgr::ArenaTeamContainer::const_iterator i = sArenaTeamMgr->GetArenaTeamMapBegin();
|
||||||
for (; i != sObjectMgr->GetArenaTeamMapEnd(); ++i)
|
for (; i != sArenaTeamMgr->GetArenaTeamMapEnd(); ++i)
|
||||||
{
|
{
|
||||||
if (i->second->GetType() == Type && i->second->GetStats().Rating > Stats.Rating)
|
if (i->second->GetType() == Type && i->second->GetStats().Rating > Stats.Rating)
|
||||||
++Stats.Rank;
|
++Stats.Rank;
|
||||||
|
|||||||
@@ -0,0 +1,179 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Common.h"
|
||||||
|
#include "ArenaTeamMgr.h"
|
||||||
|
|
||||||
|
ArenaTeamMgr::ArenaTeamMgr()
|
||||||
|
{
|
||||||
|
NextArenaTeamId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArenaTeamMgr::~ArenaTeamMgr()
|
||||||
|
{
|
||||||
|
for (ArenaTeamContainer::iterator itr = ArenaTeamStore.begin(); itr != ArenaTeamStore.end(); ++itr)
|
||||||
|
delete itr->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Arena teams collection
|
||||||
|
ArenaTeam* ArenaTeamMgr::GetArenaTeamById(uint32 arenaTeamId) const
|
||||||
|
{
|
||||||
|
ArenaTeamContainer::const_iterator itr = ArenaTeamStore.find(arenaTeamId);
|
||||||
|
if (itr != ArenaTeamStore.end())
|
||||||
|
return itr->second;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArenaTeam* ArenaTeamMgr::GetArenaTeamByName(const std::string& arenaTeamName) const
|
||||||
|
{
|
||||||
|
std::string search = arenaTeamName;
|
||||||
|
std::transform(search.begin(), search.end(), search.begin(), ::toupper);
|
||||||
|
for (ArenaTeamContainer::const_iterator itr = ArenaTeamStore.begin(); itr != ArenaTeamStore.end(); ++itr)
|
||||||
|
{
|
||||||
|
std::string teamName = itr->second->GetName();
|
||||||
|
std::transform(teamName.begin(), teamName.end(), teamName.begin(), ::toupper);
|
||||||
|
if (search == teamName)
|
||||||
|
return itr->second;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArenaTeam* ArenaTeamMgr::GetArenaTeamByCaptain(uint64 const& guid) const
|
||||||
|
{
|
||||||
|
for (ArenaTeamContainer::const_iterator itr = ArenaTeamStore.begin(); itr != ArenaTeamStore.end(); ++itr)
|
||||||
|
if (itr->second->GetCaptain() == guid)
|
||||||
|
return itr->second;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArenaTeamMgr::AddArenaTeam(ArenaTeam* arenaTeam)
|
||||||
|
{
|
||||||
|
ArenaTeamStore[arenaTeam->GetId()] = arenaTeam;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArenaTeamMgr::RemoveArenaTeam(uint32 arenaTeamId)
|
||||||
|
{
|
||||||
|
ArenaTeamStore.erase(arenaTeamId);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 ArenaTeamMgr::GenerateArenaTeamId()
|
||||||
|
{
|
||||||
|
if (NextArenaTeamId >= 0xFFFFFFFE)
|
||||||
|
{
|
||||||
|
sLog->outError("Arena team ids overflow!! Can't continue, shutting down server. ");
|
||||||
|
World::StopNow(ERROR_EXIT_CODE);
|
||||||
|
}
|
||||||
|
return NextArenaTeamId++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArenaTeamMgr::LoadArenaTeams()
|
||||||
|
{
|
||||||
|
uint32 oldMSTime = getMSTime();
|
||||||
|
|
||||||
|
// Clean out the trash before loading anything
|
||||||
|
CharacterDatabase.Execute("DELETE FROM arena_team_member WHERE arenaTeamId NOT IN (SELECT arenaTeamId FROM arena_team)");
|
||||||
|
|
||||||
|
// 0 1 2 3 4 5 6 7 8
|
||||||
|
QueryResult result = CharacterDatabase.Query("SELECT arena_team.arenaTeamId, name, captainGuid, type, backgroundColor, emblemStyle, emblemColor, borderStyle, borderColor, "
|
||||||
|
// 9 10 11 12 13 14
|
||||||
|
"rating, weekGames, weekWins, seasonGames, seasonWins, rank FROM arena_team ORDER BY arena_team.arenaTeamId ASC");
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
sLog->outString(">> Loaded 0 arena teams. DB table `arena_team` is empty!");
|
||||||
|
sLog->outString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryResult result2 = CharacterDatabase.Query(
|
||||||
|
// 0 1 2 3 4 5 6 7 8 9
|
||||||
|
"SELECT arenaTeamId, atm.guid, atm.weekGames, atm.weekWins, atm.seasonGames, atm.seasonWins, c.name, class, personalRating, matchMakerRating FROM arena_team_member atm"
|
||||||
|
" INNER JOIN arena_team ate USING (arenaTeamId)"
|
||||||
|
" LEFT JOIN characters AS c ON atm.guid = c.guid"
|
||||||
|
" LEFT JOIN character_arena_stats AS cas ON c.guid = cas.guid AND (cas.slot = 0 AND ate.type = 2 OR cas.slot = 1 AND ate.type = 3 OR cas.slot = 2 AND ate.type = 5)"
|
||||||
|
" ORDER BY atm.arenateamid ASC");
|
||||||
|
|
||||||
|
uint32 count = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
ArenaTeam* newArenaTeam = new ArenaTeam;
|
||||||
|
|
||||||
|
if (!newArenaTeam->LoadArenaTeamFromDB(result) || !newArenaTeam->LoadMembersFromDB(result2))
|
||||||
|
{
|
||||||
|
newArenaTeam->Disband(NULL);
|
||||||
|
delete newArenaTeam;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
AddArenaTeam(newArenaTeam);
|
||||||
|
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
while (result->NextRow());
|
||||||
|
|
||||||
|
sLog->outString(">> Loaded %u arena teams in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||||
|
sLog->outString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArenaTeamMgr::DistributeArenaPoints()
|
||||||
|
{
|
||||||
|
// Used to distribute arena points based on last week's stats
|
||||||
|
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_START);
|
||||||
|
|
||||||
|
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_START);
|
||||||
|
|
||||||
|
// Temporary structure for storing maximum points to add values for all players
|
||||||
|
std::map<uint32, uint32> PlayerPoints;
|
||||||
|
|
||||||
|
// At first update all points for all team members
|
||||||
|
for (ArenaTeamContainer::iterator teamItr = GetArenaTeamMapBegin(); teamItr != GetArenaTeamMapEnd(); ++teamItr)
|
||||||
|
if (ArenaTeam * at = teamItr->second)
|
||||||
|
at->UpdateArenaPointsHelper(PlayerPoints);
|
||||||
|
|
||||||
|
// Cycle that gives points to all players
|
||||||
|
for (std::map<uint32, uint32>::iterator playerItr = PlayerPoints.begin(); playerItr != PlayerPoints.end(); ++playerItr)
|
||||||
|
{
|
||||||
|
// Update database
|
||||||
|
CharacterDatabase.PExecute("UPDATE characters SET arenaPoints = arenaPoints + '%u' WHERE guid = '%u'", playerItr->second, playerItr->first);
|
||||||
|
|
||||||
|
// Add points to player if online
|
||||||
|
Player* pl = sObjectMgr->GetPlayer(playerItr->first);
|
||||||
|
if (pl)
|
||||||
|
pl->ModifyArenaPoints(playerItr->second);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerPoints.clear();
|
||||||
|
|
||||||
|
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_END);
|
||||||
|
|
||||||
|
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_START);
|
||||||
|
for (ArenaTeamContainer::iterator titr = GetArenaTeamMapBegin(); titr != GetArenaTeamMapEnd(); ++titr)
|
||||||
|
{
|
||||||
|
if (ArenaTeam * at = titr->second)
|
||||||
|
{
|
||||||
|
at->FinishWeek();
|
||||||
|
at->SaveToDB();
|
||||||
|
at->NotifyStatsChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_END);
|
||||||
|
|
||||||
|
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_END);
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
* option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
* more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _ARENATEAMMGR_H
|
||||||
|
#define _ARENATEAMMGR_H
|
||||||
|
|
||||||
|
#include "ArenaTeam.h"
|
||||||
|
|
||||||
|
class ArenaTeamMgr
|
||||||
|
{
|
||||||
|
friend class ACE_Singleton<ArenaTeamMgr, ACE_Null_Mutex>;
|
||||||
|
ArenaTeamMgr();
|
||||||
|
~ArenaTeamMgr();
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef UNORDERED_MAP<uint32, ArenaTeam*> ArenaTeamContainer;
|
||||||
|
|
||||||
|
ArenaTeam* GetArenaTeamById(uint32 arenaTeamId) const;
|
||||||
|
ArenaTeam* GetArenaTeamByName(const std::string& arenaTeamName) const;
|
||||||
|
ArenaTeam* GetArenaTeamByCaptain(uint64 const& guid) const;
|
||||||
|
|
||||||
|
void LoadArenaTeams();
|
||||||
|
void AddArenaTeam(ArenaTeam* arenaTeam);
|
||||||
|
void RemoveArenaTeam(uint32 Id);
|
||||||
|
|
||||||
|
ArenaTeamContainer::iterator GetArenaTeamMapBegin() { return ArenaTeamStore.begin(); }
|
||||||
|
ArenaTeamContainer::iterator GetArenaTeamMapEnd() { return ArenaTeamStore.end(); }
|
||||||
|
|
||||||
|
void DistributeArenaPoints();
|
||||||
|
|
||||||
|
uint32 GenerateArenaTeamId();
|
||||||
|
void SetNextArenaTeamId(uint32 Id) { NextArenaTeamId = Id; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
uint32 NextArenaTeamId;
|
||||||
|
ArenaTeamContainer ArenaTeamStore;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define sArenaTeamMgr ACE_Singleton<ArenaTeamMgr, ACE_Null_Mutex>::instance()
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
#include "ArenaTeamMgr.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
|
|
||||||
@@ -689,8 +690,8 @@ void Battleground::EndBattleground(uint32 winner)
|
|||||||
// arena rating calculation
|
// arena rating calculation
|
||||||
if (isArena() && isRated())
|
if (isArena() && isRated())
|
||||||
{
|
{
|
||||||
winner_arena_team = sObjectMgr->GetArenaTeamById(GetArenaTeamIdForTeam(winner));
|
winner_arena_team = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(winner));
|
||||||
loser_arena_team = sObjectMgr->GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeam(winner)));
|
loser_arena_team = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeam(winner)));
|
||||||
if (winner_arena_team && loser_arena_team && winner_arena_team != loser_arena_team)
|
if (winner_arena_team && loser_arena_team && winner_arena_team != loser_arena_team)
|
||||||
{
|
{
|
||||||
if (winner != WINNER_NONE)
|
if (winner != WINNER_NONE)
|
||||||
@@ -929,8 +930,8 @@ void Battleground::RemovePlayerAtLeave(const uint64& guid, bool Transport, bool
|
|||||||
if (isRated() && GetStatus() == STATUS_IN_PROGRESS)
|
if (isRated() && GetStatus() == STATUS_IN_PROGRESS)
|
||||||
{
|
{
|
||||||
//left a rated match while the encounter was in progress, consider as loser
|
//left a rated match while the encounter was in progress, consider as loser
|
||||||
ArenaTeam * winner_arena_team = sObjectMgr->GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeam(team)));
|
ArenaTeam * winner_arena_team = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeam(team)));
|
||||||
ArenaTeam * loser_arena_team = sObjectMgr->GetArenaTeamById(GetArenaTeamIdForTeam(team));
|
ArenaTeam * loser_arena_team = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(team));
|
||||||
if (winner_arena_team && loser_arena_team && winner_arena_team != loser_arena_team)
|
if (winner_arena_team && loser_arena_team && winner_arena_team != loser_arena_team)
|
||||||
loser_arena_team->MemberLost(plr, GetArenaMatchmakerRating(GetOtherTeam(team)));
|
loser_arena_team->MemberLost(plr, GetArenaMatchmakerRating(GetOtherTeam(team)));
|
||||||
}
|
}
|
||||||
@@ -951,8 +952,8 @@ void Battleground::RemovePlayerAtLeave(const uint64& guid, bool Transport, bool
|
|||||||
if (isRated() && GetStatus() == STATUS_IN_PROGRESS)
|
if (isRated() && GetStatus() == STATUS_IN_PROGRESS)
|
||||||
{
|
{
|
||||||
//left a rated match while the encounter was in progress, consider as loser
|
//left a rated match while the encounter was in progress, consider as loser
|
||||||
ArenaTeam * others_arena_team = sObjectMgr->GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeam(team)));
|
ArenaTeam * others_arena_team = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeam(team)));
|
||||||
ArenaTeam * players_arena_team = sObjectMgr->GetArenaTeamById(GetArenaTeamIdForTeam(team));
|
ArenaTeam * players_arena_team = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(team));
|
||||||
if (others_arena_team && players_arena_team)
|
if (others_arena_team && players_arena_team)
|
||||||
players_arena_team->OfflineMemberLost(guid, GetArenaMatchmakerRating(GetOtherTeam(team)));
|
players_arena_team->OfflineMemberLost(guid, GetArenaMatchmakerRating(GetOtherTeam(team)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
#include "ArenaTeamMgr.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
|
|
||||||
@@ -162,7 +163,7 @@ void BattlegroundMgr::Update(uint32 diff)
|
|||||||
{
|
{
|
||||||
if (time(NULL) > m_NextAutoDistributionTime)
|
if (time(NULL) > m_NextAutoDistributionTime)
|
||||||
{
|
{
|
||||||
DistributeArenaPoints();
|
sArenaTeamMgr->DistributeArenaPoints();
|
||||||
m_NextAutoDistributionTime = m_NextAutoDistributionTime + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld->getIntConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS);
|
m_NextAutoDistributionTime = m_NextAutoDistributionTime + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld->getIntConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS);
|
||||||
sWorld->setWorldState(WS_ARENA_DISTRIBUTION_TIME, uint64(m_NextAutoDistributionTime));
|
sWorld->setWorldState(WS_ARENA_DISTRIBUTION_TIME, uint64(m_NextAutoDistributionTime));
|
||||||
}
|
}
|
||||||
@@ -250,7 +251,7 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket *data, Battleground *bg)
|
|||||||
for (int8 i = 1; i >= 0; --i)
|
for (int8 i = 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
uint32 at_id = bg->m_ArenaTeamIds[i];
|
uint32 at_id = bg->m_ArenaTeamIds[i];
|
||||||
ArenaTeam* at = sObjectMgr->GetArenaTeamById(at_id);
|
ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(at_id);
|
||||||
if (at)
|
if (at)
|
||||||
*data << at->GetName();
|
*data << at->GetName();
|
||||||
else
|
else
|
||||||
@@ -815,53 +816,6 @@ void BattlegroundMgr::InitAutomaticArenaPointDistribution()
|
|||||||
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Automatic Arena Point Distribution initialized.");
|
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Automatic Arena Point Distribution initialized.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattlegroundMgr::DistributeArenaPoints()
|
|
||||||
{
|
|
||||||
// used to distribute arena points based on last week's stats
|
|
||||||
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_START);
|
|
||||||
|
|
||||||
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_START);
|
|
||||||
|
|
||||||
//temporary structure for storing maximum points to add values for all players
|
|
||||||
std::map<uint32, uint32> PlayerPoints;
|
|
||||||
|
|
||||||
//at first update all points for all team members
|
|
||||||
for (ObjectMgr::ArenaTeamMap::iterator team_itr = sObjectMgr->GetArenaTeamMapBegin(); team_itr != sObjectMgr->GetArenaTeamMapEnd(); ++team_itr)
|
|
||||||
if (ArenaTeam * at = team_itr->second)
|
|
||||||
at->UpdateArenaPointsHelper(PlayerPoints);
|
|
||||||
|
|
||||||
//cycle that gives points to all players
|
|
||||||
for (std::map<uint32, uint32>::iterator plr_itr = PlayerPoints.begin(); plr_itr != PlayerPoints.end(); ++plr_itr)
|
|
||||||
{
|
|
||||||
//update to database
|
|
||||||
CharacterDatabase.PExecute("UPDATE characters SET arenaPoints = arenaPoints + '%u' WHERE guid = '%u'", plr_itr->second, plr_itr->first);
|
|
||||||
|
|
||||||
//add points to player if online
|
|
||||||
Player* pl = sObjectMgr->GetPlayer(plr_itr->first);
|
|
||||||
if (pl)
|
|
||||||
pl->ModifyArenaPoints(plr_itr->second);
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerPoints.clear();
|
|
||||||
|
|
||||||
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_END);
|
|
||||||
|
|
||||||
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_START);
|
|
||||||
for (ObjectMgr::ArenaTeamMap::iterator titr = sObjectMgr->GetArenaTeamMapBegin(); titr != sObjectMgr->GetArenaTeamMapEnd(); ++titr)
|
|
||||||
{
|
|
||||||
if (ArenaTeam * at = titr->second)
|
|
||||||
{
|
|
||||||
at->FinishWeek(); // set played this week etc values to 0 in memory, too
|
|
||||||
at->SaveToDB(); // save changes
|
|
||||||
at->NotifyStatsChanged(); // notify the players of the changes
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_END);
|
|
||||||
|
|
||||||
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_END);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket *data, const uint64& guid, Player* plr, BattlegroundTypeId bgTypeId, uint8 fromWhere)
|
void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket *data, const uint64& guid, Player* plr, BattlegroundTypeId bgTypeId, uint8 fromWhere)
|
||||||
{
|
{
|
||||||
if (!plr)
|
if (!plr)
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ class BattlegroundMgr
|
|||||||
uint32 GetPrematureFinishTime() const;
|
uint32 GetPrematureFinishTime() const;
|
||||||
|
|
||||||
void InitAutomaticArenaPointDistribution();
|
void InitAutomaticArenaPointDistribution();
|
||||||
void DistributeArenaPoints();
|
|
||||||
void ToggleArenaTesting();
|
void ToggleArenaTesting();
|
||||||
void ToggleTesting();
|
void ToggleTesting();
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "BattlegroundMgr.h"
|
#include "BattlegroundMgr.h"
|
||||||
#include "Chat.h"
|
#include "Chat.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
#include "ArenaTeamMgr.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Group.h"
|
#include "Group.h"
|
||||||
|
|
||||||
@@ -158,7 +159,7 @@ GroupQueueInfo * BattlegroundQueue::AddGroup(Player *leader, Group* grp, Battleg
|
|||||||
//announce world (this don't need mutex)
|
//announce world (this don't need mutex)
|
||||||
if (isRated && sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE))
|
if (isRated && sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE))
|
||||||
{
|
{
|
||||||
ArenaTeam *Team = sObjectMgr->GetArenaTeamById(arenateamid);
|
ArenaTeam *Team = sArenaTeamMgr->GetArenaTeamById(arenateamid);
|
||||||
if (Team)
|
if (Team)
|
||||||
sWorld->SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN, Team->GetName().c_str(), ginfo->ArenaType, ginfo->ArenaType, ginfo->ArenaTeamRating);
|
sWorld->SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN, Team->GetName().c_str(), ginfo->ArenaType, ginfo->ArenaType, ginfo->ArenaTeamRating);
|
||||||
}
|
}
|
||||||
@@ -353,7 +354,7 @@ void BattlegroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou
|
|||||||
// announce to world if arena team left queue for rated match, show only once
|
// announce to world if arena team left queue for rated match, show only once
|
||||||
if (group->ArenaType && group->IsRated && group->Players.empty() && sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE))
|
if (group->ArenaType && group->IsRated && group->Players.empty() && sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE))
|
||||||
{
|
{
|
||||||
ArenaTeam *Team = sObjectMgr->GetArenaTeamById(group->ArenaTeamId);
|
ArenaTeam *Team = sArenaTeamMgr->GetArenaTeamById(group->ArenaTeamId);
|
||||||
if (Team)
|
if (Team)
|
||||||
sWorld->SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT, Team->GetName().c_str(), group->ArenaType, group->ArenaType, group->ArenaTeamRating);
|
sWorld->SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT, Team->GetName().c_str(), group->ArenaType, group->ArenaType, group->ArenaTeamRating);
|
||||||
}
|
}
|
||||||
@@ -361,7 +362,7 @@ void BattlegroundQueue::RemovePlayer(const uint64& guid, bool decreaseInvitedCou
|
|||||||
//if player leaves queue and he is invited to rated arena match, then he have to lose
|
//if player leaves queue and he is invited to rated arena match, then he have to lose
|
||||||
if (group->IsInvitedToBGInstanceGUID && group->IsRated && decreaseInvitedCount)
|
if (group->IsInvitedToBGInstanceGUID && group->IsRated && decreaseInvitedCount)
|
||||||
{
|
{
|
||||||
ArenaTeam * at = sObjectMgr->GetArenaTeamById(group->ArenaTeamId);
|
ArenaTeam * at = sArenaTeamMgr->GetArenaTeamById(group->ArenaTeamId);
|
||||||
if (at)
|
if (at)
|
||||||
{
|
{
|
||||||
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "UPDATING memberLost's personal arena rating for %u by opponents rating: %u", GUID_LOPART(guid), group->OpponentsTeamRating);
|
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "UPDATING memberLost's personal arena rating for %u by opponents rating: %u", GUID_LOPART(guid), group->OpponentsTeamRating);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "WorldSession.h"
|
#include "WorldSession.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
#include "ArenaTeamMgr.h"
|
||||||
#include "AuctionHouseMgr.h"
|
#include "AuctionHouseMgr.h"
|
||||||
#include "AccountMgr.h"
|
#include "AccountMgr.h"
|
||||||
#include "PlayerDump.h"
|
#include "PlayerDump.h"
|
||||||
@@ -4394,7 +4395,7 @@ bool ChatHandler::HandleSendMessageCommand(const char *args)
|
|||||||
|
|
||||||
bool ChatHandler::HandleFlushArenaPointsCommand(const char * /*args*/)
|
bool ChatHandler::HandleFlushArenaPointsCommand(const char * /*args*/)
|
||||||
{
|
{
|
||||||
sBattlegroundMgr->DistributeArenaPoints();
|
sArenaTeamMgr->DistributeArenaPoints();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
#include "GridNotifiersImpl.h"
|
#include "GridNotifiersImpl.h"
|
||||||
#include "CellImpl.h"
|
#include "CellImpl.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
#include "ArenaTeamMgr.h"
|
||||||
#include "ObjectAccessor.h"
|
#include "ObjectAccessor.h"
|
||||||
#include "CreatureAI.h"
|
#include "CreatureAI.h"
|
||||||
#include "Formulas.h"
|
#include "Formulas.h"
|
||||||
@@ -16212,7 +16213,7 @@ void Player::_LoadArenaTeamInfo(PreparedQueryResult result)
|
|||||||
|
|
||||||
uint32 arenaTeamId = fields[0].GetUInt32();
|
uint32 arenaTeamId = fields[0].GetUInt32();
|
||||||
|
|
||||||
ArenaTeam* arenaTeam = sObjectMgr->GetArenaTeamById(arenaTeamId);
|
ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
|
||||||
if (!arenaTeam)
|
if (!arenaTeam)
|
||||||
{
|
{
|
||||||
sLog->outError("Player::_LoadArenaTeamInfo: couldn't load arenateam %u", arenaTeamId);
|
sLog->outError("Player::_LoadArenaTeamInfo: couldn't load arenateam %u", arenaTeamId);
|
||||||
@@ -16501,7 +16502,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
|||||||
if (!arena_team_id)
|
if (!arena_team_id)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ArenaTeam * at = sObjectMgr->GetArenaTeamById(arena_team_id))
|
if (ArenaTeam * at = sArenaTeamMgr->GetArenaTeamById(arena_team_id))
|
||||||
if (at->IsMember(GetGUID()))
|
if (at->IsMember(GetGUID()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -19714,7 +19715,7 @@ void Player::LeaveAllArenaTeams(uint64 guid)
|
|||||||
uint32 arenaTeamId = fields[0].GetUInt32();
|
uint32 arenaTeamId = fields[0].GetUInt32();
|
||||||
if (arenaTeamId != 0)
|
if (arenaTeamId != 0)
|
||||||
{
|
{
|
||||||
ArenaTeam* arenaTeam = sObjectMgr->GetArenaTeamById(arenaTeamId);
|
ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
|
||||||
if (arenaTeam)
|
if (arenaTeam)
|
||||||
arenaTeam->DelMember(guid, true);
|
arenaTeam->DelMember(guid, true);
|
||||||
}
|
}
|
||||||
@@ -20353,7 +20354,7 @@ uint32 Player::GetMaxPersonalArenaRatingRequirement(uint32 minarenaslot) const
|
|||||||
uint32 max_personal_rating = 0;
|
uint32 max_personal_rating = 0;
|
||||||
for (uint8 i = minarenaslot; i < MAX_ARENA_SLOT; ++i)
|
for (uint8 i = minarenaslot; i < MAX_ARENA_SLOT; ++i)
|
||||||
{
|
{
|
||||||
if (ArenaTeam * at = sObjectMgr->GetArenaTeamById(GetArenaTeamId(i)))
|
if (ArenaTeam * at = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamId(i)))
|
||||||
{
|
{
|
||||||
uint32 p_rating = GetArenaPersonalRating(i);
|
uint32 p_rating = GetArenaPersonalRating(i);
|
||||||
uint32 t_rating = at->GetRating();
|
uint32 t_rating = at->GetRating();
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "MapManager.h"
|
#include "MapManager.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
#include "ArenaTeamMgr.h"
|
||||||
#include "SpellMgr.h"
|
#include "SpellMgr.h"
|
||||||
#include "UpdateMask.h"
|
#include "UpdateMask.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
@@ -270,7 +271,6 @@ ObjectMgr::ObjectMgr()
|
|||||||
m_mailid = 1;
|
m_mailid = 1;
|
||||||
m_equipmentSetGuid = 1;
|
m_equipmentSetGuid = 1;
|
||||||
m_guildId = 1;
|
m_guildId = 1;
|
||||||
m_arenaTeamId = 1;
|
|
||||||
m_auctionid = 1;
|
m_auctionid = 1;
|
||||||
NextGroupStorageId = 1;
|
NextGroupStorageId = 1;
|
||||||
}
|
}
|
||||||
@@ -298,9 +298,6 @@ ObjectMgr::~ObjectMgr()
|
|||||||
for (GuildMap::iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
|
for (GuildMap::iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
|
||||||
delete itr->second;
|
delete itr->second;
|
||||||
|
|
||||||
for (ArenaTeamMap::iterator itr = mArenaTeamMap.begin(); itr != mArenaTeamMap.end(); ++itr)
|
|
||||||
delete itr->second;
|
|
||||||
|
|
||||||
for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr)
|
for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr)
|
||||||
itr->second.Clear();
|
itr->second.Clear();
|
||||||
|
|
||||||
@@ -374,49 +371,6 @@ void ObjectMgr::RemoveGuild(uint32 guildId)
|
|||||||
mGuildMap.erase(guildId);
|
mGuildMap.erase(guildId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arena teams collection
|
|
||||||
ArenaTeam* ObjectMgr::GetArenaTeamById(uint32 arenateamid) const
|
|
||||||
{
|
|
||||||
ArenaTeamMap::const_iterator itr = mArenaTeamMap.find(arenateamid);
|
|
||||||
if (itr != mArenaTeamMap.end())
|
|
||||||
return itr->second;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArenaTeam* ObjectMgr::GetArenaTeamByName(const std::string& arenateamname) const
|
|
||||||
{
|
|
||||||
std::string search = arenateamname;
|
|
||||||
std::transform(search.begin(), search.end(), search.begin(), ::toupper);
|
|
||||||
for (ArenaTeamMap::const_iterator itr = mArenaTeamMap.begin(); itr != mArenaTeamMap.end(); ++itr)
|
|
||||||
{
|
|
||||||
std::string teamname = itr->second->GetName();
|
|
||||||
std::transform(teamname.begin(), teamname.end(), teamname.begin(), ::toupper);
|
|
||||||
if (search == teamname)
|
|
||||||
return itr->second;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArenaTeam* ObjectMgr::GetArenaTeamByCaptain(uint64 const& guid) const
|
|
||||||
{
|
|
||||||
for (ArenaTeamMap::const_iterator itr = mArenaTeamMap.begin(); itr != mArenaTeamMap.end(); ++itr)
|
|
||||||
if (itr->second->GetCaptain() == guid)
|
|
||||||
return itr->second;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObjectMgr::AddArenaTeam(ArenaTeam* arenaTeam)
|
|
||||||
{
|
|
||||||
mArenaTeamMap[arenaTeam->GetId()] = arenaTeam;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObjectMgr::RemoveArenaTeam(uint32 Id)
|
|
||||||
{
|
|
||||||
mArenaTeamMap.erase(Id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObjectMgr::AddLocaleString(std::string& s, LocaleConstant locale, StringVector& data)
|
void ObjectMgr::AddLocaleString(std::string& s, LocaleConstant locale, StringVector& data)
|
||||||
{
|
{
|
||||||
if (!s.empty())
|
if (!s.empty())
|
||||||
@@ -4206,59 +4160,11 @@ void ObjectMgr::LoadGuilds()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sLog->outString("Validated data of loaded guilds in %u ms", GetMSTimeDiffToNow(oldMSTime));
|
sLog->outString(">> Validated data of loaded guilds in %u ms", GetMSTimeDiffToNow(oldMSTime));
|
||||||
sLog->outString();
|
sLog->outString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectMgr::LoadArenaTeams()
|
|
||||||
{
|
|
||||||
uint32 oldMSTime = getMSTime();
|
|
||||||
|
|
||||||
// Clean out the trash before loading anything
|
|
||||||
CharacterDatabase.Execute("DELETE FROM arena_team_member WHERE arenaTeamId NOT IN (SELECT arenaTeamId FROM arena_team)");
|
|
||||||
|
|
||||||
|
|
||||||
// 0 1 2 3 4 5 6 7 8
|
|
||||||
QueryResult result = CharacterDatabase.Query("SELECT arena_team.arenaTeamId, name, captainGuid, type, backgroundColor, emblemStyle, emblemColor, borderStyle, borderColor, "
|
|
||||||
// 9 10 11 12 13 14
|
|
||||||
"rating, weekGames, weekWins, seasonGames, seasonWins, rank FROM arena_team ORDER BY arena_team.arenaTeamId ASC");
|
|
||||||
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
sLog->outString(">> Loaded 0 arena team definitions. DB table `arena_team` is empty!");
|
|
||||||
sLog->outString();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QueryResult result2 = CharacterDatabase.Query(
|
|
||||||
// 0 1 2 3 4 5 6 7 8 9
|
|
||||||
"SELECT arenaTeamId, atm.guid, atm.weekGames, atm.weekWins, atm.seasonGames, atm.seasonWins, c.name, class, personalRating, matchMakerRating FROM arena_team_member atm"
|
|
||||||
" INNER JOIN arena_team ate USING (arenaTeamId)"
|
|
||||||
" LEFT JOIN characters AS c ON atm.guid = c.guid"
|
|
||||||
" LEFT JOIN character_arena_stats AS cas ON c.guid = cas.guid AND (cas.slot = 0 AND ate.type = 2 OR cas.slot = 1 AND ate.type = 3 OR cas.slot = 2 AND ate.type = 5)"
|
|
||||||
" ORDER BY atm.arenateamid ASC");
|
|
||||||
|
|
||||||
uint32 count = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
ArenaTeam* newArenaTeam = new ArenaTeam;
|
|
||||||
|
|
||||||
if (!newArenaTeam->LoadArenaTeamFromDB(result) || !newArenaTeam->LoadMembersFromDB(result2))
|
|
||||||
{
|
|
||||||
newArenaTeam->Disband(NULL);
|
|
||||||
delete newArenaTeam;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
AddArenaTeam(newArenaTeam);
|
|
||||||
|
|
||||||
++count;
|
|
||||||
} while (result->NextRow());
|
|
||||||
|
|
||||||
sLog->outString();
|
|
||||||
sLog->outString(">> Loaded %u arena team definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ObjectMgr::LoadGroups()
|
void ObjectMgr::LoadGroups()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
@@ -6934,7 +6840,7 @@ void ObjectMgr::SetHighestGuids()
|
|||||||
|
|
||||||
result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team");
|
result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team");
|
||||||
if (result)
|
if (result)
|
||||||
m_arenaTeamId = (*result)[0].GetUInt32()+1;
|
sArenaTeamMgr->SetNextArenaTeamId((*result)[0].GetUInt32()+1);
|
||||||
|
|
||||||
result = CharacterDatabase.Query("SELECT MAX(setguid) FROM character_equipmentsets");
|
result = CharacterDatabase.Query("SELECT MAX(setguid) FROM character_equipmentsets");
|
||||||
if (result)
|
if (result)
|
||||||
@@ -6949,15 +6855,7 @@ void ObjectMgr::SetHighestGuids()
|
|||||||
mGroupStorage.resize((*result)[0].GetUInt32()+1);
|
mGroupStorage.resize((*result)[0].GetUInt32()+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ObjectMgr::GenerateArenaTeamId()
|
|
||||||
{
|
|
||||||
if (m_arenaTeamId >= 0xFFFFFFFE)
|
|
||||||
{
|
|
||||||
sLog->outError("Arena team ids overflow!! Can't continue, shutting down server. ");
|
|
||||||
World::StopNow(ERROR_EXIT_CODE);
|
|
||||||
}
|
|
||||||
return m_arenaTeamId++;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 ObjectMgr::GenerateAuctionID()
|
uint32 ObjectMgr::GenerateAuctionID()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,10 +43,8 @@
|
|||||||
#include "ConditionMgr.h"
|
#include "ConditionMgr.h"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
|
||||||
class Group;
|
class Group;
|
||||||
class Guild;
|
class Guild;
|
||||||
class ArenaTeam;
|
|
||||||
class Item;
|
class Item;
|
||||||
|
|
||||||
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push, N), also any gcc version not support it at some platform
|
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push, N), also any gcc version not support it at some platform
|
||||||
@@ -613,8 +611,6 @@ class ObjectMgr
|
|||||||
|
|
||||||
typedef UNORDERED_MAP<uint32, Guild*> GuildMap;
|
typedef UNORDERED_MAP<uint32, Guild*> GuildMap;
|
||||||
|
|
||||||
typedef UNORDERED_MAP<uint32, ArenaTeam*> ArenaTeamMap;
|
|
||||||
|
|
||||||
typedef UNORDERED_MAP<uint32, Quest*> QuestMap;
|
typedef UNORDERED_MAP<uint32, Quest*> QuestMap;
|
||||||
|
|
||||||
typedef UNORDERED_MAP<uint32, AreaTrigger> AreaTriggerMap;
|
typedef UNORDERED_MAP<uint32, AreaTrigger> AreaTriggerMap;
|
||||||
@@ -661,14 +657,6 @@ class ObjectMgr
|
|||||||
void AddGuild(Guild* pGuild);
|
void AddGuild(Guild* pGuild);
|
||||||
void RemoveGuild(uint32 guildId);
|
void RemoveGuild(uint32 guildId);
|
||||||
|
|
||||||
ArenaTeam* GetArenaTeamById(uint32 arenateamid) const;
|
|
||||||
ArenaTeam* GetArenaTeamByName(const std::string& arenateamname) const;
|
|
||||||
ArenaTeam* GetArenaTeamByCaptain(uint64 const& guid) const;
|
|
||||||
void AddArenaTeam(ArenaTeam* arenaTeam);
|
|
||||||
void RemoveArenaTeam(uint32 Id);
|
|
||||||
ArenaTeamMap::iterator GetArenaTeamMapBegin() { return mArenaTeamMap.begin(); }
|
|
||||||
ArenaTeamMap::iterator GetArenaTeamMapEnd() { return mArenaTeamMap.end(); }
|
|
||||||
|
|
||||||
CreatureTemplate const* GetCreatureTemplate(uint32 entry);
|
CreatureTemplate const* GetCreatureTemplate(uint32 entry);
|
||||||
CreatureTemplateContainer const* GetCreatureTemplates() { return &CreatureTemplateStore; }
|
CreatureTemplateContainer const* GetCreatureTemplates() { return &CreatureTemplateStore; }
|
||||||
CreatureModelInfo const* GetCreatureModelInfo(uint32 modelId);
|
CreatureModelInfo const* GetCreatureModelInfo(uint32 modelId);
|
||||||
@@ -850,7 +838,6 @@ class ObjectMgr
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LoadGuilds();
|
void LoadGuilds();
|
||||||
void LoadArenaTeams();
|
|
||||||
void LoadGroups();
|
void LoadGroups();
|
||||||
void LoadQuests();
|
void LoadQuests();
|
||||||
void LoadQuestRelations()
|
void LoadQuestRelations()
|
||||||
@@ -998,7 +985,6 @@ class ObjectMgr
|
|||||||
|
|
||||||
void SetHighestGuids();
|
void SetHighestGuids();
|
||||||
uint32 GenerateLowGuid(HighGuid guidhigh);
|
uint32 GenerateLowGuid(HighGuid guidhigh);
|
||||||
uint32 GenerateArenaTeamId();
|
|
||||||
uint32 GenerateAuctionID();
|
uint32 GenerateAuctionID();
|
||||||
uint64 GenerateEquipmentSetGuid();
|
uint64 GenerateEquipmentSetGuid();
|
||||||
uint32 GenerateGuildId();
|
uint32 GenerateGuildId();
|
||||||
@@ -1270,7 +1256,6 @@ class ObjectMgr
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
// first free id for selected id type
|
// first free id for selected id type
|
||||||
uint32 m_arenaTeamId;
|
|
||||||
uint32 m_auctionid;
|
uint32 m_auctionid;
|
||||||
uint64 m_equipmentSetGuid;
|
uint64 m_equipmentSetGuid;
|
||||||
uint32 m_guildId;
|
uint32 m_guildId;
|
||||||
@@ -1304,7 +1289,6 @@ class ObjectMgr
|
|||||||
GroupSet mGroupSet;
|
GroupSet mGroupSet;
|
||||||
GroupStorage mGroupStorage;
|
GroupStorage mGroupStorage;
|
||||||
GuildMap mGuildMap;
|
GuildMap mGuildMap;
|
||||||
ArenaTeamMap mArenaTeamMap;
|
|
||||||
|
|
||||||
QuestAreaTriggerMap mQuestAreaTriggerMap;
|
QuestAreaTriggerMap mQuestAreaTriggerMap;
|
||||||
TavernAreaTriggerSet mTavernAreaTriggerSet;
|
TavernAreaTriggerSet mTavernAreaTriggerSet;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
#include "SocialMgr.h"
|
#include "SocialMgr.h"
|
||||||
|
#include "ArenaTeamMgr.h"
|
||||||
|
|
||||||
void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket & recvData)
|
void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket & recvData)
|
||||||
{
|
{
|
||||||
@@ -41,7 +42,7 @@ void WorldSession::HandleInspectArenaTeamsOpcode(WorldPacket & recvData)
|
|||||||
{
|
{
|
||||||
if (uint32 a_id = player->GetArenaTeamId(i))
|
if (uint32 a_id = player->GetArenaTeamId(i))
|
||||||
{
|
{
|
||||||
if (ArenaTeam* arenaTeam = sObjectMgr->GetArenaTeamById(a_id))
|
if (ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(a_id))
|
||||||
arenaTeam->Inspect(this, player->GetGUID());
|
arenaTeam->Inspect(this, player->GetGUID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,7 +56,7 @@ void WorldSession::HandleArenaTeamQueryOpcode(WorldPacket & recvData)
|
|||||||
uint32 arenaTeamId;
|
uint32 arenaTeamId;
|
||||||
recvData >> arenaTeamId;
|
recvData >> arenaTeamId;
|
||||||
|
|
||||||
if (ArenaTeam* arenaTeam = sObjectMgr->GetArenaTeamById(arenaTeamId))
|
if (ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId))
|
||||||
{
|
{
|
||||||
arenaTeam->Query(this);
|
arenaTeam->Query(this);
|
||||||
arenaTeam->SendStats(this);
|
arenaTeam->SendStats(this);
|
||||||
@@ -69,7 +70,7 @@ void WorldSession::HandleArenaTeamRosterOpcode(WorldPacket & recvData)
|
|||||||
uint32 arenaTeamId; // arena team id
|
uint32 arenaTeamId; // arena team id
|
||||||
recvData >> arenaTeamId;
|
recvData >> arenaTeamId;
|
||||||
|
|
||||||
if (ArenaTeam* arenaTeam = sObjectMgr->GetArenaTeamById(arenaTeamId))
|
if (ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId))
|
||||||
arenaTeam->Roster(this);
|
arenaTeam->Roster(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +105,7 @@ void WorldSession::HandleArenaTeamInviteOpcode(WorldPacket & recvData)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArenaTeam* arenaTeam = sObjectMgr->GetArenaTeamById(arenaTeamId);
|
ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
|
||||||
if (!arenaTeam)
|
if (!arenaTeam)
|
||||||
{
|
{
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PLAYER_NOT_IN_TEAM);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, "", "", ERR_ARENA_TEAM_PLAYER_NOT_IN_TEAM);
|
||||||
@@ -155,7 +156,7 @@ void WorldSession::HandleArenaTeamAcceptOpcode(WorldPacket & /*recv_data*/)
|
|||||||
{
|
{
|
||||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_ARENA_TEAM_ACCEPT"); // empty opcode
|
sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_ARENA_TEAM_ACCEPT"); // empty opcode
|
||||||
|
|
||||||
ArenaTeam* arenaTeam = sObjectMgr->GetArenaTeamById(_player->GetArenaTeamIdInvited());
|
ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(_player->GetArenaTeamIdInvited());
|
||||||
if (!arenaTeam)
|
if (!arenaTeam)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -199,7 +200,7 @@ void WorldSession::HandleArenaTeamLeaveOpcode(WorldPacket & recvData)
|
|||||||
uint32 arenaTeamId;
|
uint32 arenaTeamId;
|
||||||
recvData >> arenaTeamId;
|
recvData >> arenaTeamId;
|
||||||
|
|
||||||
ArenaTeam* arenaTeam = sObjectMgr->GetArenaTeamById(arenaTeamId);
|
ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
|
||||||
if (!arenaTeam)
|
if (!arenaTeam)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -234,7 +235,7 @@ void WorldSession::HandleArenaTeamDisbandOpcode(WorldPacket & recvData)
|
|||||||
uint32 arenaTeamId;
|
uint32 arenaTeamId;
|
||||||
recvData >> arenaTeamId;
|
recvData >> arenaTeamId;
|
||||||
|
|
||||||
if (ArenaTeam* arenaTeam = sObjectMgr->GetArenaTeamById(arenaTeamId))
|
if (ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId))
|
||||||
{
|
{
|
||||||
// Only captain can disband the team
|
// Only captain can disband the team
|
||||||
if (arenaTeam->GetCaptain() != _player->GetGUID())
|
if (arenaTeam->GetCaptain() != _player->GetGUID())
|
||||||
@@ -260,7 +261,7 @@ void WorldSession::HandleArenaTeamRemoveOpcode(WorldPacket & recvData)
|
|||||||
recvData >> name;
|
recvData >> name;
|
||||||
|
|
||||||
// Check for valid arena team
|
// Check for valid arena team
|
||||||
ArenaTeam* arenaTeam = sObjectMgr->GetArenaTeamById(arenaTeamId);
|
ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
|
||||||
if (!arenaTeam)
|
if (!arenaTeam)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -306,7 +307,7 @@ void WorldSession::HandleArenaTeamLeaderOpcode(WorldPacket & recvData)
|
|||||||
recvData >> name;
|
recvData >> name;
|
||||||
|
|
||||||
// Check for valid arena team
|
// Check for valid arena team
|
||||||
ArenaTeam* arenaTeam = sObjectMgr->GetArenaTeamById(arenaTeamId);
|
ArenaTeam* arenaTeam = sArenaTeamMgr->GetArenaTeamById(arenaTeamId);
|
||||||
if (!arenaTeam)
|
if (!arenaTeam)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "ObjectAccessor.h"
|
#include "ObjectAccessor.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
#include "ArenaTeamMgr.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
#include "WorldSession.h"
|
#include "WorldSession.h"
|
||||||
|
|
||||||
@@ -476,7 +477,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recv_data)
|
|||||||
// if player leaves rated arena match before match start, it is counted as he played but he lost
|
// if player leaves rated arena match before match start, it is counted as he played but he lost
|
||||||
if (ginfo.IsRated && ginfo.IsInvitedToBGInstanceGUID)
|
if (ginfo.IsRated && ginfo.IsInvitedToBGInstanceGUID)
|
||||||
{
|
{
|
||||||
ArenaTeam * at = sObjectMgr->GetArenaTeamById(ginfo.Team);
|
ArenaTeam * at = sArenaTeamMgr->GetArenaTeamById(ginfo.Team);
|
||||||
if (at)
|
if (at)
|
||||||
{
|
{
|
||||||
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "UPDATING memberLost's personal arena rating for %u by opponents rating: %u, because he has left queue!", GUID_LOPART(_player->GetGUID()), ginfo.OpponentsTeamRating);
|
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "UPDATING memberLost's personal arena rating for %u by opponents rating: %u, because he has left queue!", GUID_LOPART(_player->GetGUID()), ginfo.OpponentsTeamRating);
|
||||||
@@ -714,7 +715,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recv_data)
|
|||||||
{
|
{
|
||||||
ateamId = _player->GetArenaTeamId(arenaslot);
|
ateamId = _player->GetArenaTeamId(arenaslot);
|
||||||
// check real arenateam existence only here (if it was moved to group->CanJoin .. () then we would ahve to get it twice)
|
// check real arenateam existence only here (if it was moved to group->CanJoin .. () then we would ahve to get it twice)
|
||||||
ArenaTeam * at = sObjectMgr->GetArenaTeamById(ateamId);
|
ArenaTeam * at = sArenaTeamMgr->GetArenaTeamById(ateamId);
|
||||||
if (!at)
|
if (!at)
|
||||||
{
|
{
|
||||||
_player->GetSession()->SendNotInArenaTeamPacket(arenatype);
|
_player->GetSession()->SendNotInArenaTeamPacket(arenatype);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "ObjectAccessor.h"
|
#include "ObjectAccessor.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
#include "ArenaTeamMgr.h"
|
||||||
#include "SystemConfig.h"
|
#include "SystemConfig.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
@@ -606,7 +607,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket & recv_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// is arena team captain
|
// is arena team captain
|
||||||
if (sObjectMgr->GetArenaTeamByCaptain(guid))
|
if (sArenaTeamMgr->GetArenaTeamByCaptain(guid))
|
||||||
{
|
{
|
||||||
WorldPacket data(SMSG_CHAR_DELETE, 1);
|
WorldPacket data(SMSG_CHAR_DELETE, 1);
|
||||||
data << (uint8)CHAR_DELETE_FAILED_ARENA_CAPTAIN;
|
data << (uint8)CHAR_DELETE_FAILED_ARENA_CAPTAIN;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "WorldSession.h"
|
#include "WorldSession.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
#include "ArenaTeamMgr.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Opcodes.h"
|
#include "Opcodes.h"
|
||||||
#include "Guild.h"
|
#include "Guild.h"
|
||||||
@@ -167,7 +168,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (sObjectMgr->GetArenaTeamByName(name))
|
if (sArenaTeamMgr->GetArenaTeamByName(name))
|
||||||
{
|
{
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
|
||||||
return;
|
return;
|
||||||
@@ -417,7 +418,7 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (sObjectMgr->GetArenaTeamByName(newname))
|
if (sArenaTeamMgr->GetArenaTeamByName(newname))
|
||||||
{
|
{
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, newname, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, newname, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
|
||||||
return;
|
return;
|
||||||
@@ -770,7 +771,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if arena team name is already taken
|
// Check if arena team name is already taken
|
||||||
if (sObjectMgr->GetArenaTeamByName(name))
|
if (sArenaTeamMgr->GetArenaTeamByName(name))
|
||||||
{
|
{
|
||||||
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
|
SendArenaTeamCommandResult(ERR_ARENA_TEAM_CREATE_S, name, "", ERR_ARENA_TEAM_NAME_EXISTS_S);
|
||||||
return;
|
return;
|
||||||
@@ -847,7 +848,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Register arena team
|
// Register arena team
|
||||||
sObjectMgr->AddArenaTeam(arenaTeam);
|
sArenaTeamMgr->AddArenaTeam(arenaTeam);
|
||||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "PetitonsHandler: Arena team (guid: %u) added to ObjectMgr", arenaTeam->GetId());
|
sLog->outDebug(LOG_FILTER_NETWORKIO, "PetitonsHandler: Arena team (guid: %u) added to ObjectMgr", arenaTeam->GetId());
|
||||||
|
|
||||||
// Add members
|
// Add members
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#include "AchievementMgr.h"
|
#include "AchievementMgr.h"
|
||||||
#include "AuctionHouseMgr.h"
|
#include "AuctionHouseMgr.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
|
#include "ArenaTeamMgr.h"
|
||||||
#include "TicketMgr.h"
|
#include "TicketMgr.h"
|
||||||
#include "CreatureEventAIMgr.h"
|
#include "CreatureEventAIMgr.h"
|
||||||
#include "SpellMgr.h"
|
#include "SpellMgr.h"
|
||||||
@@ -1518,7 +1519,7 @@ void World::SetInitialWorldSettings()
|
|||||||
sObjectMgr->LoadGuilds();
|
sObjectMgr->LoadGuilds();
|
||||||
|
|
||||||
sLog->outString("Loading ArenaTeams...");
|
sLog->outString("Loading ArenaTeams...");
|
||||||
sObjectMgr->LoadArenaTeams();
|
sArenaTeamMgr->LoadArenaTeams();
|
||||||
|
|
||||||
sLog->outString("Loading Groups...");
|
sLog->outString("Loading Groups...");
|
||||||
sObjectMgr->LoadGroups();
|
sObjectMgr->LoadGroups();
|
||||||
|
|||||||
Reference in New Issue
Block a user