aboutsummaryrefslogtreecommitdiff
path: root/src/game/BattleGround.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/BattleGround.cpp')
-rw-r--r--src/game/BattleGround.cpp56
1 files changed, 36 insertions, 20 deletions
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index aebe9bd28b1..b45a9961671 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -135,7 +135,7 @@ BattleGround::BattleGround()
m_ClientInstanceID = 0;
m_EndTime = 0;
m_LastResurrectTime = 0;
- m_QueueId = QUEUE_ID_MAX_LEVEL_19;
+ m_BracketId = BG_BRACKET_ID_FIRST;
m_InvitedAlliance = 0;
m_InvitedHorde = 0;
m_ArenaType = 0;
@@ -503,11 +503,13 @@ void BattleGround::SendPacketToAll(WorldPacket *packet)
{
for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
+ if (itr->second.OfflineRemoveTime)
+ continue;
Player *plr = objmgr.GetPlayer(itr->first);
if (plr)
plr->GetSession()->SendPacket(packet);
else
- sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
+ sLog.outError("BattleGround:SendPacketToAll: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
}
}
@@ -515,11 +517,12 @@ void BattleGround::SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player *
{
for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
+ if (itr->second.OfflineRemoveTime)
+ continue;
Player *plr = objmgr.GetPlayer(itr->first);
-
if (!plr)
{
- sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
+ sLog.outError("BattleGround:SendPacketToTeam: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
continue;
}
@@ -547,11 +550,13 @@ void BattleGround::PlaySoundToTeam(uint32 SoundID, uint32 TeamID)
for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
+ if (itr->second.OfflineRemoveTime)
+ continue;
Player *plr = objmgr.GetPlayer(itr->first);
if (!plr)
{
- sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
+ sLog.outError("BattleGround:PlaySoundToTeam: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
continue;
}
@@ -570,11 +575,13 @@ void BattleGround::CastSpellOnTeam(uint32 SpellID, uint32 TeamID)
{
for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
+ if (itr->second.OfflineRemoveTime)
+ continue;
Player *plr = objmgr.GetPlayer(itr->first);
if (!plr)
{
- sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
+ sLog.outError("BattleGround:CastSpellOnTeam: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
continue;
}
@@ -606,11 +613,13 @@ void BattleGround::RewardHonorToTeam(uint32 Honor, uint32 TeamID)
{
for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
+ if (itr->second.OfflineRemoveTime)
+ continue;
Player *plr = objmgr.GetPlayer(itr->first);
if (!plr)
{
- sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
+ sLog.outError("BattleGround:RewardHonorToTeam: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
continue;
}
@@ -631,11 +640,13 @@ void BattleGround::RewardReputationToTeam(uint32 faction_id, uint32 Reputation,
for (BattleGroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
+ if (itr->second.OfflineRemoveTime)
+ continue;
Player *plr = objmgr.GetPlayer(itr->first);
if (!plr)
{
- sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
+ sLog.outError("BattleGround:RewardReputationToTeam: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
continue;
}
@@ -722,10 +733,9 @@ void BattleGround::EndBattleGround(uint32 winner)
for (BattleGroundPlayerMap::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
- Player *plr = objmgr.GetPlayer(itr->first);
uint32 team = itr->second.Team;
- if (!plr)
+ if (itr->second.OfflineRemoveTime)
{
//if rated arena match - make member lost!
if (isArena() && isRated() && winner_arena_team && loser_arena_team && winner_arena_team != loser_arena_team)
@@ -735,9 +745,11 @@ void BattleGround::EndBattleGround(uint32 winner)
else
loser_arena_team->OfflineMemberLost(itr->first, winner_rating);
}
- sLog.outError("BattleGround: Player (GUID: %u) not found!", GUID_LOPART(itr->first));
continue;
}
+ Player *plr = objmgr.GetPlayer(itr->first);
+ if (!plr)
+ sLog.outError("BattleGround:EndBattleGround Player (GUID: %u) not found!", GUID_LOPART(itr->first));
// should remove spirit of redemption
if(plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
@@ -1077,7 +1089,7 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
{
// a player has left the battleground, so there are free slots -> add to queue
AddToBGFreeSlotQueue();
- sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, GetQueueId());
+ sBattleGroundMgr.ScheduleQueueUpdate(0, 0, bgQueueTypeId, bgTypeId, GetBracketId());
}
// Let others know
WorldPacket data;
@@ -1104,7 +1116,6 @@ void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
// this method is called when no players remains in battleground
void BattleGround::Reset()
{
- SetQueueId(QUEUE_ID_MAX_LEVEL_19);
SetWinner(WINNER_NONE);
SetStatus(STATUS_WAIT_QUEUE);
SetStartTime(0);
@@ -1279,16 +1290,15 @@ void BattleGround::EventPlayerLoggedOut(Player* player)
m_Players[player->GetGUID()].OfflineRemoveTime = sWorld.GetGameTime() + MAX_OFFLINE_TIME;
if (GetStatus() == STATUS_IN_PROGRESS)
{
- if (isBattleGround())
- EventPlayerDroppedFlag(player);
- else
- {
- //1 player is logging out, if it is the last, then end arena!
+ // drop flag and handle other cleanups
+ RemovePlayer(player, player->GetGUID());
+
+ // 1 player is logging out, if it is the last, then end arena!
+ if (isArena())
if (GetAlivePlayersCountByTeam(player->GetTeam()) <= 1 && GetPlayersCountByTeam(GetOtherTeam(player->GetTeam())))
EndBattleGround(GetOtherTeam(player->GetTeam()));
- }
- return;
}
+
player->LeaveBattleground();
}
@@ -1919,3 +1929,9 @@ bool BattleGround::IsTeamScoreInRange(uint32 team, uint32 minScore, uint32 maxSc
uint32 score = (m_TeamScores[team_idx] < 0) ? 0 : uint32(m_TeamScores[team_idx]);
return score >= minScore && score <= maxScore;
}
+
+void BattleGround::SetBracket( PvPDifficultyEntry const* bracketEntry )
+{
+ m_BracketId = bracketEntry->GetBracketId();
+ SetLevelRange(bracketEntry->minLevel,bracketEntry->maxLevel);
+}