aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/updates/world/2012_11_14_02_world_battleground_template.sql3
-rwxr-xr-xsrc/server/game/Battlegrounds/Battleground.cpp22
-rwxr-xr-xsrc/server/game/Battlegrounds/BattlegroundMgr.cpp14
-rwxr-xr-xsrc/server/game/Battlegrounds/BattlegroundQueue.cpp2
-rwxr-xr-xsrc/server/game/Handlers/BattleGroundHandler.cpp159
5 files changed, 104 insertions, 96 deletions
diff --git a/sql/updates/world/2012_11_14_02_world_battleground_template.sql b/sql/updates/world/2012_11_14_02_world_battleground_template.sql
new file mode 100644
index 00000000000..b69216ea380
--- /dev/null
+++ b/sql/updates/world/2012_11_14_02_world_battleground_template.sql
@@ -0,0 +1,3 @@
+DELETE FROM `battleground_template` WHERE `id` = 6;
+INSERT INTO `battleground_template` (`id`, `MinPlayersPerTeam`, `MaxPlayersPerTeam`, `MinLvl`, `MaxLvl`, `AllianceStartLoc`, `AllianceStartO`, `HordeStartLoc`, `HordeStartO`, `StartMaxDist`, `Weight`, `ScriptName`, `Comment`) VALUES
+(6,0,2,10,80,0,0,0,0,0,1,'','All Arena');
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index 50f8554d5db..cff58456a8d 100755
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -642,7 +642,12 @@ void Battleground::SendPacketToTeam(uint32 TeamID, WorldPacket* packet, Player*
for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
if (Player* player = _GetPlayerForTeam(TeamID, itr, "SendPacketToTeam"))
if (self || sender != player)
- player->GetSession()->SendPacket(packet);
+ {
+ WorldSession* session = player->GetSession();
+ sLog->outDebug(LOG_FILTER_BATTLEGROUND, "%s %s - SendPacketToTeam %u, Player: %s", GetOpcodeNameForLogging(packet->GetOpcode()).c_str(),
+ session->GetPlayerInfo().c_str(), TeamID, sender->GetName().c_str());
+ session->SendPacket(packet);
+ }
}
void Battleground::PlaySoundToAll(uint32 SoundID)
@@ -1064,7 +1069,7 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
if (Transport)
player->TeleportToBGEntryPoint();
- sLog->outInfo(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Removed player %s from Battleground.", player->GetName().c_str());
+ sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Removed player %s from Battleground.", player->GetName().c_str());
}
//battleground object will be deleted next Battleground::Update() call
@@ -1078,9 +1083,6 @@ void Battleground::Reset()
SetStartTime(0);
SetEndTime(0);
SetLastResurrectTime(0);
- SetArenaType(0);
- SetRated(false);
-
m_Events = 0;
if (m_InvitedAlliance > 0 || m_InvitedHorde > 0)
@@ -1177,10 +1179,9 @@ void Battleground::AddPlayer(Player* player)
player->ResetAllPowers();
}
- WorldPacket teammate;
- teammate.Initialize(SMSG_ARENA_OPPONENT_UPDATE, 8);
- teammate << uint64(player->GetGUID());
- SendPacketToTeam(team, &teammate, player, false);
+ WorldPacket data(SMSG_ARENA_OPPONENT_UPDATE, 8);
+ data << uint64(player->GetGUID());
+ SendPacketToTeam(team, &data, player, false);
}
else
{
@@ -1203,9 +1204,6 @@ void Battleground::AddPlayer(Player* player)
// setup BG group membership
PlayerAddedToBGCheckIfBGIsRunning(player);
AddOrSetPlayerToCorrectBgGroup(player, team);
-
- // Log
- sLog->outInfo(LOG_FILTER_BATTLEGROUND, "BATTLEGROUND: Player %s joined the battle.", player->GetName().c_str());
}
// this method adds player to his team's bg group, or sets his correct group if player is already in bg group
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
index bfa3b955427..6d472faf9c6 100755
--- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
@@ -131,7 +131,7 @@ void BattlegroundMgr::Update(uint32 diff)
if (m_NextRatedArenaUpdate < diff)
{
// forced update for rated arenas (scan all, but skipped non rated)
- sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundMgr: UPDATING ARENA QUEUES");
+ sLog->outTrace(LOG_FILTER_ARENAS, "BattlegroundMgr: UPDATING ARENA QUEUES");
for (int qtype = BATTLEGROUND_QUEUE_2v2; qtype <= BATTLEGROUND_QUEUE_5v5; ++qtype)
for (int bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket)
m_BattlegroundQueues[qtype].BattlegroundQueueUpdate(diff,
@@ -904,25 +904,25 @@ BattlegroundQueueTypeId BattlegroundMgr::BGQueueTypeId(BattlegroundTypeId bgType
{
switch (bgTypeId)
{
- case BATTLEGROUND_WS:
- return BATTLEGROUND_QUEUE_WS;
case BATTLEGROUND_AB:
return BATTLEGROUND_QUEUE_AB;
case BATTLEGROUND_AV:
return BATTLEGROUND_QUEUE_AV;
case BATTLEGROUND_EY:
return BATTLEGROUND_QUEUE_EY;
- case BATTLEGROUND_SA:
- return BATTLEGROUND_QUEUE_SA;
case BATTLEGROUND_IC:
return BATTLEGROUND_QUEUE_IC;
case BATTLEGROUND_RB:
return BATTLEGROUND_QUEUE_RB;
+ case BATTLEGROUND_SA:
+ return BATTLEGROUND_QUEUE_SA;
+ case BATTLEGROUND_WS:
+ return BATTLEGROUND_QUEUE_WS;
case BATTLEGROUND_AA:
- case BATTLEGROUND_NA:
- case BATTLEGROUND_RL:
case BATTLEGROUND_BE:
case BATTLEGROUND_DS:
+ case BATTLEGROUND_NA:
+ case BATTLEGROUND_RL:
case BATTLEGROUND_RV:
switch (arenaType)
{
diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
index 922cccb9186..012d970901d 100755
--- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
@@ -475,7 +475,7 @@ bool BattlegroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg,
uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId);
- sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: invited player %s (%u) to BG instance %u queueindex %u bgtype %u, I can't help it if they don't press the enter battle button.",
+ sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: invited player %s (%u) to BG instance %u queueindex %u bgtype %u",
player->GetName().c_str(), player->GetGUIDLow(), bg->GetInstanceID(), queueSlot, bg->GetTypeID());
// send status packet
diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp
index 3a359704916..0a076dfaa34 100755
--- a/src/server/game/Handlers/BattleGroundHandler.cpp
+++ b/src/server/game/Handlers/BattleGroundHandler.cpp
@@ -342,8 +342,6 @@ void WorldSession::HandleBattlefieldListOpcode(WorldPacket &recvData)
void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData)
{
- sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_BATTLEFIELD_PORT Message");
-
uint8 type; // arenatype if arena
uint8 unk2; // unk, can be 0x0 (may be if was invited?) and 0x1
uint32 bgTypeId_; // type id from dbc
@@ -351,16 +349,17 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData)
uint8 action; // enter battle 0x1, leave queue 0x0
recvData >> type >> unk2 >> bgTypeId_ >> unk >> action;
-
if (!sBattlemasterListStore.LookupEntry(bgTypeId_))
{
- sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundHandler: invalid bgtype (%u) with player (Name: %s, GUID: %u) received.", bgTypeId_, _player->GetName().c_str(), _player->GetGUIDLow());
+ sLog->outDebug(LOG_FILTER_BATTLEGROUND, "CMSG_BATTLEFIELD_PORT %s ArenaType: %u, Unk: %u, BgType: %u, Action: %u. Invalid BgType!",
+ GetPlayerInfo().c_str(), type, unk2, bgTypeId_, action);
return;
}
if (!_player->InBattlegroundQueue())
{
- sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundHandler: Invalid CMSG_BATTLEFIELD_PORT received from player (Name: %s, GUID: %u), he is not in bg_queue.", _player->GetName().c_str(), _player->GetGUIDLow());
+ sLog->outDebug(LOG_FILTER_BATTLEGROUND, "CMSG_BATTLEFIELD_PORT %s ArenaType: %u, Unk: %u, BgType: %u, Action: %u. Player not in queue!",
+ GetPlayerInfo().c_str(), type, unk2, bgTypeId_, action);
return;
}
@@ -372,27 +371,39 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData)
GroupQueueInfo ginfo;
if (!bgQueue.GetPlayerGroupInfoData(_player->GetGUID(), &ginfo))
{
- sLog->outError(LOG_FILTER_NETWORKIO, "BattlegroundHandler: itrplayerstatus not found.");
+ sLog->outDebug(LOG_FILTER_BATTLEGROUND, "CMSG_BATTLEFIELD_PORT %s ArenaType: %u, Unk: %u, BgType: %u, Action: %u. Player not in queue (No player Group Info)!",
+ GetPlayerInfo().c_str(), type, unk2, bgTypeId_, action);
return;
}
// if action == 1, then instanceId is required
if (!ginfo.IsInvitedToBGInstanceGUID && action == 1)
{
- sLog->outError(LOG_FILTER_NETWORKIO, "BattlegroundHandler: instance not found.");
+ sLog->outDebug(LOG_FILTER_BATTLEGROUND, "CMSG_BATTLEFIELD_PORT %s ArenaType: %u, Unk: %u, BgType: %u, Action: %u. Player is not invited to any bg!",
+ GetPlayerInfo().c_str(), type, unk2, bgTypeId_, action);
return;
}
Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
-
- // bg template might and must be used in case of leaving queue, when instance is not created yet
- if (!bg && action == 0)
- bg = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
if (!bg)
{
- sLog->outError(LOG_FILTER_NETWORKIO, "BattlegroundHandler: bg_template not found for type id %u.", bgTypeId);
- return;
+ if (action)
+ {
+ sLog->outDebug(LOG_FILTER_BATTLEGROUND, "CMSG_BATTLEFIELD_PORT %s ArenaType: %u, Unk: %u, BgType: %u, Action: %u. Cant find BG with id %u!",
+ GetPlayerInfo().c_str(), type, unk2, bgTypeId_, action, ginfo.IsInvitedToBGInstanceGUID);
+ return;
+ }
+
+ bg = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
+ if (!bg)
+ {
+ sLog->outError(LOG_FILTER_NETWORKIO, "BattlegroundHandler: bg_template not found for type id %u.", bgTypeId);
+ return;
+ }
}
+ sLog->outDebug(LOG_FILTER_BATTLEGROUND, "CMSG_BATTLEFIELD_PORT %s ArenaType: %u, Unk: %u, BgType: %u, Action: %u.",
+ GetPlayerInfo().c_str(), type, unk2, bgTypeId_, action);
+
// expected bracket entry
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
if (!bracketEntry)
@@ -409,86 +420,82 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData)
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data2, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS);
_player->GetSession()->SendPacket(&data2);
action = 0;
- sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName().c_str(), _player->GetGUIDLow());
+ sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Player %s (%u) has a deserter debuff, do not port him to battleground!", _player->GetName().c_str(), _player->GetGUIDLow());
}
//if player don't match battleground max level, then do not allow him to enter! (this might happen when player leveled up during his waiting in queue
if (_player->getLevel() > bg->GetMaxLevel())
{
- sLog->outError(LOG_FILTER_NETWORKIO, "Battleground: Player %s (%u) has level (%u) higher than maxlevel (%u) of battleground (%u)! Do not port him to battleground!",
+ sLog->outError(LOG_FILTER_NETWORKIO, "Player %s (%u) has level (%u) higher than maxlevel (%u) of battleground (%u)! Do not port him to battleground!",
_player->GetName().c_str(), _player->GetGUIDLow(), _player->getLevel(), bg->GetMaxLevel(), bg->GetTypeID());
action = 0;
}
}
uint32 queueSlot = _player->GetBattlegroundQueueIndex(bgQueueTypeId);
WorldPacket data;
- switch (action)
+ if (action)
{
- case 1: // port to battleground
- if (!_player->IsInvitedForBattlegroundQueueType(bgQueueTypeId))
- return; // cheating?
+ if (!_player->IsInvitedForBattlegroundQueueType(bgQueueTypeId))
+ return; // cheating?
- if (!_player->InBattleground())
- _player->SetBattlegroundEntryPoint();
+ if (!_player->InBattleground())
+ _player->SetBattlegroundEntryPoint();
- // resurrect the player
- if (!_player->isAlive())
- {
- _player->ResurrectPlayer(1.0f);
- _player->SpawnCorpseBones();
- }
- // stop taxi flight at port
- if (_player->isInFlight())
- {
- _player->GetMotionMaster()->MovementExpired();
- _player->CleanupAfterTaxiFlight();
- }
+ // resurrect the player
+ if (!_player->isAlive())
+ {
+ _player->ResurrectPlayer(1.0f);
+ _player->SpawnCorpseBones();
+ }
+ // stop taxi flight at port
+ if (_player->isInFlight())
+ {
+ _player->GetMotionMaster()->MovementExpired();
+ _player->CleanupAfterTaxiFlight();
+ }
- sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime(), bg->GetArenaType());
- _player->GetSession()->SendPacket(&data);
- // remove battleground queue status from BGmgr
- bgQueue.RemovePlayer(_player->GetGUID(), false);
- // this is still needed here if battleground "jumping" shouldn't add deserter debuff
- // also this is required to prevent stuck at old battleground after SetBattlegroundId set to new
- if (Battleground* currentBg = _player->GetBattleground())
- currentBg->RemovePlayerAtLeave(_player->GetGUID(), false, true);
-
- // set the destination instance id
- _player->SetBattlegroundId(bg->GetInstanceID(), bgTypeId);
- // set the destination team
- _player->SetBGTeam(ginfo.Team);
- // bg->HandleBeforeTeleportToBattleground(_player);
- sBattlegroundMgr->SendToBattleground(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
- // add only in HandleMoveWorldPortAck()
- // bg->AddPlayer(_player, team);
- sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUIDLow(), bg->GetInstanceID(), bg->GetTypeID(), bgQueueTypeId);
- break;
- case 0: // leave queue
- if (bg->isArena() && bg->GetStatus() > STATUS_WAIT_QUEUE)
- return;
+ sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime(), bg->GetArenaType());
+ _player->GetSession()->SendPacket(&data);
+ // remove battleground queue status from BGmgr
+ bgQueue.RemovePlayer(_player->GetGUID(), false);
+ // this is still needed here if battleground "jumping" shouldn't add deserter debuff
+ // also this is required to prevent stuck at old battleground after SetBattlegroundId set to new
+ if (Battleground* currentBg = _player->GetBattleground())
+ currentBg->RemovePlayerAtLeave(_player->GetGUID(), false, true);
+
+ // set the destination instance id
+ _player->SetBattlegroundId(bg->GetInstanceID(), bgTypeId);
+ // set the destination team
+ _player->SetBGTeam(ginfo.Team);
+ // bg->HandleBeforeTeleportToBattleground(_player);
+ sBattlegroundMgr->SendToBattleground(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
+ // add only in HandleMoveWorldPortAck()
+ // bg->AddPlayer(_player, team);
+ sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUIDLow(), bg->GetInstanceID(), bg->GetTypeID(), bgQueueTypeId);
+ }
+ else // leave queue
+ {
+ if (bg->isArena() && bg->GetStatus() > STATUS_WAIT_QUEUE)
+ return;
- // if player leaves rated arena match before match start, it is counted as he played but he lost
- if (ginfo.IsRated && ginfo.IsInvitedToBGInstanceGUID)
+ // if player leaves rated arena match before match start, it is counted as he played but he lost
+ if (ginfo.IsRated && ginfo.IsInvitedToBGInstanceGUID)
+ {
+ ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(ginfo.Team);
+ if (at)
{
- ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(ginfo.Team);
- 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);
- at->MemberLost(_player, ginfo.OpponentsMatchmakerRating);
- at->SaveToDB();
- }
+ 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);
+ at->MemberLost(_player, ginfo.OpponentsMatchmakerRating);
+ at->SaveToDB();
}
- _player->RemoveBattlegroundQueueId(bgQueueTypeId); // must be called this way, because if you move this call to queue->removeplayer, it causes bugs
- sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_NONE, 0, 0, 0);
- bgQueue.RemovePlayer(_player->GetGUID(), true);
- // player left queue, we should update it - do not update Arena Queue
- if (!ginfo.ArenaType)
- sBattlegroundMgr->ScheduleQueueUpdate(ginfo.ArenaMatchmakerRating, ginfo.ArenaType, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
- SendPacket(&data);
- sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) left queue for bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUIDLow(), bg->GetTypeID(), bgQueueTypeId);
- break;
- default:
- sLog->outError(LOG_FILTER_NETWORKIO, "Battleground port: unknown action %u", action);
- break;
+ }
+ _player->RemoveBattlegroundQueueId(bgQueueTypeId); // must be called this way, because if you move this call to queue->removeplayer, it causes bugs
+ sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_NONE, 0, 0, 0);
+ bgQueue.RemovePlayer(_player->GetGUID(), true);
+ // player left queue, we should update it - do not update Arena Queue
+ if (!ginfo.ArenaType)
+ sBattlegroundMgr->ScheduleQueueUpdate(ginfo.ArenaMatchmakerRating, ginfo.ArenaType, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
+ SendPacket(&data);
+ sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) left queue for bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUIDLow(), bg->GetTypeID(), bgQueueTypeId);
}
}