mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Battlegrounds: Optimize internal battleground data storage (from Array MAX_BATTLEGROUND_TYPE_ID to std::map)
This commit is contained in:
@@ -163,34 +163,34 @@ Battleground::Battleground()
|
||||
m_MapId = 0;
|
||||
m_Map = NULL;
|
||||
|
||||
m_TeamStartLocX[BG_TEAM_ALLIANCE] = 0;
|
||||
m_TeamStartLocX[BG_TEAM_HORDE] = 0;
|
||||
m_TeamStartLocX[TEAM_ALLIANCE] = 0;
|
||||
m_TeamStartLocX[TEAM_HORDE] = 0;
|
||||
|
||||
m_TeamStartLocY[BG_TEAM_ALLIANCE] = 0;
|
||||
m_TeamStartLocY[BG_TEAM_HORDE] = 0;
|
||||
m_TeamStartLocY[TEAM_ALLIANCE] = 0;
|
||||
m_TeamStartLocY[TEAM_HORDE] = 0;
|
||||
|
||||
m_TeamStartLocZ[BG_TEAM_ALLIANCE] = 0;
|
||||
m_TeamStartLocZ[BG_TEAM_HORDE] = 0;
|
||||
m_TeamStartLocZ[TEAM_ALLIANCE] = 0;
|
||||
m_TeamStartLocZ[TEAM_HORDE] = 0;
|
||||
|
||||
m_TeamStartLocO[BG_TEAM_ALLIANCE] = 0;
|
||||
m_TeamStartLocO[BG_TEAM_HORDE] = 0;
|
||||
m_TeamStartLocO[TEAM_ALLIANCE] = 0;
|
||||
m_TeamStartLocO[TEAM_HORDE] = 0;
|
||||
|
||||
m_ArenaTeamIds[BG_TEAM_ALLIANCE] = 0;
|
||||
m_ArenaTeamIds[BG_TEAM_HORDE] = 0;
|
||||
m_ArenaTeamIds[TEAM_ALLIANCE] = 0;
|
||||
m_ArenaTeamIds[TEAM_HORDE] = 0;
|
||||
|
||||
m_StartMaxDist = 0.0f;
|
||||
|
||||
m_ArenaTeamRatingChanges[BG_TEAM_ALLIANCE] = 0;
|
||||
m_ArenaTeamRatingChanges[BG_TEAM_HORDE] = 0;
|
||||
m_ArenaTeamRatingChanges[TEAM_ALLIANCE] = 0;
|
||||
m_ArenaTeamRatingChanges[TEAM_HORDE] = 0;
|
||||
|
||||
m_BgRaids[BG_TEAM_ALLIANCE] = NULL;
|
||||
m_BgRaids[BG_TEAM_HORDE] = NULL;
|
||||
m_BgRaids[TEAM_ALLIANCE] = NULL;
|
||||
m_BgRaids[TEAM_HORDE] = NULL;
|
||||
|
||||
m_PlayersCount[BG_TEAM_ALLIANCE] = 0;
|
||||
m_PlayersCount[BG_TEAM_HORDE] = 0;
|
||||
m_PlayersCount[TEAM_ALLIANCE] = 0;
|
||||
m_PlayersCount[TEAM_HORDE] = 0;
|
||||
|
||||
m_TeamScores[BG_TEAM_ALLIANCE] = 0;
|
||||
m_TeamScores[BG_TEAM_HORDE] = 0;
|
||||
m_TeamScores[TEAM_ALLIANCE] = 0;
|
||||
m_TeamScores[TEAM_HORDE] = 0;
|
||||
|
||||
m_PrematureCountDown = false;
|
||||
|
||||
@@ -620,7 +620,7 @@ inline Player* Battleground::_GetPlayerForTeam(uint32 teamId, BattlegroundPlayer
|
||||
|
||||
void Battleground::SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O)
|
||||
{
|
||||
BattlegroundTeamId idx = GetTeamIndexByTeamId(TeamID);
|
||||
TeamId idx = GetTeamIndexByTeamId(TeamID);
|
||||
m_TeamStartLocX[idx] = X;
|
||||
m_TeamStartLocY[idx] = Y;
|
||||
m_TeamStartLocZ[idx] = Z;
|
||||
@@ -777,7 +777,7 @@ void Battleground::EndBattleground(uint32 winner)
|
||||
SetArenaMatchmakerRating(GetOtherTeam(winner), loser_matchmaker_rating + loser_matchmaker_change);
|
||||
SetArenaTeamRatingChangeForTeam(winner, winner_change);
|
||||
SetArenaTeamRatingChangeForTeam(GetOtherTeam(winner), loser_change);
|
||||
sLog->outDebug(LOG_FILTER_ARENAS, "Arena match Type: %u for Team1Id: %u - Team2Id: %u ended. WinnerTeamId: %u. Winner rating: +%d, Loser rating: %d", m_ArenaType, m_ArenaTeamIds[BG_TEAM_ALLIANCE], m_ArenaTeamIds[BG_TEAM_HORDE], winner_arena_team->GetId(), winner_change, loser_change);
|
||||
sLog->outDebug(LOG_FILTER_ARENAS, "Arena match Type: %u for Team1Id: %u - Team2Id: %u ended. WinnerTeamId: %u. Winner rating: +%d, Loser rating: %d", m_ArenaType, m_ArenaTeamIds[TEAM_ALLIANCE], m_ArenaTeamIds[TEAM_HORDE], winner_arena_team->GetId(), winner_change, loser_change);
|
||||
if (sWorld->getBoolConfig(CONFIG_ARENA_LOG_EXTENDED_INFO))
|
||||
for (Battleground::BattlegroundScoreMap::const_iterator itr = GetPlayerScoresBegin(); itr != GetPlayerScoresEnd(); ++itr)
|
||||
if (Player* player = ObjectAccessor::FindPlayer(itr->first))
|
||||
@@ -1104,7 +1104,7 @@ void Battleground::StartBattleground()
|
||||
sBattlegroundMgr->AddBattleground(this);
|
||||
|
||||
if (m_IsRated)
|
||||
sLog->outDebug(LOG_FILTER_ARENAS, "Arena match type: %u for Team1Id: %u - Team2Id: %u started.", m_ArenaType, m_ArenaTeamIds[BG_TEAM_ALLIANCE], m_ArenaTeamIds[BG_TEAM_HORDE]);
|
||||
sLog->outDebug(LOG_FILTER_ARENAS, "Arena match type: %u for Team1Id: %u - Team2Id: %u started.", m_ArenaType, m_ArenaTeamIds[TEAM_ALLIANCE], m_ArenaTeamIds[TEAM_HORDE]);
|
||||
}
|
||||
|
||||
void Battleground::AddPlayer(Player* player)
|
||||
@@ -1893,7 +1893,7 @@ void Battleground::UpdateArenaWorldState()
|
||||
|
||||
void Battleground::SetBgRaid(uint32 TeamID, Group* bg_raid)
|
||||
{
|
||||
Group*& old_raid = TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE];
|
||||
Group*& old_raid = TeamID == ALLIANCE ? m_BgRaids[TEAM_ALLIANCE] : m_BgRaids[TEAM_HORDE];
|
||||
if (old_raid)
|
||||
old_raid->SetBattlegroundGroup(NULL);
|
||||
if (bg_raid)
|
||||
@@ -1908,7 +1908,7 @@ WorldSafeLocsEntry const* Battleground::GetClosestGraveYard(Player* player)
|
||||
|
||||
bool Battleground::IsTeamScoreInRange(uint32 team, uint32 minScore, uint32 maxScore) const
|
||||
{
|
||||
BattlegroundTeamId teamIndex = GetTeamIndexByTeamId(team);
|
||||
TeamId teamIndex = GetTeamIndexByTeamId(team);
|
||||
uint32 score = std::max(m_TeamScores[teamIndex], 0);
|
||||
return score >= minScore && score <= maxScore;
|
||||
}
|
||||
|
||||
@@ -232,11 +232,6 @@ enum BattlegroundWinner
|
||||
WINNER_NONE = 2
|
||||
};
|
||||
|
||||
enum BattlegroundTeamId
|
||||
{
|
||||
BG_TEAM_ALLIANCE = 0,
|
||||
BG_TEAM_HORDE = 1
|
||||
};
|
||||
#define BG_TEAMS_COUNT 2
|
||||
|
||||
enum BattlegroundStartingEvents
|
||||
@@ -437,7 +432,7 @@ class Battleground
|
||||
void SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O);
|
||||
void GetTeamStartLoc(uint32 TeamID, float &X, float &Y, float &Z, float &O) const
|
||||
{
|
||||
BattlegroundTeamId idx = GetTeamIndexByTeamId(TeamID);
|
||||
TeamId idx = GetTeamIndexByTeamId(TeamID);
|
||||
X = m_TeamStartLocX[idx];
|
||||
Y = m_TeamStartLocY[idx];
|
||||
Z = m_TeamStartLocZ[idx];
|
||||
@@ -475,12 +470,12 @@ class Battleground
|
||||
void SendMessage2ToAll(int32 entry, ChatMsg type, Player const* source, int32 strId1 = 0, int32 strId2 = 0);
|
||||
|
||||
// Raid Group
|
||||
Group* GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; }
|
||||
Group* GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[TEAM_ALLIANCE] : m_BgRaids[TEAM_HORDE]; }
|
||||
void SetBgRaid(uint32 TeamID, Group* bg_raid);
|
||||
|
||||
virtual void UpdatePlayerScore(Player* Source, uint32 type, uint32 value, bool doAddHonor = true);
|
||||
|
||||
static BattlegroundTeamId GetTeamIndexByTeamId(uint32 Team) { return Team == ALLIANCE ? BG_TEAM_ALLIANCE : BG_TEAM_HORDE; }
|
||||
static TeamId GetTeamIndexByTeamId(uint32 Team) { return Team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; }
|
||||
uint32 GetPlayersCountByTeam(uint32 Team) const { return m_PlayersCount[GetTeamIndexByTeamId(Team)]; }
|
||||
uint32 GetAlivePlayersCountByTeam(uint32 Team) const; // used in arenas to correctly handle death in spirit of redemption / last stand etc. (killer = killed) cases
|
||||
void UpdatePlayersCountByTeam(uint32 Team, bool remove)
|
||||
|
||||
@@ -63,50 +63,42 @@ BattlegroundMgr::~BattlegroundMgr()
|
||||
|
||||
void BattlegroundMgr::DeleteAllBattlegrounds()
|
||||
{
|
||||
for (uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; ++i)
|
||||
for (BattlegroundDataContainer::iterator itr1 = bgDataStore.begin(); itr1 != bgDataStore.end(); ++itr1)
|
||||
{
|
||||
for (BattlegroundContainer::iterator itr = m_Battlegrounds[i].begin(); itr != m_Battlegrounds[i].end();)
|
||||
{
|
||||
Battleground* bg = itr->second;
|
||||
m_Battlegrounds[i].erase(itr++);
|
||||
if (!m_ClientBattlegroundIds[i][bg->GetBracketId()].empty())
|
||||
m_ClientBattlegroundIds[i][bg->GetBracketId()].erase(bg->GetClientInstanceID());
|
||||
delete bg;
|
||||
}
|
||||
BattlegroundData& data = itr1->second;
|
||||
|
||||
while (!data.m_Battlegrounds.empty())
|
||||
delete data.m_Battlegrounds.begin()->second;
|
||||
data.m_Battlegrounds.clear();
|
||||
|
||||
while (!data.BGFreeSlotQueue.empty())
|
||||
delete data.BGFreeSlotQueue.front();
|
||||
}
|
||||
|
||||
// destroy template battlegrounds that listed only in queues (other already terminated)
|
||||
for (uint32 bgTypeId = 0; bgTypeId < MAX_BATTLEGROUND_TYPE_ID; ++bgTypeId)
|
||||
{
|
||||
// ~Battleground call unregistring BG from queue
|
||||
while (!BGFreeSlotQueue[bgTypeId].empty())
|
||||
delete BGFreeSlotQueue[bgTypeId].front();
|
||||
}
|
||||
bgDataStore.clear();
|
||||
}
|
||||
|
||||
// used to update running battlegrounds, and delete finished ones
|
||||
void BattlegroundMgr::Update(uint32 diff)
|
||||
{
|
||||
BattlegroundContainer::iterator itr, next;
|
||||
for (uint32 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; ++i)
|
||||
for (BattlegroundDataContainer::iterator itr1 = bgDataStore.begin(); itr1 != bgDataStore.end(); ++itr1)
|
||||
{
|
||||
itr = m_Battlegrounds[i].begin();
|
||||
// skip updating battleground template
|
||||
if (itr != m_Battlegrounds[i].end())
|
||||
++itr;
|
||||
for (; itr != m_Battlegrounds[i].end(); itr = next)
|
||||
BattlegroundContainer& bgs = itr1->second.m_Battlegrounds;
|
||||
BattlegroundContainer::iterator itrDelete = bgs.begin();
|
||||
// first one is template and should not be deleted
|
||||
for (BattlegroundContainer::iterator itr = ++itrDelete; itr != bgs.end();)
|
||||
{
|
||||
next = itr;
|
||||
++next;
|
||||
itr->second->Update(diff);
|
||||
// use the SetDeleteThis variable
|
||||
// direct deletion caused crashes
|
||||
if (itr->second->ToBeDeleted())
|
||||
itrDelete = itr++;
|
||||
Battleground* bg = itrDelete->second;
|
||||
|
||||
bg->Update(diff);
|
||||
if (bg->ToBeDeleted())
|
||||
{
|
||||
Battleground* bg = itr->second;
|
||||
m_Battlegrounds[i].erase(itr);
|
||||
if (!m_ClientBattlegroundIds[i][bg->GetBracketId()].empty())
|
||||
m_ClientBattlegroundIds[i][bg->GetBracketId()].erase(bg->GetClientInstanceID());
|
||||
itrDelete->second = NULL;
|
||||
bgs.erase(itrDelete);
|
||||
BattlegroundClientIdsContainer& clients = itr1->second.m_ClientBattlegroundIds[bg->GetBracketId()];
|
||||
if (!clients.empty())
|
||||
clients.erase(bg->GetClientInstanceID());
|
||||
|
||||
delete bg;
|
||||
}
|
||||
@@ -121,12 +113,7 @@ void BattlegroundMgr::Update(uint32 diff)
|
||||
if (!m_QueueUpdateScheduler.empty())
|
||||
{
|
||||
std::vector<uint64> scheduled;
|
||||
{
|
||||
//copy vector and clear the other
|
||||
scheduled = std::vector<uint64>(m_QueueUpdateScheduler);
|
||||
m_QueueUpdateScheduler.clear();
|
||||
//release lock
|
||||
}
|
||||
std::swap(scheduled, m_QueueUpdateScheduler);
|
||||
|
||||
for (uint8 i = 0; i < scheduled.size(); i++)
|
||||
{
|
||||
@@ -158,6 +145,7 @@ void BattlegroundMgr::Update(uint32 diff)
|
||||
else
|
||||
m_NextRatedArenaUpdate -= diff;
|
||||
}
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_ARENA_AUTO_DISTRIBUTE_POINTS))
|
||||
{
|
||||
if (m_AutoDistributionTimeChecker < diff)
|
||||
@@ -231,13 +219,13 @@ void BattlegroundMgr::BuildBattlegroundStatusPacket(WorldPacket* data, Battlegro
|
||||
void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg)
|
||||
{
|
||||
uint8 type = (bg->isArena() ? 1 : 0);
|
||||
// last check on 3.0.3
|
||||
|
||||
data->Initialize(MSG_PVP_LOG_DATA, (1+1+4+40*bg->GetPlayerScoresSize()));
|
||||
*data << uint8(type); // type (battleground=0/arena=1)
|
||||
|
||||
if (type) // arena
|
||||
if (type) // arena
|
||||
{
|
||||
// it seems this must be according to BG_WINNER_A/H and _NOT_ BG_TEAM_A/H
|
||||
// it seems this must be according to BG_WINNER_A/H and _NOT_ TEAM_A/H
|
||||
for (int8 i = 1; i >= 0; --i)
|
||||
{
|
||||
int32 rating_change = bg->GetArenaTeamRatingChangeByIndex(i);
|
||||
@@ -355,7 +343,7 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg)
|
||||
break;
|
||||
case BATTLEGROUND_AB:
|
||||
*data << uint32(0x00000002); // count of next fields
|
||||
*data << uint32(((BattlegroundABScore*)itr2->second)->BasesAssaulted); // bases asssulted
|
||||
*data << uint32(((BattlegroundABScore*)itr2->second)->BasesAssaulted); // bases assaulted
|
||||
*data << uint32(((BattlegroundABScore*)itr2->second)->BasesDefended); // bases defended
|
||||
break;
|
||||
case BATTLEGROUND_EY:
|
||||
@@ -367,17 +355,17 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg)
|
||||
*data << uint32(((BattlegroundSAScore*)itr2->second)->demolishers_destroyed);
|
||||
*data << uint32(((BattlegroundSAScore*)itr2->second)->gates_destroyed);
|
||||
break;
|
||||
case BATTLEGROUND_IC: // wotlk
|
||||
case BATTLEGROUND_IC:
|
||||
*data << uint32(0x00000002); // count of next fields
|
||||
*data << uint32(((BattlegroundICScore*)itr2->second)->BasesAssaulted); // bases asssulted
|
||||
*data << uint32(((BattlegroundICScore*)itr2->second)->BasesAssaulted); // bases assaulted
|
||||
*data << uint32(((BattlegroundICScore*)itr2->second)->BasesDefended); // bases defended
|
||||
break;
|
||||
case BATTLEGROUND_NA:
|
||||
case BATTLEGROUND_BE:
|
||||
case BATTLEGROUND_AA:
|
||||
case BATTLEGROUND_RL:
|
||||
case BATTLEGROUND_DS: // wotlk
|
||||
case BATTLEGROUND_RV: // wotlk
|
||||
case BATTLEGROUND_DS:
|
||||
case BATTLEGROUND_RV:
|
||||
*data << uint32(0);
|
||||
break;
|
||||
default:
|
||||
@@ -440,11 +428,16 @@ Battleground* BattlegroundMgr::GetBattlegroundThroughClientInstance(uint32 insta
|
||||
if (bg->isArena())
|
||||
return GetBattleground(instanceId, bgTypeId);
|
||||
|
||||
for (BattlegroundContainer::iterator itr = m_Battlegrounds[bgTypeId].begin(); itr != m_Battlegrounds[bgTypeId].end(); ++itr)
|
||||
BattlegroundDataContainer::const_iterator it = bgDataStore.find(bgTypeId);
|
||||
if (it == bgDataStore.end())
|
||||
return NULL;
|
||||
|
||||
for (BattlegroundContainer::const_iterator itr = it->second.m_Battlegrounds.begin(); itr != it->second.m_Battlegrounds.end(); ++itr)
|
||||
{
|
||||
if (itr->second->GetClientInstanceID() == instanceId)
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -453,25 +446,41 @@ Battleground* BattlegroundMgr::GetBattleground(uint32 instanceId, BattlegroundTy
|
||||
if (!instanceId)
|
||||
return NULL;
|
||||
|
||||
BattlegroundContainer::iterator itr;
|
||||
BattlegroundDataContainer::const_iterator begin, end;
|
||||
|
||||
if (bgTypeId == BATTLEGROUND_TYPE_NONE)
|
||||
{
|
||||
for (uint32 i = BATTLEGROUND_AV; i < MAX_BATTLEGROUND_TYPE_ID; i++)
|
||||
{
|
||||
itr = m_Battlegrounds[i].find(instanceId);
|
||||
if (itr != m_Battlegrounds[i].end())
|
||||
return itr->second;
|
||||
}
|
||||
return NULL;
|
||||
begin = bgDataStore.begin();
|
||||
end = bgDataStore.end();
|
||||
}
|
||||
itr = m_Battlegrounds[bgTypeId].find(instanceId);
|
||||
return ((itr != m_Battlegrounds[bgTypeId].end()) ? itr->second : NULL);
|
||||
else
|
||||
{
|
||||
end = bgDataStore.find(bgTypeId);
|
||||
if (end == bgDataStore.end())
|
||||
return NULL;
|
||||
begin = end++;
|
||||
}
|
||||
|
||||
for (BattlegroundDataContainer::const_iterator it = begin; it != end; ++it)
|
||||
{
|
||||
BattlegroundContainer const& bgs = it->second.m_Battlegrounds;
|
||||
BattlegroundContainer::const_iterator itr = bgs.find(instanceId);
|
||||
if (itr != bgs.end())
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Battleground* BattlegroundMgr::GetBattlegroundTemplate(BattlegroundTypeId bgTypeId)
|
||||
{
|
||||
BattlegroundDataContainer::const_iterator itr = bgDataStore.find(bgTypeId);
|
||||
if (itr == bgDataStore.end())
|
||||
return NULL;
|
||||
|
||||
BattlegroundContainer const& bgs = itr->second.m_Battlegrounds;
|
||||
//map is sorted and we can be sure that lowest instance id has only BG template
|
||||
return m_Battlegrounds[bgTypeId].empty() ? NULL : m_Battlegrounds[bgTypeId].begin()->second;
|
||||
return bgs.empty() ? NULL : bgs.begin()->second;
|
||||
}
|
||||
|
||||
uint32 BattlegroundMgr::CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id)
|
||||
@@ -485,16 +494,18 @@ uint32 BattlegroundMgr::CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeI
|
||||
// the instance-id just needs to be as low as possible, beginning with 1
|
||||
// the following works, because std::set is default ordered with "<"
|
||||
// the optimalization would be to use as bitmask std::vector<uint32> - but that would only make code unreadable
|
||||
|
||||
BattlegroundClientIdsContainer& clientIds = bgDataStore[bgTypeId].m_ClientBattlegroundIds[bracket_id];
|
||||
uint32 lastId = 0;
|
||||
for (std::set<uint32>::iterator itr = m_ClientBattlegroundIds[bgTypeId][bracket_id].begin(); itr != m_ClientBattlegroundIds[bgTypeId][bracket_id].end();)
|
||||
for (BattlegroundClientIdsContainer::const_iterator itr = clientIds.begin(); itr != clientIds.end();)
|
||||
{
|
||||
if ((++lastId) != *itr) //if there is a gap between the ids, we will break..
|
||||
break;
|
||||
lastId = *itr;
|
||||
}
|
||||
|
||||
m_ClientBattlegroundIds[bgTypeId][bracket_id].insert(lastId + 1);
|
||||
return lastId + 1;
|
||||
clientIds.insert(++lastId);
|
||||
return lastId;
|
||||
}
|
||||
|
||||
// create a new battleground that will really be used to play
|
||||
@@ -661,8 +672,7 @@ bool BattlegroundMgr::CreateBattleground(CreateBattlegroundData& data)
|
||||
bg = new BattlegroundAA;
|
||||
break;
|
||||
default:
|
||||
bg = new Battleground;
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
|
||||
bg->SetMapId(data.MapID);
|
||||
@@ -841,10 +851,10 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid
|
||||
*data << uint8(0); // unk
|
||||
|
||||
// Rewards
|
||||
*data << uint8(player->GetRandomWinner()); // 3.3.3 hasWin
|
||||
*data << uint32(winner_kills); // 3.3.3 winHonor
|
||||
*data << uint32(winner_arena); // 3.3.3 winArena
|
||||
*data << uint32(loser_kills); // 3.3.3 lossHonor
|
||||
*data << uint8(player->GetRandomWinner()); // 3.3.3 hasWin
|
||||
*data << uint32(winner_kills); // 3.3.3 winHonor
|
||||
*data << uint32(winner_arena); // 3.3.3 winArena
|
||||
*data << uint32(loser_kills); // 3.3.3 lossHonor
|
||||
|
||||
uint8 isRandom = bgTypeId == BATTLEGROUND_RB;
|
||||
|
||||
@@ -852,29 +862,29 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid
|
||||
if (isRandom)
|
||||
{
|
||||
// Rewards (random)
|
||||
*data << uint8(player->GetRandomWinner()); // 3.3.3 hasWin_Random
|
||||
*data << uint32(winner_kills); // 3.3.3 winHonor_Random
|
||||
*data << uint32(winner_arena); // 3.3.3 winArena_Random
|
||||
*data << uint32(loser_kills); // 3.3.3 lossHonor_Random
|
||||
*data << uint8(player->GetRandomWinner()); // 3.3.3 hasWin_Random
|
||||
*data << uint32(winner_kills); // 3.3.3 winHonor_Random
|
||||
*data << uint32(winner_arena); // 3.3.3 winArena_Random
|
||||
*data << uint32(loser_kills); // 3.3.3 lossHonor_Random
|
||||
}
|
||||
|
||||
if (bgTypeId == BATTLEGROUND_AA) // arena
|
||||
{
|
||||
if (bgTypeId == BATTLEGROUND_AA) // arena
|
||||
*data << uint32(0); // unk (count?)
|
||||
}
|
||||
else // battleground
|
||||
{
|
||||
size_t count_pos = data->wpos();
|
||||
*data << uint32(0); // number of bg instances
|
||||
|
||||
if (Battleground* bgTemplate = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId))
|
||||
BattlegroundDataContainer::iterator it = bgDataStore.find(bgTypeId);
|
||||
if (it != bgDataStore.end())
|
||||
{
|
||||
// expected bracket entry
|
||||
if (PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(), player->getLevel()))
|
||||
if (PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(it->second.m_Battlegrounds.begin()->second->GetMapId(), player->getLevel()))
|
||||
{
|
||||
uint32 count = 0;
|
||||
BattlegroundBracketId bracketId = bracketEntry->GetBracketId();
|
||||
for (std::set<uint32>::iterator itr = m_ClientBattlegroundIds[bgTypeId][bracketId].begin(); itr != m_ClientBattlegroundIds[bgTypeId][bracketId].end();++itr)
|
||||
BattlegroundClientIdsContainer& clientIds = it->second.m_ClientBattlegroundIds[bracketId];
|
||||
for (BattlegroundClientIdsContainer::const_iterator itr = clientIds.begin(); itr != clientIds.end(); ++itr)
|
||||
{
|
||||
*data << uint32(*itr);
|
||||
++count;
|
||||
@@ -887,23 +897,20 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket* data, uint64 guid
|
||||
|
||||
void BattlegroundMgr::SendToBattleground(Player* player, uint32 instanceId, BattlegroundTypeId bgTypeId)
|
||||
{
|
||||
Battleground* bg = GetBattleground(instanceId, bgTypeId);
|
||||
if (bg)
|
||||
if (Battleground* bg = GetBattleground(instanceId, bgTypeId))
|
||||
{
|
||||
uint32 mapid = bg->GetMapId();
|
||||
float x, y, z, O;
|
||||
uint32 mapid = bg->GetMapId();
|
||||
uint32 team = player->GetBGTeam();
|
||||
if (team == 0)
|
||||
team = player->GetTeam();
|
||||
bg->GetTeamStartLoc(team, x, y, z, O);
|
||||
|
||||
sLog->outInfo(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Sending %s to map %u, X %f, Y %f, Z %f, O %f", player->GetName(), mapid, x, y, z, O);
|
||||
bg->GetTeamStartLoc(team, x, y, z, O);
|
||||
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundMgr::SendToBattleground: Sending %s to map %u, X %f, Y %f, Z %f, O %f (bgType %u)", player->GetName(), mapid, x, y, z, O, bgTypeId);
|
||||
player->TeleportTo(mapid, x, y, z, O);
|
||||
}
|
||||
else
|
||||
{
|
||||
sLog->outError(LOG_FILTER_BATTLEGROUND, "player %u is trying to port to non-existent bg instance %u", player->GetGUIDLow(), instanceId);
|
||||
}
|
||||
sLog->outError(LOG_FILTER_BATTLEGROUND, "BattlegroundMgr::SendToBattleground: Instance %u (bgType %u) not found while trying to teleport player %s", instanceId, bgTypeId, player->GetName());
|
||||
}
|
||||
|
||||
void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode(Player* player, Battleground* bg, uint64 guid)
|
||||
@@ -918,12 +925,12 @@ void BattlegroundMgr::SendAreaSpiritHealerQueryOpcode(Player* player, Battlegrou
|
||||
|
||||
bool BattlegroundMgr::IsArenaType(BattlegroundTypeId bgTypeId)
|
||||
{
|
||||
return (bgTypeId == BATTLEGROUND_AA ||
|
||||
bgTypeId == BATTLEGROUND_BE ||
|
||||
bgTypeId == BATTLEGROUND_NA ||
|
||||
bgTypeId == BATTLEGROUND_DS ||
|
||||
bgTypeId == BATTLEGROUND_RV ||
|
||||
bgTypeId == BATTLEGROUND_RL);
|
||||
return bgTypeId == BATTLEGROUND_AA
|
||||
|| bgTypeId == BATTLEGROUND_BE
|
||||
|| bgTypeId == BATTLEGROUND_NA
|
||||
|| bgTypeId == BATTLEGROUND_DS
|
||||
|| bgTypeId == BATTLEGROUND_RV
|
||||
|| bgTypeId == BATTLEGROUND_RL;
|
||||
}
|
||||
|
||||
BattlegroundQueueTypeId BattlegroundMgr::BGQueueTypeId(BattlegroundTypeId bgTypeId, uint8 arenaType)
|
||||
@@ -1011,19 +1018,13 @@ uint8 BattlegroundMgr::BGArenaType(BattlegroundQueueTypeId bgQueueTypeId)
|
||||
void BattlegroundMgr::ToggleTesting()
|
||||
{
|
||||
m_Testing = !m_Testing;
|
||||
if (m_Testing)
|
||||
sWorld->SendWorldText(LANG_DEBUG_BG_ON);
|
||||
else
|
||||
sWorld->SendWorldText(LANG_DEBUG_BG_OFF);
|
||||
sWorld->SendWorldText(m_Testing ? LANG_DEBUG_BG_ON : LANG_DEBUG_BG_OFF);
|
||||
}
|
||||
|
||||
void BattlegroundMgr::ToggleArenaTesting()
|
||||
{
|
||||
m_ArenaTesting = !m_ArenaTesting;
|
||||
if (m_ArenaTesting)
|
||||
sWorld->SendWorldText(LANG_DEBUG_ARENA_ON);
|
||||
else
|
||||
sWorld->SendWorldText(LANG_DEBUG_ARENA_OFF);
|
||||
sWorld->SendWorldText(m_ArenaTesting ? LANG_DEBUG_ARENA_ON : LANG_DEBUG_ARENA_OFF);
|
||||
}
|
||||
|
||||
void BattlegroundMgr::SetHolidayWeekends(uint32 mask)
|
||||
@@ -1041,18 +1042,9 @@ void BattlegroundMgr::ScheduleQueueUpdate(uint32 arenaMatchmakerRating, uint8 ar
|
||||
{
|
||||
//This method must be atomic, TODO add mutex
|
||||
//we will use only 1 number created of bgTypeId and bracket_id
|
||||
uint64 schedule_id = ((uint64)arenaMatchmakerRating << 32) | (arenaType << 24) | (bgQueueTypeId << 16) | (bgTypeId << 8) | bracket_id;
|
||||
bool found = false;
|
||||
for (uint8 i = 0; i < m_QueueUpdateScheduler.size(); i++)
|
||||
{
|
||||
if (m_QueueUpdateScheduler[i] == schedule_id)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
m_QueueUpdateScheduler.push_back(schedule_id);
|
||||
uint64 const scheduleId = ((uint64)arenaMatchmakerRating << 32) | (arenaType << 24) | (bgQueueTypeId << 16) | (bgTypeId << 8) | bracket_id;
|
||||
if (std::find(m_QueueUpdateScheduler.begin(), m_QueueUpdateScheduler.end(), scheduleId) == m_QueueUpdateScheduler.end())
|
||||
m_QueueUpdateScheduler.push_back(scheduleId);
|
||||
}
|
||||
|
||||
uint32 BattlegroundMgr::GetMaxRatingDifference() const
|
||||
@@ -1146,17 +1138,17 @@ bool BattlegroundMgr::IsBGWeekend(BattlegroundTypeId bgTypeId)
|
||||
|
||||
BGFreeSlotQueueContainer& BattlegroundMgr::GetBGFreeSlotQueueStore(BattlegroundTypeId bgTypeId)
|
||||
{
|
||||
return BGFreeSlotQueue[bgTypeId];
|
||||
return bgDataStore[bgTypeId].BGFreeSlotQueue;
|
||||
}
|
||||
|
||||
void BattlegroundMgr::AddToBGFreeSlotQueue(BattlegroundTypeId bgTypeId, Battleground* bg)
|
||||
{
|
||||
BGFreeSlotQueue[bgTypeId].push_front(bg);
|
||||
bgDataStore[bgTypeId].BGFreeSlotQueue.push_front(bg);
|
||||
}
|
||||
|
||||
void BattlegroundMgr::RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId)
|
||||
{
|
||||
BGFreeSlotQueueContainer& queues = BGFreeSlotQueue[bgTypeId];
|
||||
BGFreeSlotQueueContainer& queues = bgDataStore[bgTypeId].BGFreeSlotQueue;
|
||||
for (BGFreeSlotQueueContainer::iterator itr = queues.begin(); itr != queues.end(); ++itr)
|
||||
if ((*itr)->GetInstanceID() == instanceId)
|
||||
{
|
||||
@@ -1168,11 +1160,11 @@ void BattlegroundMgr::RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uin
|
||||
void BattlegroundMgr::AddBattleground(Battleground* bg)
|
||||
{
|
||||
if (bg)
|
||||
m_Battlegrounds[bg->GetTypeID()][bg->GetInstanceID()] = bg;
|
||||
bgDataStore[bg->GetTypeID()].m_Battlegrounds[bg->GetInstanceID()] = bg;
|
||||
}
|
||||
|
||||
void BattlegroundMgr::RemoveBattleground(BattlegroundTypeId bgTypeId, uint32 instanceId)
|
||||
{
|
||||
m_Battlegrounds[bgTypeId].erase(instanceId);
|
||||
bgDataStore[bgTypeId].m_Battlegrounds.erase(instanceId);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <ace/Singleton.h>
|
||||
|
||||
typedef std::map<uint32, Battleground*> BattlegroundContainer;
|
||||
typedef std::set<uint32> BattlegroundClientIdsContainer;
|
||||
|
||||
typedef UNORDERED_MAP<uint32, BattlegroundTypeId> BattleMastersMap;
|
||||
|
||||
@@ -54,6 +55,13 @@ struct CreateBattlegroundData
|
||||
uint32 scriptId;
|
||||
};
|
||||
|
||||
struct BattlegroundData
|
||||
{
|
||||
BattlegroundContainer m_Battlegrounds;
|
||||
BattlegroundClientIdsContainer m_ClientBattlegroundIds[MAX_BATTLEGROUND_BRACKETS];
|
||||
BGFreeSlotQueueContainer BGFreeSlotQueue;
|
||||
};
|
||||
|
||||
class BattlegroundMgr
|
||||
{
|
||||
friend class ACE_Singleton<BattlegroundMgr, ACE_Null_Mutex>;
|
||||
@@ -133,13 +141,12 @@ class BattlegroundMgr
|
||||
BattlegroundTypeId GetRandomBG(BattlegroundTypeId id);
|
||||
|
||||
BattleMastersMap mBattleMastersMap;
|
||||
typedef std::map<BattlegroundTypeId, BattlegroundData> BattlegroundDataContainer;
|
||||
BattlegroundDataContainer bgDataStore;
|
||||
|
||||
typedef std::map<BattlegroundTypeId, uint8> BattlegroundSelectionWeightMap; // TypeId and its selectionWeight
|
||||
|
||||
BattlegroundQueue m_BattlegroundQueues[MAX_BATTLEGROUND_QUEUE_TYPES];
|
||||
BGFreeSlotQueueContainer BGFreeSlotQueue[MAX_BATTLEGROUND_TYPE_ID];
|
||||
BattlegroundContainer m_Battlegrounds[MAX_BATTLEGROUND_TYPE_ID];
|
||||
std::set<uint32> m_ClientBattlegroundIds[MAX_BATTLEGROUND_TYPE_ID][MAX_BATTLEGROUND_BRACKETS]; //the instanceids just visible for the client
|
||||
|
||||
BattlegroundSelectionWeightMap m_ArenaSelectionWeights;
|
||||
BattlegroundSelectionWeightMap m_BGSelectionWeights;
|
||||
|
||||
@@ -236,16 +236,16 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, Battlegr
|
||||
void BattlegroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id)
|
||||
{
|
||||
uint32 timeInQueue = getMSTimeDiff(ginfo->JoinTime, getMSTime());
|
||||
uint8 team_index = BG_TEAM_ALLIANCE; //default set to BG_TEAM_ALLIANCE - or non rated arenas!
|
||||
uint8 team_index = TEAM_ALLIANCE; //default set to TEAM_ALLIANCE - or non rated arenas!
|
||||
if (!ginfo->ArenaType)
|
||||
{
|
||||
if (ginfo->Team == HORDE)
|
||||
team_index = BG_TEAM_HORDE;
|
||||
team_index = TEAM_HORDE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ginfo->IsRated)
|
||||
team_index = BG_TEAM_HORDE; //for rated arenas use BG_TEAM_HORDE
|
||||
team_index = TEAM_HORDE; //for rated arenas use TEAM_HORDE
|
||||
}
|
||||
|
||||
//store pointer to arrayindex of player that was added first
|
||||
@@ -263,16 +263,16 @@ void BattlegroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* g
|
||||
|
||||
uint32 BattlegroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id) const
|
||||
{
|
||||
uint8 team_index = BG_TEAM_ALLIANCE; //default set to BG_TEAM_ALLIANCE - or non rated arenas!
|
||||
uint8 team_index = TEAM_ALLIANCE; //default set to TEAM_ALLIANCE - or non rated arenas!
|
||||
if (!ginfo->ArenaType)
|
||||
{
|
||||
if (ginfo->Team == HORDE)
|
||||
team_index = BG_TEAM_HORDE;
|
||||
team_index = TEAM_HORDE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ginfo->IsRated)
|
||||
team_index = BG_TEAM_HORDE; //for rated arenas use BG_TEAM_HORDE
|
||||
team_index = TEAM_HORDE; //for rated arenas use TEAM_HORDE
|
||||
}
|
||||
//check if there is enought values(we always add values > 0)
|
||||
if (m_WaitTimes[team_index][bracket_id][COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME - 1])
|
||||
@@ -303,7 +303,7 @@ void BattlegroundQueue::RemovePlayer(uint64 guid, bool decreaseInvitedCount)
|
||||
// mostly people with the highest levels are in battlegrounds, thats why
|
||||
// we count from MAX_BATTLEGROUND_QUEUES - 1 to 0
|
||||
// variable index removes useless searching in other team's queue
|
||||
uint32 index = (group->Team == HORDE) ? BG_TEAM_HORDE : BG_TEAM_ALLIANCE;
|
||||
uint32 index = (group->Team == HORDE) ? TEAM_HORDE : TEAM_ALLIANCE;
|
||||
|
||||
for (int32 bracket_id_tmp = MAX_BATTLEGROUND_BRACKETS - 1; bracket_id_tmp >= 0 && bracket_id == -1; --bracket_id_tmp)
|
||||
{
|
||||
@@ -495,13 +495,13 @@ void BattlegroundQueue::FillPlayersToBG(Battleground* bg, BattlegroundBracketId
|
||||
uint32 aliCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].size();
|
||||
//index to queue which group is current
|
||||
uint32 aliIndex = 0;
|
||||
for (; aliIndex < aliCount && m_SelectionPools[BG_TEAM_ALLIANCE].AddGroup((*Ali_itr), aliFree); aliIndex++)
|
||||
for (; aliIndex < aliCount && m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), aliFree); aliIndex++)
|
||||
++Ali_itr;
|
||||
//the same thing for horde
|
||||
GroupsQueueType::const_iterator Horde_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].begin();
|
||||
uint32 hordeCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].size();
|
||||
uint32 hordeIndex = 0;
|
||||
for (; hordeIndex < hordeCount && m_SelectionPools[BG_TEAM_HORDE].AddGroup((*Horde_itr), hordeFree); hordeIndex++)
|
||||
for (; hordeIndex < hordeCount && m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), hordeFree); hordeIndex++)
|
||||
++Horde_itr;
|
||||
|
||||
//if ofc like BG queue invitation is set in config, then we are happy
|
||||
@@ -517,45 +517,45 @@ void BattlegroundQueue::FillPlayersToBG(Battleground* bg, BattlegroundBracketId
|
||||
*/
|
||||
|
||||
// At first we need to compare free space in bg and our selection pool
|
||||
int32 diffAli = aliFree - int32(m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount());
|
||||
int32 diffHorde = hordeFree - int32(m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount());
|
||||
while (abs(diffAli - diffHorde) > 1 && (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() > 0 || m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() > 0))
|
||||
int32 diffAli = aliFree - int32(m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount());
|
||||
int32 diffHorde = hordeFree - int32(m_SelectionPools[TEAM_HORDE].GetPlayerCount());
|
||||
while (abs(diffAli - diffHorde) > 1 && (m_SelectionPools[TEAM_HORDE].GetPlayerCount() > 0 || m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() > 0))
|
||||
{
|
||||
//each cycle execution we need to kick at least 1 group
|
||||
if (diffAli < diffHorde)
|
||||
{
|
||||
//kick alliance group, add to pool new group if needed
|
||||
if (m_SelectionPools[BG_TEAM_ALLIANCE].KickGroup(diffHorde - diffAli))
|
||||
if (m_SelectionPools[TEAM_ALLIANCE].KickGroup(diffHorde - diffAli))
|
||||
{
|
||||
for (; aliIndex < aliCount && m_SelectionPools[BG_TEAM_ALLIANCE].AddGroup((*Ali_itr), (aliFree >= diffHorde) ? aliFree - diffHorde : 0); aliIndex++)
|
||||
for (; aliIndex < aliCount && m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), (aliFree >= diffHorde) ? aliFree - diffHorde : 0); aliIndex++)
|
||||
++Ali_itr;
|
||||
}
|
||||
//if ali selection is already empty, then kick horde group, but if there are less horde than ali in bg - break;
|
||||
if (!m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount())
|
||||
if (!m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount())
|
||||
{
|
||||
if (aliFree <= diffHorde + 1)
|
||||
break;
|
||||
m_SelectionPools[BG_TEAM_HORDE].KickGroup(diffHorde - diffAli);
|
||||
m_SelectionPools[TEAM_HORDE].KickGroup(diffHorde - diffAli);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//kick horde group, add to pool new group if needed
|
||||
if (m_SelectionPools[BG_TEAM_HORDE].KickGroup(diffAli - diffHorde))
|
||||
if (m_SelectionPools[TEAM_HORDE].KickGroup(diffAli - diffHorde))
|
||||
{
|
||||
for (; hordeIndex < hordeCount && m_SelectionPools[BG_TEAM_HORDE].AddGroup((*Horde_itr), (hordeFree >= diffAli) ? hordeFree - diffAli : 0); hordeIndex++)
|
||||
for (; hordeIndex < hordeCount && m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), (hordeFree >= diffAli) ? hordeFree - diffAli : 0); hordeIndex++)
|
||||
++Horde_itr;
|
||||
}
|
||||
if (!m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount())
|
||||
if (!m_SelectionPools[TEAM_HORDE].GetPlayerCount())
|
||||
{
|
||||
if (hordeFree <= diffAli + 1)
|
||||
break;
|
||||
m_SelectionPools[BG_TEAM_ALLIANCE].KickGroup(diffAli - diffHorde);
|
||||
m_SelectionPools[TEAM_ALLIANCE].KickGroup(diffAli - diffHorde);
|
||||
}
|
||||
}
|
||||
//count diffs after small update
|
||||
diffAli = aliFree - int32(m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount());
|
||||
diffHorde = hordeFree - int32(m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount());
|
||||
diffAli = aliFree - int32(m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount());
|
||||
diffHorde = hordeFree - int32(m_SelectionPools[TEAM_HORDE].GetPlayerCount());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -579,10 +579,10 @@ bool BattlegroundQueue::CheckPremadeMatch(BattlegroundBracketId bracket_id, uint
|
||||
|
||||
if (ali_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].end() && horde_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].end())
|
||||
{
|
||||
m_SelectionPools[BG_TEAM_ALLIANCE].AddGroup((*ali_group), MaxPlayersPerTeam);
|
||||
m_SelectionPools[BG_TEAM_HORDE].AddGroup((*horde_group), MaxPlayersPerTeam);
|
||||
m_SelectionPools[TEAM_ALLIANCE].AddGroup((*ali_group), MaxPlayersPerTeam);
|
||||
m_SelectionPools[TEAM_HORDE].AddGroup((*horde_group), MaxPlayersPerTeam);
|
||||
//add groups/players from normal queue to size of bigger group
|
||||
uint32 maxPlayers = std::min(m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount(), m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount());
|
||||
uint32 maxPlayers = std::min(m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount(), m_SelectionPools[TEAM_HORDE].GetPlayerCount());
|
||||
GroupsQueueType::const_iterator itr;
|
||||
for (uint32 i = 0; i < BG_TEAMS_COUNT; i++)
|
||||
{
|
||||
@@ -637,11 +637,11 @@ bool BattlegroundQueue::CheckNormalMatch(Battleground* bg_template, Battleground
|
||||
}
|
||||
}
|
||||
//try to invite same number of players - this cycle may cause longer wait time even if there are enough players in queue, but we want ballanced bg
|
||||
uint32 j = BG_TEAM_ALLIANCE;
|
||||
if (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() < m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount())
|
||||
j = BG_TEAM_HORDE;
|
||||
uint32 j = TEAM_ALLIANCE;
|
||||
if (m_SelectionPools[TEAM_HORDE].GetPlayerCount() < m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount())
|
||||
j = TEAM_HORDE;
|
||||
if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) != 0
|
||||
&& m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() >= minPlayers && m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() >= minPlayers)
|
||||
&& m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= minPlayers)
|
||||
{
|
||||
//we will try to invite more groups to team with less players indexed by j
|
||||
++(itr_team[j]); //this will not cause a crash, because for cycle above reached break;
|
||||
@@ -652,28 +652,28 @@ bool BattlegroundQueue::CheckNormalMatch(Battleground* bg_template, Battleground
|
||||
break;
|
||||
}
|
||||
// do not allow to start bg with more than 2 players more on 1 faction
|
||||
if (abs((int32)(m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() - m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount())) > 2)
|
||||
if (abs((int32)(m_SelectionPools[TEAM_HORDE].GetPlayerCount() - m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount())) > 2)
|
||||
return false;
|
||||
}
|
||||
//allow 1v0 if debug bg
|
||||
if (sBattlegroundMgr->isTesting() && bg_template->isBattleground() && (m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() || m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount()))
|
||||
if (sBattlegroundMgr->isTesting() && bg_template->isBattleground() && (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() || m_SelectionPools[TEAM_HORDE].GetPlayerCount()))
|
||||
return true;
|
||||
//return true if there are enough players in selection pools - enable to work .debug bg command correctly
|
||||
return m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() >= minPlayers && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() >= minPlayers;
|
||||
return m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= minPlayers;
|
||||
}
|
||||
|
||||
// this method will check if we can invite players to same faction skirmish match
|
||||
bool BattlegroundQueue::CheckSkirmishForSameFaction(BattlegroundBracketId bracket_id, uint32 minPlayersPerTeam)
|
||||
{
|
||||
if (m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() < minPlayersPerTeam && m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() < minPlayersPerTeam)
|
||||
if (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() < minPlayersPerTeam && m_SelectionPools[TEAM_HORDE].GetPlayerCount() < minPlayersPerTeam)
|
||||
return false;
|
||||
uint32 teamIndex = BG_TEAM_ALLIANCE;
|
||||
uint32 otherTeam = BG_TEAM_HORDE;
|
||||
uint32 teamIndex = TEAM_ALLIANCE;
|
||||
uint32 otherTeam = TEAM_HORDE;
|
||||
uint32 otherTeamId = HORDE;
|
||||
if (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() == minPlayersPerTeam)
|
||||
if (m_SelectionPools[TEAM_HORDE].GetPlayerCount() == minPlayersPerTeam)
|
||||
{
|
||||
teamIndex = BG_TEAM_HORDE;
|
||||
otherTeam = BG_TEAM_ALLIANCE;
|
||||
teamIndex = TEAM_HORDE;
|
||||
otherTeam = TEAM_ALLIANCE;
|
||||
otherTeamId = ALLIANCE;
|
||||
}
|
||||
//clear other team's selection
|
||||
@@ -751,16 +751,16 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTyp
|
||||
bg->GetStatus() > STATUS_WAIT_QUEUE && bg->GetStatus() < STATUS_WAIT_LEAVE)
|
||||
{
|
||||
// clear selection pools
|
||||
m_SelectionPools[BG_TEAM_ALLIANCE].Init();
|
||||
m_SelectionPools[BG_TEAM_HORDE].Init();
|
||||
m_SelectionPools[TEAM_ALLIANCE].Init();
|
||||
m_SelectionPools[TEAM_HORDE].Init();
|
||||
|
||||
// call a function that does the job for us
|
||||
FillPlayersToBG(bg, bracket_id);
|
||||
|
||||
// now everything is set, invite players
|
||||
for (GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE].SelectedGroups.end(); ++citr)
|
||||
for (GroupsQueueType::const_iterator citr = m_SelectionPools[TEAM_ALLIANCE].SelectedGroups.begin(); citr != m_SelectionPools[TEAM_ALLIANCE].SelectedGroups.end(); ++citr)
|
||||
InviteGroupToBG((*citr), bg, (*citr)->Team);
|
||||
for (GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_HORDE].SelectedGroups.end(); ++citr)
|
||||
for (GroupsQueueType::const_iterator citr = m_SelectionPools[TEAM_HORDE].SelectedGroups.begin(); citr != m_SelectionPools[TEAM_HORDE].SelectedGroups.end(); ++citr)
|
||||
InviteGroupToBG((*citr), bg, (*citr)->Team);
|
||||
|
||||
if (!bg->HasFreeSlots())
|
||||
@@ -819,8 +819,8 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTyp
|
||||
}
|
||||
}
|
||||
|
||||
m_SelectionPools[BG_TEAM_ALLIANCE].Init();
|
||||
m_SelectionPools[BG_TEAM_HORDE].Init();
|
||||
m_SelectionPools[TEAM_ALLIANCE].Init();
|
||||
m_SelectionPools[TEAM_HORDE].Init();
|
||||
|
||||
if (bg_template->isBattleground())
|
||||
{
|
||||
@@ -836,13 +836,13 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTyp
|
||||
}
|
||||
//invite those selection pools
|
||||
for (uint32 i = 0; i < BG_TEAMS_COUNT; i++)
|
||||
for (GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr)
|
||||
for (GroupsQueueType::const_iterator citr = m_SelectionPools[TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr)
|
||||
InviteGroupToBG((*citr), bg2, (*citr)->Team);
|
||||
//start bg
|
||||
bg2->StartBattleground();
|
||||
//clear structures
|
||||
m_SelectionPools[BG_TEAM_ALLIANCE].Init();
|
||||
m_SelectionPools[BG_TEAM_HORDE].Init();
|
||||
m_SelectionPools[TEAM_ALLIANCE].Init();
|
||||
m_SelectionPools[TEAM_HORDE].Init();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -863,7 +863,7 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTyp
|
||||
|
||||
// invite those selection pools
|
||||
for (uint32 i = 0; i < BG_TEAMS_COUNT; i++)
|
||||
for (GroupsQueueType::const_iterator citr = m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[BG_TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr)
|
||||
for (GroupsQueueType::const_iterator citr = m_SelectionPools[TEAM_ALLIANCE + i].SelectedGroups.begin(); citr != m_SelectionPools[TEAM_ALLIANCE + i].SelectedGroups.end(); ++citr)
|
||||
InviteGroupToBG((*citr), bg2, (*citr)->Team);
|
||||
// start bg
|
||||
bg2->StartBattleground();
|
||||
@@ -950,8 +950,8 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTyp
|
||||
//if we have 2 teams, then start new arena and invite players!
|
||||
if (found == 2)
|
||||
{
|
||||
GroupQueueInfo* aTeam = *itr_teams[BG_TEAM_ALLIANCE];
|
||||
GroupQueueInfo* hTeam = *itr_teams[BG_TEAM_HORDE];
|
||||
GroupQueueInfo* aTeam = *itr_teams[TEAM_ALLIANCE];
|
||||
GroupQueueInfo* hTeam = *itr_teams[TEAM_HORDE];
|
||||
Battleground* arena = sBattlegroundMgr->CreateNewBattleground(bgTypeId, bracketEntry, arenaType, true);
|
||||
if (!arena)
|
||||
{
|
||||
@@ -970,12 +970,12 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTyp
|
||||
if (aTeam->Team != ALLIANCE)
|
||||
{
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].push_front(aTeam);
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].erase(itr_teams[BG_TEAM_ALLIANCE]);
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].erase(itr_teams[TEAM_ALLIANCE]);
|
||||
}
|
||||
if (hTeam->Team != HORDE)
|
||||
{
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].push_front(hTeam);
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].erase(itr_teams[BG_TEAM_HORDE]);
|
||||
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].erase(itr_teams[TEAM_HORDE]);
|
||||
}
|
||||
|
||||
arena->SetArenaMatchmakerRating(ALLIANCE, aTeam->ArenaMatchmakerRating);
|
||||
|
||||
@@ -119,17 +119,17 @@ void BattlegroundAB::PostUpdateImpl(uint32 diff)
|
||||
m_ReputationScoreTics[team] += BG_AB_TickPoints[points];
|
||||
if (m_ReputationScoreTics[team] >= m_ReputationTics)
|
||||
{
|
||||
(team == BG_TEAM_ALLIANCE) ? RewardReputationToTeam(509, 10, ALLIANCE) : RewardReputationToTeam(510, 10, HORDE);
|
||||
(team == TEAM_ALLIANCE) ? RewardReputationToTeam(509, 10, ALLIANCE) : RewardReputationToTeam(510, 10, HORDE);
|
||||
m_ReputationScoreTics[team] -= m_ReputationTics;
|
||||
}
|
||||
if (m_HonorScoreTics[team] >= m_HonorTics)
|
||||
{
|
||||
RewardHonorToTeam(GetBonusHonorFromKill(1), (team == BG_TEAM_ALLIANCE) ? ALLIANCE : HORDE);
|
||||
RewardHonorToTeam(GetBonusHonorFromKill(1), (team == TEAM_ALLIANCE) ? ALLIANCE : HORDE);
|
||||
m_HonorScoreTics[team] -= m_HonorTics;
|
||||
}
|
||||
if (!m_IsInformedNearVictory && m_TeamScores[team] > BG_AB_WARNING_NEAR_VICTORY_SCORE)
|
||||
{
|
||||
if (team == BG_TEAM_ALLIANCE)
|
||||
if (team == TEAM_ALLIANCE)
|
||||
SendMessageToAll(LANG_BG_AB_A_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL);
|
||||
else
|
||||
SendMessageToAll(LANG_BG_AB_H_NEAR_VICTORY, CHAT_MSG_BG_SYSTEM_NEUTRAL);
|
||||
@@ -139,9 +139,9 @@ void BattlegroundAB::PostUpdateImpl(uint32 diff)
|
||||
|
||||
if (m_TeamScores[team] > BG_AB_MAX_TEAM_SCORE)
|
||||
m_TeamScores[team] = BG_AB_MAX_TEAM_SCORE;
|
||||
if (team == BG_TEAM_ALLIANCE)
|
||||
if (team == TEAM_ALLIANCE)
|
||||
UpdateWorldState(BG_AB_OP_RESOURCES_ALLY, m_TeamScores[team]);
|
||||
if (team == BG_TEAM_HORDE)
|
||||
if (team == TEAM_HORDE)
|
||||
UpdateWorldState(BG_AB_OP_RESOURCES_HORDE, m_TeamScores[team]);
|
||||
// update achievement flags
|
||||
// we increased m_TeamScores[team] so we just need to check if it is 500 more than other teams resources
|
||||
@@ -152,9 +152,9 @@ void BattlegroundAB::PostUpdateImpl(uint32 diff)
|
||||
}
|
||||
|
||||
// Test win condition
|
||||
if (m_TeamScores[BG_TEAM_ALLIANCE] >= BG_AB_MAX_TEAM_SCORE)
|
||||
if (m_TeamScores[TEAM_ALLIANCE] >= BG_AB_MAX_TEAM_SCORE)
|
||||
EndBattleground(ALLIANCE);
|
||||
if (m_TeamScores[BG_TEAM_HORDE] >= BG_AB_MAX_TEAM_SCORE)
|
||||
if (m_TeamScores[TEAM_HORDE] >= BG_AB_MAX_TEAM_SCORE)
|
||||
EndBattleground(HORDE);
|
||||
}
|
||||
}
|
||||
@@ -322,8 +322,8 @@ void BattlegroundAB::FillInitialWorldStates(WorldPacket& data)
|
||||
// Team scores
|
||||
data << uint32(BG_AB_OP_RESOURCES_MAX) << uint32(BG_AB_MAX_TEAM_SCORE);
|
||||
data << uint32(BG_AB_OP_RESOURCES_WARNING) << uint32(BG_AB_WARNING_NEAR_VICTORY_SCORE);
|
||||
data << uint32(BG_AB_OP_RESOURCES_ALLY) << uint32(m_TeamScores[BG_TEAM_ALLIANCE]);
|
||||
data << uint32(BG_AB_OP_RESOURCES_HORDE) << uint32(m_TeamScores[BG_TEAM_HORDE]);
|
||||
data << uint32(BG_AB_OP_RESOURCES_ALLY) << uint32(m_TeamScores[TEAM_ALLIANCE]);
|
||||
data << uint32(BG_AB_OP_RESOURCES_HORDE) << uint32(m_TeamScores[TEAM_HORDE]);
|
||||
|
||||
// other unknown
|
||||
data << uint32(0x745) << uint32(0x2); // 37 1861 unk
|
||||
@@ -441,7 +441,7 @@ void BattlegroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* /*targ
|
||||
return;
|
||||
}
|
||||
|
||||
BattlegroundTeamId teamIndex = GetTeamIndexByTeamId(source->GetTeam());
|
||||
TeamId teamIndex = GetTeamIndexByTeamId(source->GetTeam());
|
||||
|
||||
// Check if player really could use this banner, not cheated
|
||||
if (!(m_Nodes[node] == 0 || teamIndex == m_Nodes[node]%2))
|
||||
@@ -487,7 +487,7 @@ void BattlegroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* /*targ
|
||||
m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME;
|
||||
|
||||
// FIXME: node names not localized
|
||||
if (teamIndex == BG_TEAM_ALLIANCE)
|
||||
if (teamIndex == TEAM_ALLIANCE)
|
||||
SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node));
|
||||
else
|
||||
SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node));
|
||||
@@ -504,15 +504,15 @@ void BattlegroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* /*targ
|
||||
_CreateBanner(node, BG_AB_NODE_TYPE_OCCUPIED, teamIndex, true);
|
||||
_SendNodeUpdate(node);
|
||||
m_NodeTimers[node] = 0;
|
||||
_NodeOccupied(node, (teamIndex == BG_TEAM_ALLIANCE) ? ALLIANCE:HORDE);
|
||||
_NodeOccupied(node, (teamIndex == TEAM_ALLIANCE) ? ALLIANCE:HORDE);
|
||||
|
||||
// FIXME: node names not localized
|
||||
if (teamIndex == BG_TEAM_ALLIANCE)
|
||||
if (teamIndex == TEAM_ALLIANCE)
|
||||
SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node));
|
||||
else
|
||||
SendMessage2ToAll(LANG_BG_AB_NODE_DEFENDED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node));
|
||||
}
|
||||
sound = (teamIndex == BG_TEAM_ALLIANCE) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE;
|
||||
sound = (teamIndex == TEAM_ALLIANCE) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE;
|
||||
}
|
||||
// If node is occupied, change to enemy-contested
|
||||
else
|
||||
@@ -529,19 +529,19 @@ void BattlegroundAB::EventPlayerClickedOnFlag(Player* source, GameObject* /*targ
|
||||
m_NodeTimers[node] = BG_AB_FLAG_CAPTURING_TIME;
|
||||
|
||||
// FIXME: node names not localized
|
||||
if (teamIndex == BG_TEAM_ALLIANCE)
|
||||
if (teamIndex == TEAM_ALLIANCE)
|
||||
SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_ALLIANCE, source, _GetNodeNameId(node));
|
||||
else
|
||||
SendMessage2ToAll(LANG_BG_AB_NODE_ASSAULTED, CHAT_MSG_BG_SYSTEM_HORDE, source, _GetNodeNameId(node));
|
||||
|
||||
sound = (teamIndex == BG_TEAM_ALLIANCE) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE;
|
||||
sound = (teamIndex == TEAM_ALLIANCE) ? BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE : BG_AB_SOUND_NODE_ASSAULTED_HORDE;
|
||||
}
|
||||
|
||||
// If node is occupied again, send "X has taken the Y" msg.
|
||||
if (m_Nodes[node] >= BG_AB_NODE_TYPE_OCCUPIED)
|
||||
{
|
||||
// FIXME: team and node names not localized
|
||||
if (teamIndex == BG_TEAM_ALLIANCE)
|
||||
if (teamIndex == TEAM_ALLIANCE)
|
||||
SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_ALLIANCE, NULL, LANG_BG_AB_ALLY, _GetNodeNameId(node));
|
||||
else
|
||||
SendMessage2ToAll(LANG_BG_AB_NODE_TAKEN, CHAT_MSG_BG_SYSTEM_HORDE, NULL, LANG_BG_AB_HORDE, _GetNodeNameId(node));
|
||||
@@ -592,20 +592,20 @@ void BattlegroundAB::Reset()
|
||||
//call parent's class reset
|
||||
Battleground::Reset();
|
||||
|
||||
m_TeamScores[BG_TEAM_ALLIANCE] = 0;
|
||||
m_TeamScores[BG_TEAM_HORDE] = 0;
|
||||
m_lastTick[BG_TEAM_ALLIANCE] = 0;
|
||||
m_lastTick[BG_TEAM_HORDE] = 0;
|
||||
m_HonorScoreTics[BG_TEAM_ALLIANCE] = 0;
|
||||
m_HonorScoreTics[BG_TEAM_HORDE] = 0;
|
||||
m_ReputationScoreTics[BG_TEAM_ALLIANCE] = 0;
|
||||
m_ReputationScoreTics[BG_TEAM_HORDE] = 0;
|
||||
m_TeamScores[TEAM_ALLIANCE] = 0;
|
||||
m_TeamScores[TEAM_HORDE] = 0;
|
||||
m_lastTick[TEAM_ALLIANCE] = 0;
|
||||
m_lastTick[TEAM_HORDE] = 0;
|
||||
m_HonorScoreTics[TEAM_ALLIANCE] = 0;
|
||||
m_HonorScoreTics[TEAM_HORDE] = 0;
|
||||
m_ReputationScoreTics[TEAM_ALLIANCE] = 0;
|
||||
m_ReputationScoreTics[TEAM_HORDE] = 0;
|
||||
m_IsInformedNearVictory = false;
|
||||
bool isBGWeekend = sBattlegroundMgr->IsBGWeekend(GetTypeID());
|
||||
m_HonorTics = (isBGWeekend) ? BG_AB_ABBGWeekendHonorTicks : BG_AB_NotABBGWeekendHonorTicks;
|
||||
m_ReputationTics = (isBGWeekend) ? BG_AB_ABBGWeekendReputationTicks : BG_AB_NotABBGWeekendReputationTicks;
|
||||
m_TeamScores500Disadvantage[BG_TEAM_ALLIANCE] = false;
|
||||
m_TeamScores500Disadvantage[BG_TEAM_HORDE] = false;
|
||||
m_TeamScores500Disadvantage[TEAM_ALLIANCE] = false;
|
||||
m_TeamScores500Disadvantage[TEAM_HORDE] = false;
|
||||
|
||||
for (uint8 i = 0; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
|
||||
{
|
||||
@@ -636,7 +636,7 @@ void BattlegroundAB::EndBattleground(uint32 winner)
|
||||
|
||||
WorldSafeLocsEntry const* BattlegroundAB::GetClosestGraveYard(Player* player)
|
||||
{
|
||||
BattlegroundTeamId teamIndex = GetTeamIndexByTeamId(player->GetTeam());
|
||||
TeamId teamIndex = GetTeamIndexByTeamId(player->GetTeam());
|
||||
|
||||
// Is there any occupied node for this team?
|
||||
std::vector<uint8> nodes;
|
||||
|
||||
@@ -242,17 +242,17 @@ void BattlegroundAV::UpdateScore(uint16 team, int16 points)
|
||||
uint8 teamindex = GetTeamIndexByTeamId(team); //0=ally 1=horde
|
||||
m_Team_Scores[teamindex] += points;
|
||||
|
||||
UpdateWorldState(((teamindex == BG_TEAM_HORDE)?AV_Horde_Score:AV_Alliance_Score), m_Team_Scores[teamindex]);
|
||||
UpdateWorldState(((teamindex == TEAM_HORDE)?AV_Horde_Score:AV_Alliance_Score), m_Team_Scores[teamindex]);
|
||||
if (points < 0)
|
||||
{
|
||||
if (m_Team_Scores[teamindex] < 1)
|
||||
{
|
||||
m_Team_Scores[teamindex]=0;
|
||||
EndBattleground(((teamindex == BG_TEAM_HORDE)?ALLIANCE:HORDE));
|
||||
EndBattleground(((teamindex == TEAM_HORDE)?ALLIANCE:HORDE));
|
||||
}
|
||||
else if (!m_IsInformedNearVictory[teamindex] && m_Team_Scores[teamindex] < SEND_MSG_NEAR_LOSE)
|
||||
{
|
||||
SendMessageToAll(teamindex == BG_TEAM_HORDE?LANG_BG_AV_H_NEAR_LOSE:LANG_BG_AV_A_NEAR_LOSE, teamindex == BG_TEAM_HORDE ? CHAT_MSG_BG_SYSTEM_HORDE : CHAT_MSG_BG_SYSTEM_ALLIANCE);
|
||||
SendMessageToAll(teamindex == TEAM_HORDE?LANG_BG_AV_H_NEAR_LOSE:LANG_BG_AV_A_NEAR_LOSE, teamindex == TEAM_HORDE ? CHAT_MSG_BG_SYSTEM_HORDE : CHAT_MSG_BG_SYSTEM_ALLIANCE);
|
||||
PlaySoundToAll(AV_SOUND_NEAR_VICTORY);
|
||||
m_IsInformedNearVictory[teamindex] = true;
|
||||
}
|
||||
|
||||
@@ -63,10 +63,10 @@ void BattlegroundEY::PostUpdateImpl(uint32 diff)
|
||||
if (m_PointAddingTimer <= 0)
|
||||
{
|
||||
m_PointAddingTimer = BG_EY_FPOINTS_TICK_TIME;
|
||||
if (m_TeamPointsCount[BG_TEAM_ALLIANCE] > 0)
|
||||
AddPoints(ALLIANCE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_ALLIANCE] - 1]);
|
||||
if (m_TeamPointsCount[BG_TEAM_HORDE] > 0)
|
||||
AddPoints(HORDE, BG_EY_TickPoints[m_TeamPointsCount[BG_TEAM_HORDE] - 1]);
|
||||
if (m_TeamPointsCount[TEAM_ALLIANCE] > 0)
|
||||
AddPoints(ALLIANCE, BG_EY_TickPoints[m_TeamPointsCount[TEAM_ALLIANCE] - 1]);
|
||||
if (m_TeamPointsCount[TEAM_HORDE] > 0)
|
||||
AddPoints(HORDE, BG_EY_TickPoints[m_TeamPointsCount[TEAM_HORDE] - 1]);
|
||||
}
|
||||
|
||||
if (m_FlagState == BG_EY_FLAG_STATE_WAIT_RESPAWN || m_FlagState == BG_EY_FLAG_STATE_ON_GROUND)
|
||||
@@ -128,7 +128,7 @@ void BattlegroundEY::StartingEventOpenDoors()
|
||||
|
||||
void BattlegroundEY::AddPoints(uint32 Team, uint32 Points)
|
||||
{
|
||||
BattlegroundTeamId team_index = GetTeamIndexByTeamId(Team);
|
||||
TeamId team_index = GetTeamIndexByTeamId(Team);
|
||||
m_TeamScores[team_index] += Points;
|
||||
m_HonorScoreTics[team_index] += Points;
|
||||
if (m_HonorScoreTics[team_index] >= m_HonorTics)
|
||||
@@ -307,9 +307,9 @@ void BattlegroundEY::EndBattleground(uint32 winner)
|
||||
void BattlegroundEY::UpdatePointsCount(uint32 Team)
|
||||
{
|
||||
if (Team == ALLIANCE)
|
||||
UpdateWorldState(EY_ALLIANCE_BASE, m_TeamPointsCount[BG_TEAM_ALLIANCE]);
|
||||
UpdateWorldState(EY_ALLIANCE_BASE, m_TeamPointsCount[TEAM_ALLIANCE]);
|
||||
else
|
||||
UpdateWorldState(EY_HORDE_BASE, m_TeamPointsCount[BG_TEAM_HORDE]);
|
||||
UpdateWorldState(EY_HORDE_BASE, m_TeamPointsCount[TEAM_HORDE]);
|
||||
}
|
||||
|
||||
void BattlegroundEY::UpdatePointsIcons(uint32 Team, uint32 Point)
|
||||
@@ -516,12 +516,12 @@ void BattlegroundEY::Reset()
|
||||
//call parent's class reset
|
||||
Battleground::Reset();
|
||||
|
||||
m_TeamScores[BG_TEAM_ALLIANCE] = 0;
|
||||
m_TeamScores[BG_TEAM_HORDE] = 0;
|
||||
m_TeamPointsCount[BG_TEAM_ALLIANCE] = 0;
|
||||
m_TeamPointsCount[BG_TEAM_HORDE] = 0;
|
||||
m_HonorScoreTics[BG_TEAM_ALLIANCE] = 0;
|
||||
m_HonorScoreTics[BG_TEAM_HORDE] = 0;
|
||||
m_TeamScores[TEAM_ALLIANCE] = 0;
|
||||
m_TeamScores[TEAM_HORDE] = 0;
|
||||
m_TeamPointsCount[TEAM_ALLIANCE] = 0;
|
||||
m_TeamPointsCount[TEAM_HORDE] = 0;
|
||||
m_HonorScoreTics[TEAM_ALLIANCE] = 0;
|
||||
m_HonorScoreTics[TEAM_HORDE] = 0;
|
||||
m_FlagState = BG_EY_FLAG_STATE_ON_BASE;
|
||||
m_FlagCapturedBgObjectType = 0;
|
||||
m_FlagKeeper = 0;
|
||||
@@ -664,14 +664,14 @@ void BattlegroundEY::EventTeamLostPoint(Player* Source, uint32 Point)
|
||||
|
||||
if (Team == ALLIANCE)
|
||||
{
|
||||
m_TeamPointsCount[BG_TEAM_ALLIANCE]--;
|
||||
m_TeamPointsCount[TEAM_ALLIANCE]--;
|
||||
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeAlliance, RESPAWN_ONE_DAY);
|
||||
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeAlliance + 1, RESPAWN_ONE_DAY);
|
||||
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeAlliance + 2, RESPAWN_ONE_DAY);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TeamPointsCount[BG_TEAM_HORDE]--;
|
||||
m_TeamPointsCount[TEAM_HORDE]--;
|
||||
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeHorde, RESPAWN_ONE_DAY);
|
||||
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeHorde + 1, RESPAWN_ONE_DAY);
|
||||
SpawnBGObject(m_LosingPointTypes[Point].DespawnObjectTypeHorde + 2, RESPAWN_ONE_DAY);
|
||||
@@ -712,14 +712,14 @@ void BattlegroundEY::EventTeamCapturedPoint(Player* Source, uint32 Point)
|
||||
|
||||
if (Team == ALLIANCE)
|
||||
{
|
||||
m_TeamPointsCount[BG_TEAM_ALLIANCE]++;
|
||||
m_TeamPointsCount[TEAM_ALLIANCE]++;
|
||||
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance, RESPAWN_IMMEDIATELY);
|
||||
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance + 1, RESPAWN_IMMEDIATELY);
|
||||
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeAlliance + 2, RESPAWN_IMMEDIATELY);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TeamPointsCount[BG_TEAM_HORDE]++;
|
||||
m_TeamPointsCount[TEAM_HORDE]++;
|
||||
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde, RESPAWN_IMMEDIATELY);
|
||||
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 1, RESPAWN_IMMEDIATELY);
|
||||
SpawnBGObject(m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 2, RESPAWN_IMMEDIATELY);
|
||||
@@ -790,12 +790,12 @@ void BattlegroundEY::EventPlayerCapturedFlag(Player* Source, uint32 BgObjectType
|
||||
uint8 team_id = 0;
|
||||
if (Source->GetTeam() == ALLIANCE)
|
||||
{
|
||||
team_id = BG_TEAM_ALLIANCE;
|
||||
team_id = TEAM_ALLIANCE;
|
||||
SendMessageToAll(LANG_BG_EY_CAPTURED_FLAG_A, CHAT_MSG_BG_SYSTEM_ALLIANCE, Source);
|
||||
}
|
||||
else
|
||||
{
|
||||
team_id = BG_TEAM_HORDE;
|
||||
team_id = TEAM_HORDE;
|
||||
SendMessageToAll(LANG_BG_EY_CAPTURED_FLAG_H, CHAT_MSG_BG_SYSTEM_HORDE, Source);
|
||||
}
|
||||
|
||||
@@ -825,8 +825,8 @@ void BattlegroundEY::UpdatePlayerScore(Player* Source, uint32 type, uint32 value
|
||||
|
||||
void BattlegroundEY::FillInitialWorldStates(WorldPacket& data)
|
||||
{
|
||||
data << uint32(EY_HORDE_BASE) << uint32(m_TeamPointsCount[BG_TEAM_HORDE]);
|
||||
data << uint32(EY_ALLIANCE_BASE) << uint32(m_TeamPointsCount[BG_TEAM_ALLIANCE]);
|
||||
data << uint32(EY_HORDE_BASE) << uint32(m_TeamPointsCount[TEAM_HORDE]);
|
||||
data << uint32(EY_ALLIANCE_BASE) << uint32(m_TeamPointsCount[TEAM_ALLIANCE]);
|
||||
data << uint32(0xab6) << uint32(0x0);
|
||||
data << uint32(0xab5) << uint32(0x0);
|
||||
data << uint32(0xab4) << uint32(0x0);
|
||||
|
||||
@@ -864,7 +864,7 @@ void BattlegroundIC::EventPlayerDamagedGO(Player* /*player*/, GameObject* /*go*/
|
||||
|
||||
WorldSafeLocsEntry const* BattlegroundIC::GetClosestGraveYard(Player* player)
|
||||
{
|
||||
BattlegroundTeamId teamIndex = GetTeamIndexByTeamId(player->GetTeam());
|
||||
TeamId teamIndex = GetTeamIndexByTeamId(player->GetTeam());
|
||||
|
||||
// Is there any occupied node for this team?
|
||||
std::vector<uint8> nodes;
|
||||
|
||||
@@ -56,8 +56,8 @@ void BattlegroundSA::Reset()
|
||||
GateStatus[i] = BG_SA_GATE_OK;
|
||||
ShipsStarted = false;
|
||||
gateDestroyed = false;
|
||||
_notEvenAScratch[BG_TEAM_ALLIANCE] = true;
|
||||
_notEvenAScratch[BG_TEAM_HORDE] = true;
|
||||
_notEvenAScratch[TEAM_ALLIANCE] = true;
|
||||
_notEvenAScratch[TEAM_HORDE] = true;
|
||||
Status = BG_SA_WARMUP;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,44 +90,44 @@ void BattlegroundWS::PostUpdateImpl(uint32 diff)
|
||||
UpdateWorldState(BG_WS_STATE_TIMER, 25 - _minutesElapsed);
|
||||
}
|
||||
|
||||
if (_flagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_WAIT_RESPAWN)
|
||||
if (_flagState[TEAM_ALLIANCE] == BG_WS_FLAG_STATE_WAIT_RESPAWN)
|
||||
{
|
||||
_flagsTimer[BG_TEAM_ALLIANCE] -= diff;
|
||||
_flagsTimer[TEAM_ALLIANCE] -= diff;
|
||||
|
||||
if (_flagsTimer[BG_TEAM_ALLIANCE] < 0)
|
||||
if (_flagsTimer[TEAM_ALLIANCE] < 0)
|
||||
{
|
||||
_flagsTimer[BG_TEAM_ALLIANCE] = 0;
|
||||
_flagsTimer[TEAM_ALLIANCE] = 0;
|
||||
RespawnFlag(ALLIANCE, true);
|
||||
}
|
||||
}
|
||||
if (_flagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_GROUND)
|
||||
if (_flagState[TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_GROUND)
|
||||
{
|
||||
_flagsDropTimer[BG_TEAM_ALLIANCE] -= diff;
|
||||
_flagsDropTimer[TEAM_ALLIANCE] -= diff;
|
||||
|
||||
if (_flagsDropTimer[BG_TEAM_ALLIANCE] < 0)
|
||||
if (_flagsDropTimer[TEAM_ALLIANCE] < 0)
|
||||
{
|
||||
_flagsDropTimer[BG_TEAM_ALLIANCE] = 0;
|
||||
_flagsDropTimer[TEAM_ALLIANCE] = 0;
|
||||
RespawnFlagAfterDrop(ALLIANCE);
|
||||
_bothFlagsKept = false;
|
||||
}
|
||||
}
|
||||
if (_flagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_WAIT_RESPAWN)
|
||||
if (_flagState[TEAM_HORDE] == BG_WS_FLAG_STATE_WAIT_RESPAWN)
|
||||
{
|
||||
_flagsTimer[BG_TEAM_HORDE] -= diff;
|
||||
_flagsTimer[TEAM_HORDE] -= diff;
|
||||
|
||||
if (_flagsTimer[BG_TEAM_HORDE] < 0)
|
||||
if (_flagsTimer[TEAM_HORDE] < 0)
|
||||
{
|
||||
_flagsTimer[BG_TEAM_HORDE] = 0;
|
||||
_flagsTimer[TEAM_HORDE] = 0;
|
||||
RespawnFlag(HORDE, true);
|
||||
}
|
||||
}
|
||||
if (_flagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_ON_GROUND)
|
||||
if (_flagState[TEAM_HORDE] == BG_WS_FLAG_STATE_ON_GROUND)
|
||||
{
|
||||
_flagsDropTimer[BG_TEAM_HORDE] -= diff;
|
||||
_flagsDropTimer[TEAM_HORDE] -= diff;
|
||||
|
||||
if (_flagsDropTimer[BG_TEAM_HORDE] < 0)
|
||||
if (_flagsDropTimer[TEAM_HORDE] < 0)
|
||||
{
|
||||
_flagsDropTimer[BG_TEAM_HORDE] = 0;
|
||||
_flagsDropTimer[TEAM_HORDE] = 0;
|
||||
RespawnFlagAfterDrop(HORDE);
|
||||
_bothFlagsKept = false;
|
||||
}
|
||||
@@ -224,12 +224,12 @@ void BattlegroundWS::RespawnFlag(uint32 Team, bool captured)
|
||||
if (Team == ALLIANCE)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Respawn Alliance flag");
|
||||
_flagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_BASE;
|
||||
_flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_BASE;
|
||||
}
|
||||
else
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Respawn Horde flag");
|
||||
_flagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_ON_BASE;
|
||||
_flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_BASE;
|
||||
}
|
||||
|
||||
if (captured)
|
||||
@@ -285,7 +285,7 @@ void BattlegroundWS::EventPlayerCapturedFlag(Player* Source)
|
||||
return;
|
||||
SetHordeFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time
|
||||
// horde flag in base (but not respawned yet)
|
||||
_flagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_WAIT_RESPAWN;
|
||||
_flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_WAIT_RESPAWN;
|
||||
// Drop Horde Flag from Player
|
||||
Source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG);
|
||||
if (_flagDebuffState == 1)
|
||||
@@ -303,7 +303,7 @@ void BattlegroundWS::EventPlayerCapturedFlag(Player* Source)
|
||||
return;
|
||||
SetAllianceFlagPicker(0); // must be before aura remove to prevent 2 events (drop+capture) at the same time
|
||||
// alliance flag in base (but not respawned yet)
|
||||
_flagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_WAIT_RESPAWN;
|
||||
_flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_WAIT_RESPAWN;
|
||||
// Drop Alliance Flag from Player
|
||||
Source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG);
|
||||
if (_flagDebuffState == 1)
|
||||
@@ -367,7 +367,7 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* Source)
|
||||
{
|
||||
if (!this->IsHordeFlagPickedup())
|
||||
return;
|
||||
if (GetFlagPickerGUID(BG_TEAM_HORDE) == Source->GetGUID())
|
||||
if (GetFlagPickerGUID(TEAM_HORDE) == Source->GetGUID())
|
||||
{
|
||||
SetHordeFlagPicker(0);
|
||||
Source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG);
|
||||
@@ -377,7 +377,7 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* Source)
|
||||
{
|
||||
if (!this->IsAllianceFlagPickedup())
|
||||
return;
|
||||
if (GetFlagPickerGUID(BG_TEAM_ALLIANCE) == Source->GetGUID())
|
||||
if (GetFlagPickerGUID(TEAM_ALLIANCE) == Source->GetGUID())
|
||||
{
|
||||
SetAllianceFlagPicker(0);
|
||||
Source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG);
|
||||
@@ -392,7 +392,7 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* Source)
|
||||
{
|
||||
if (!IsHordeFlagPickedup())
|
||||
return;
|
||||
if (GetFlagPickerGUID(BG_TEAM_HORDE) == Source->GetGUID())
|
||||
if (GetFlagPickerGUID(TEAM_HORDE) == Source->GetGUID())
|
||||
{
|
||||
SetHordeFlagPicker(0);
|
||||
Source->RemoveAurasDueToSpell(BG_WS_SPELL_WARSONG_FLAG);
|
||||
@@ -400,7 +400,7 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* Source)
|
||||
Source->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT);
|
||||
if (_flagDebuffState == 2)
|
||||
Source->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT);
|
||||
_flagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_ON_GROUND;
|
||||
_flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_GROUND;
|
||||
Source->CastSpell(Source, BG_WS_SPELL_WARSONG_FLAG_DROPPED, true);
|
||||
set = true;
|
||||
}
|
||||
@@ -409,7 +409,7 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* Source)
|
||||
{
|
||||
if (!IsAllianceFlagPickedup())
|
||||
return;
|
||||
if (GetFlagPickerGUID(BG_TEAM_ALLIANCE) == Source->GetGUID())
|
||||
if (GetFlagPickerGUID(TEAM_ALLIANCE) == Source->GetGUID())
|
||||
{
|
||||
SetAllianceFlagPicker(0);
|
||||
Source->RemoveAurasDueToSpell(BG_WS_SPELL_SILVERWING_FLAG);
|
||||
@@ -417,7 +417,7 @@ void BattlegroundWS::EventPlayerDroppedFlag(Player* Source)
|
||||
Source->RemoveAurasDueToSpell(WS_SPELL_FOCUSED_ASSAULT);
|
||||
if (_flagDebuffState == 2)
|
||||
Source->RemoveAurasDueToSpell(WS_SPELL_BRUTAL_ASSAULT);
|
||||
_flagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_GROUND;
|
||||
_flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_GROUND;
|
||||
Source->CastSpell(Source, BG_WS_SPELL_SILVERWING_FLAG_DROPPED, true);
|
||||
set = true;
|
||||
}
|
||||
@@ -460,7 +460,7 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target
|
||||
PlaySoundToAll(BG_WS_SOUND_ALLIANCE_FLAG_PICKED_UP);
|
||||
SpawnBGObject(BG_WS_OBJECT_A_FLAG, RESPAWN_ONE_DAY);
|
||||
SetAllianceFlagPicker(Source->GetGUID());
|
||||
_flagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_PLAYER;
|
||||
_flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_PLAYER;
|
||||
//update world state to show correct flag carrier
|
||||
UpdateFlagState(HORDE, BG_WS_FLAG_STATE_ON_PLAYER);
|
||||
UpdateWorldState(BG_WS_FLAG_UNK_ALLIANCE, 1);
|
||||
@@ -479,7 +479,7 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target
|
||||
PlaySoundToAll(BG_WS_SOUND_HORDE_FLAG_PICKED_UP);
|
||||
SpawnBGObject(BG_WS_OBJECT_H_FLAG, RESPAWN_ONE_DAY);
|
||||
SetHordeFlagPicker(Source->GetGUID());
|
||||
_flagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_ON_PLAYER;
|
||||
_flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_PLAYER;
|
||||
//update world state to show correct flag carrier
|
||||
UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_ON_PLAYER);
|
||||
UpdateWorldState(BG_WS_FLAG_UNK_HORDE, 1);
|
||||
@@ -511,7 +511,7 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target
|
||||
SpawnBGObject(BG_WS_OBJECT_A_FLAG, RESPAWN_ONE_DAY);
|
||||
SetAllianceFlagPicker(Source->GetGUID());
|
||||
Source->CastSpell(Source, BG_WS_SPELL_SILVERWING_FLAG, true);
|
||||
_flagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_PLAYER;
|
||||
_flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_PLAYER;
|
||||
UpdateFlagState(HORDE, BG_WS_FLAG_STATE_ON_PLAYER);
|
||||
if (_flagDebuffState == 1)
|
||||
Source->CastSpell(Source, WS_SPELL_FOCUSED_ASSAULT, true);
|
||||
@@ -545,7 +545,7 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target
|
||||
SpawnBGObject(BG_WS_OBJECT_H_FLAG, RESPAWN_ONE_DAY);
|
||||
SetHordeFlagPicker(Source->GetGUID());
|
||||
Source->CastSpell(Source, BG_WS_SPELL_WARSONG_FLAG, true);
|
||||
_flagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_ON_PLAYER;
|
||||
_flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_PLAYER;
|
||||
UpdateFlagState(ALLIANCE, BG_WS_FLAG_STATE_ON_PLAYER);
|
||||
if (_flagDebuffState == 1)
|
||||
Source->CastSpell(Source, WS_SPELL_FOCUSED_ASSAULT, true);
|
||||
@@ -567,7 +567,7 @@ void BattlegroundWS::EventPlayerClickedOnFlag(Player* Source, GameObject* target
|
||||
void BattlegroundWS::RemovePlayer(Player* player, uint64 guid, uint32 /*team*/)
|
||||
{
|
||||
// sometimes flag aura not removed :(
|
||||
if (IsAllianceFlagPickedup() && m_FlagKeepers[BG_TEAM_ALLIANCE] == guid)
|
||||
if (IsAllianceFlagPickedup() && m_FlagKeepers[TEAM_ALLIANCE] == guid)
|
||||
{
|
||||
if (!player)
|
||||
{
|
||||
@@ -578,7 +578,7 @@ void BattlegroundWS::RemovePlayer(Player* player, uint64 guid, uint32 /*team*/)
|
||||
else
|
||||
this->EventPlayerDroppedFlag(player);
|
||||
}
|
||||
if (IsHordeFlagPickedup() && m_FlagKeepers[BG_TEAM_HORDE] == guid)
|
||||
if (IsHordeFlagPickedup() && m_FlagKeepers[TEAM_HORDE] == guid)
|
||||
{
|
||||
if (!player)
|
||||
{
|
||||
@@ -635,13 +635,13 @@ void BattlegroundWS::HandleAreaTrigger(Player* player, uint32 trigger)
|
||||
//buff_guid = BgObjects[BG_WS_OBJECT_BERSERKBUFF_2];
|
||||
break;
|
||||
case 3646: // Alliance Flag spawn
|
||||
if (_flagState[BG_TEAM_HORDE] && !_flagState[BG_TEAM_ALLIANCE])
|
||||
if (GetFlagPickerGUID(BG_TEAM_HORDE) == player->GetGUID())
|
||||
if (_flagState[TEAM_HORDE] && !_flagState[TEAM_ALLIANCE])
|
||||
if (GetFlagPickerGUID(TEAM_HORDE) == player->GetGUID())
|
||||
EventPlayerCapturedFlag(player);
|
||||
break;
|
||||
case 3647: // Horde Flag spawn
|
||||
if (_flagState[BG_TEAM_ALLIANCE] && !_flagState[BG_TEAM_HORDE])
|
||||
if (GetFlagPickerGUID(BG_TEAM_ALLIANCE) == player->GetGUID())
|
||||
if (_flagState[TEAM_ALLIANCE] && !_flagState[TEAM_HORDE])
|
||||
if (GetFlagPickerGUID(TEAM_ALLIANCE) == player->GetGUID())
|
||||
EventPlayerCapturedFlag(player);
|
||||
break;
|
||||
case 3649: // unk1
|
||||
@@ -712,17 +712,17 @@ void BattlegroundWS::Reset()
|
||||
//call parent's class reset
|
||||
Battleground::Reset();
|
||||
|
||||
m_FlagKeepers[BG_TEAM_ALLIANCE] = 0;
|
||||
m_FlagKeepers[BG_TEAM_HORDE] = 0;
|
||||
m_FlagKeepers[TEAM_ALLIANCE] = 0;
|
||||
m_FlagKeepers[TEAM_HORDE] = 0;
|
||||
|
||||
m_DroppedFlagGUID[BG_TEAM_ALLIANCE] = 0;
|
||||
m_DroppedFlagGUID[BG_TEAM_HORDE] = 0;
|
||||
m_DroppedFlagGUID[TEAM_ALLIANCE] = 0;
|
||||
m_DroppedFlagGUID[TEAM_HORDE] = 0;
|
||||
|
||||
_flagState[BG_TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_BASE;
|
||||
_flagState[BG_TEAM_HORDE] = BG_WS_FLAG_STATE_ON_BASE;
|
||||
_flagState[TEAM_ALLIANCE] = BG_WS_FLAG_STATE_ON_BASE;
|
||||
_flagState[TEAM_HORDE] = BG_WS_FLAG_STATE_ON_BASE;
|
||||
|
||||
m_TeamScores[BG_TEAM_ALLIANCE] = 0;
|
||||
m_TeamScores[BG_TEAM_HORDE] = 0;
|
||||
m_TeamScores[TEAM_ALLIANCE] = 0;
|
||||
m_TeamScores[TEAM_HORDE] = 0;
|
||||
|
||||
if (sBattlegroundMgr->IsBGWeekend(GetTypeID()))
|
||||
{
|
||||
@@ -741,10 +741,10 @@ void BattlegroundWS::Reset()
|
||||
_bothFlagsKept = false;
|
||||
_flagDebuffState = 0;
|
||||
_flagSpellForceTimer = 0;
|
||||
_flagsDropTimer[BG_TEAM_ALLIANCE] = 0;
|
||||
_flagsDropTimer[BG_TEAM_HORDE] = 0;
|
||||
_flagsTimer[BG_TEAM_ALLIANCE] = 0;
|
||||
_flagsTimer[BG_TEAM_HORDE] = 0;
|
||||
_flagsDropTimer[TEAM_ALLIANCE] = 0;
|
||||
_flagsDropTimer[TEAM_HORDE] = 0;
|
||||
_flagsTimer[TEAM_ALLIANCE] = 0;
|
||||
_flagsTimer[TEAM_HORDE] = 0;
|
||||
}
|
||||
|
||||
void BattlegroundWS::EndBattleground(uint32 winner)
|
||||
@@ -822,28 +822,28 @@ void BattlegroundWS::FillInitialWorldStates(WorldPacket& data)
|
||||
data << uint32(BG_WS_FLAG_CAPTURES_ALLIANCE) << uint32(GetTeamScore(ALLIANCE));
|
||||
data << uint32(BG_WS_FLAG_CAPTURES_HORDE) << uint32(GetTeamScore(HORDE));
|
||||
|
||||
if (_flagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_GROUND)
|
||||
if (_flagState[TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_GROUND)
|
||||
data << uint32(BG_WS_FLAG_UNK_ALLIANCE) << uint32(-1);
|
||||
else if (_flagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_PLAYER)
|
||||
else if (_flagState[TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_PLAYER)
|
||||
data << uint32(BG_WS_FLAG_UNK_ALLIANCE) << uint32(1);
|
||||
else
|
||||
data << uint32(BG_WS_FLAG_UNK_ALLIANCE) << uint32(0);
|
||||
|
||||
if (_flagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_ON_GROUND)
|
||||
if (_flagState[TEAM_HORDE] == BG_WS_FLAG_STATE_ON_GROUND)
|
||||
data << uint32(BG_WS_FLAG_UNK_HORDE) << uint32(-1);
|
||||
else if (_flagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_ON_PLAYER)
|
||||
else if (_flagState[TEAM_HORDE] == BG_WS_FLAG_STATE_ON_PLAYER)
|
||||
data << uint32(BG_WS_FLAG_UNK_HORDE) << uint32(1);
|
||||
else
|
||||
data << uint32(BG_WS_FLAG_UNK_HORDE) << uint32(0);
|
||||
|
||||
data << uint32(BG_WS_FLAG_CAPTURES_MAX) << uint32(BG_WS_MAX_TEAM_SCORE);
|
||||
|
||||
if (_flagState[BG_TEAM_HORDE] == BG_WS_FLAG_STATE_ON_PLAYER)
|
||||
if (_flagState[TEAM_HORDE] == BG_WS_FLAG_STATE_ON_PLAYER)
|
||||
data << uint32(BG_WS_FLAG_STATE_HORDE) << uint32(2);
|
||||
else
|
||||
data << uint32(BG_WS_FLAG_STATE_HORDE) << uint32(1);
|
||||
|
||||
if (_flagState[BG_TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_PLAYER)
|
||||
if (_flagState[TEAM_ALLIANCE] == BG_WS_FLAG_STATE_ON_PLAYER)
|
||||
data << uint32(BG_WS_FLAG_STATE_ALLIANCE) << uint32(2);
|
||||
else
|
||||
data << uint32(BG_WS_FLAG_STATE_ALLIANCE) << uint32(1);
|
||||
|
||||
@@ -170,14 +170,14 @@ class BattlegroundWS : public Battleground
|
||||
/* BG Flags */
|
||||
uint64 GetFlagPickerGUID(int32 team) const
|
||||
{
|
||||
if (team == BG_TEAM_ALLIANCE || team == BG_TEAM_HORDE)
|
||||
if (team == TEAM_ALLIANCE || team == TEAM_HORDE)
|
||||
return m_FlagKeepers[team];
|
||||
return 0;
|
||||
}
|
||||
void SetAllianceFlagPicker(uint64 guid) { m_FlagKeepers[BG_TEAM_ALLIANCE] = guid; }
|
||||
void SetHordeFlagPicker(uint64 guid) { m_FlagKeepers[BG_TEAM_HORDE] = guid; }
|
||||
bool IsAllianceFlagPickedup() const { return m_FlagKeepers[BG_TEAM_ALLIANCE] != 0; }
|
||||
bool IsHordeFlagPickedup() const { return m_FlagKeepers[BG_TEAM_HORDE] != 0; }
|
||||
void SetAllianceFlagPicker(uint64 guid) { m_FlagKeepers[TEAM_ALLIANCE] = guid; }
|
||||
void SetHordeFlagPicker(uint64 guid) { m_FlagKeepers[TEAM_HORDE] = guid; }
|
||||
bool IsAllianceFlagPickedup() const { return m_FlagKeepers[TEAM_ALLIANCE] != 0; }
|
||||
bool IsHordeFlagPickedup() const { return m_FlagKeepers[TEAM_HORDE] != 0; }
|
||||
void RespawnFlag(uint32 Team, bool captured);
|
||||
void RespawnFlagAfterDrop(uint32 Team);
|
||||
uint8 GetFlagState(uint32 team) { return _flagState[GetTeamIndexByTeamId(team)]; }
|
||||
|
||||
@@ -257,14 +257,14 @@ void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket& /*recv_d
|
||||
Player* allianceFlagCarrier = NULL;
|
||||
Player* hordeFlagCarrier = NULL;
|
||||
|
||||
if (uint64 guid = bg->GetFlagPickerGUID(BG_TEAM_ALLIANCE))
|
||||
if (uint64 guid = bg->GetFlagPickerGUID(TEAM_ALLIANCE))
|
||||
{
|
||||
allianceFlagCarrier = ObjectAccessor::FindPlayer(guid);
|
||||
if (allianceFlagCarrier)
|
||||
++flagCarrierCount;
|
||||
}
|
||||
|
||||
if (uint64 guid = bg->GetFlagPickerGUID(BG_TEAM_HORDE))
|
||||
if (uint64 guid = bg->GetFlagPickerGUID(TEAM_HORDE))
|
||||
{
|
||||
hordeFlagCarrier = ObjectAccessor::FindPlayer(guid);
|
||||
if (hordeFlagCarrier)
|
||||
|
||||
@@ -1730,7 +1730,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
|
||||
|
||||
sWorld->UpdateCharacterNameData(GUID_LOPART(guid), newname, gender, race);
|
||||
|
||||
BattlegroundTeamId team = BG_TEAM_ALLIANCE;
|
||||
TeamId team = TEAM_ALLIANCE;
|
||||
|
||||
// Search each faction is targeted
|
||||
switch (race)
|
||||
@@ -1740,7 +1740,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
|
||||
case RACE_UNDEAD_PLAYER:
|
||||
case RACE_TROLL:
|
||||
case RACE_BLOODELF:
|
||||
team = BG_TEAM_HORDE;
|
||||
team = TEAM_HORDE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -1757,7 +1757,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
|
||||
// Faction specific languages
|
||||
if (team == BG_TEAM_HORDE)
|
||||
if (team == TEAM_HORDE)
|
||||
stmt->setUInt16(1, 109);
|
||||
else
|
||||
stmt->setUInt16(1, 98);
|
||||
@@ -1816,7 +1816,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
|
||||
uint32 numFullTaximasks = level / 7;
|
||||
if (numFullTaximasks > 11)
|
||||
numFullTaximasks = 11;
|
||||
if (team == BG_TEAM_ALLIANCE)
|
||||
if (team == TEAM_ALLIANCE)
|
||||
{
|
||||
if (playerClass != CLASS_DEATH_KNIGHT)
|
||||
{
|
||||
@@ -1868,7 +1868,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
|
||||
{
|
||||
Quest *qinfo = iter->second;
|
||||
uint32 requiredRaces = qinfo->GetRequiredRaces();
|
||||
if (team == BG_TEAM_ALLIANCE)
|
||||
if (team == TEAM_ALLIANCE)
|
||||
{
|
||||
if (requiredRaces & RACEMASK_ALLIANCE)
|
||||
{
|
||||
@@ -1876,7 +1876,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
|
||||
quests << ',';
|
||||
}
|
||||
}
|
||||
else // if (team == BG_TEAM_HORDE)
|
||||
else // if (team == TEAM_HORDE)
|
||||
{
|
||||
if (requiredRaces & RACEMASK_HORDE)
|
||||
{
|
||||
@@ -1929,7 +1929,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PLAYER_HOMEBIND);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
if (team == BG_TEAM_ALLIANCE)
|
||||
if (team == TEAM_ALLIANCE)
|
||||
{
|
||||
stmt->setUInt16(1, 0);
|
||||
stmt->setUInt16(2, 1519);
|
||||
@@ -1956,13 +1956,13 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
|
||||
uint32 achiev_horde = it->second;
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT);
|
||||
stmt->setUInt16(0, uint16(team == BG_TEAM_ALLIANCE ? achiev_alliance : achiev_horde));
|
||||
stmt->setUInt16(0, uint16(team == TEAM_ALLIANCE ? achiev_alliance : achiev_horde));
|
||||
stmt->setUInt32(1, lowGuid);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ACHIEVEMENT);
|
||||
stmt->setUInt16(0, uint16(team == BG_TEAM_ALLIANCE ? achiev_alliance : achiev_horde));
|
||||
stmt->setUInt16(1, uint16(team == BG_TEAM_ALLIANCE ? achiev_horde : achiev_alliance));
|
||||
stmt->setUInt16(0, uint16(team == TEAM_ALLIANCE ? achiev_alliance : achiev_horde));
|
||||
stmt->setUInt16(1, uint16(team == TEAM_ALLIANCE ? achiev_horde : achiev_alliance));
|
||||
stmt->setUInt32(2, lowGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
@@ -1974,8 +1974,8 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
|
||||
uint32 item_horde = it->second;
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INVENTORY_FACTION_CHANGE);
|
||||
stmt->setUInt32(0, (team == BG_TEAM_ALLIANCE ? item_alliance : item_horde));
|
||||
stmt->setUInt32(1, (team == BG_TEAM_ALLIANCE ? item_horde : item_alliance));
|
||||
stmt->setUInt32(0, (team == TEAM_ALLIANCE ? item_alliance : item_horde));
|
||||
stmt->setUInt32(1, (team == TEAM_ALLIANCE ? item_horde : item_alliance));
|
||||
stmt->setUInt32(2, guid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
@@ -1987,13 +1987,13 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
|
||||
uint32 spell_horde = it->second;
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL_BY_SPELL);
|
||||
stmt->setUInt32(0, (team == BG_TEAM_ALLIANCE ? spell_alliance : spell_horde));
|
||||
stmt->setUInt32(0, (team == TEAM_ALLIANCE ? spell_alliance : spell_horde));
|
||||
stmt->setUInt32(1, lowGuid);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_SPELL_FACTION_CHANGE);
|
||||
stmt->setUInt32(0, (team == BG_TEAM_ALLIANCE ? spell_alliance : spell_horde));
|
||||
stmt->setUInt32(1, (team == BG_TEAM_ALLIANCE ? spell_horde : spell_alliance));
|
||||
stmt->setUInt32(0, (team == TEAM_ALLIANCE ? spell_alliance : spell_horde));
|
||||
stmt->setUInt32(1, (team == TEAM_ALLIANCE ? spell_horde : spell_alliance));
|
||||
stmt->setUInt32(2, lowGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
@@ -2005,13 +2005,13 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
|
||||
uint32 reputation_horde = it->second;
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_REP_BY_FACTION);
|
||||
stmt->setUInt32(0, uint16(team == BG_TEAM_ALLIANCE ? reputation_alliance : reputation_horde));
|
||||
stmt->setUInt32(0, uint16(team == TEAM_ALLIANCE ? reputation_alliance : reputation_horde));
|
||||
stmt->setUInt32(1, lowGuid);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_REP_FACTION_CHANGE);
|
||||
stmt->setUInt16(0, uint16(team == BG_TEAM_ALLIANCE ? reputation_alliance : reputation_horde));
|
||||
stmt->setUInt16(1, uint16(team == BG_TEAM_ALLIANCE ? reputation_horde : reputation_alliance));
|
||||
stmt->setUInt16(0, uint16(team == TEAM_ALLIANCE ? reputation_alliance : reputation_horde));
|
||||
stmt->setUInt16(1, uint16(team == TEAM_ALLIANCE ? reputation_horde : reputation_alliance));
|
||||
stmt->setUInt32(2, lowGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
@@ -2037,7 +2037,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
|
||||
CharTitlesEntry const* atitleInfo = sCharTitlesStore.LookupEntry(title_alliance);
|
||||
CharTitlesEntry const* htitleInfo = sCharTitlesStore.LookupEntry(title_horde);
|
||||
// new team
|
||||
if (team == BG_TEAM_ALLIANCE)
|
||||
if (team == TEAM_ALLIANCE)
|
||||
{
|
||||
uint32 bitIndex = htitleInfo->bit_index;
|
||||
uint32 index = bitIndex / 32;
|
||||
|
||||
Reference in New Issue
Block a user