Skip to content

Commit

Permalink
BG: Fix entering arenas
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Feb 4, 2025
1 parent 297faa2 commit 7a1513a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
13 changes: 0 additions & 13 deletions src/game/BattleGround/BattleGroundMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,19 +394,6 @@ BattleGround* BattleGroundMgr::CreateNewBattleGround(BattleGroundTypeId bgTypeId
return nullptr;
}

// for arenas there is random map used
if (bgTemplate->IsArena())
{
BattleGroundTypeId arenas[] = { BATTLEGROUND_NA, BATTLEGROUND_BE, BATTLEGROUND_RL };
bgTypeId = arenas[urand(0, countof(arenas) - 1)];
bgTemplate = GetBattleGroundTemplate(bgTypeId);
if (!bgTemplate)
{
sLog.outError("BattleGround: CreateNewBattleGround - bg template not found for %u", bgTypeId);
return nullptr;
}
}

BattleGround* bg;
// create a copy of the BG template
switch (bgTypeId)
Expand Down
27 changes: 25 additions & 2 deletions src/game/BattleGround/BattleGroundQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ bool BattleGroundQueueItem::InviteGroupToBg(GroupQueueInfo* groupInfo, BattleGro
// loop through the players
for (auto itr = groupInfo->players.begin(); itr != groupInfo->players.end(); ++itr)
{
sWorld.GetMessager().AddMessage([playerGuid = itr->first, bgQueueTypeId, bgTypeId, isInvited = groupInfo->isInvitedToBgInstanceGuid, clientInstanceId = queueInfo.GetClientInstanceId(), isRated = queueInfo.IsRated(), mapId = queueInfo.GetMapId(), arenaType = groupInfo->arenaType, removeInviteTime = groupInfo->removeInviteTime, instanceId = queueInfo.GetInstanceId(), isBg = queueInfo.IsBattleGround()](World* /*world*/)
sWorld.GetMessager().AddMessage([playerGuid = itr->first, bgQueueTypeId, bgTypeId, isInvited = groupInfo->isInvitedToBgInstanceGuid, clientInstanceId = queueInfo.GetClientInstanceId(), isRated = queueInfo.IsRated(), mapId = queueInfo.GetMapId(), arenaType = groupInfo->arenaType, removeInviteTime = groupInfo->removeInviteTime, instanceId = queueInfo.GetInstanceId()](World* /*world*/)
{
Player* plr = sObjectMgr.GetPlayer(playerGuid);
// if offline, skip him, can happen due to asynchronicity now
Expand All @@ -541,7 +541,7 @@ bool BattleGroundQueueItem::InviteGroupToBg(GroupQueueInfo* groupInfo, BattleGro
DEBUG_LOG("Battleground: invited %s to BG instance %u queueindex %u bgtype %u, I can't help it if they don't press the enter battle button.", plr->GetGuidStr().c_str(), instanceId, queueSlot, bgTypeId);

// send status packet
sBattleGroundMgr.BuildBattleGroundStatusPacket(data, isBg, bgTypeId, clientInstanceId, isRated, mapId, queueSlot, STATUS_WAIT_JOIN, INVITE_ACCEPT_WAIT_TIME, 0, arenaType, TEAM_NONE);
sBattleGroundMgr.BuildBattleGroundStatusPacket(data, true, bgTypeId, clientInstanceId, isRated, mapId, queueSlot, STATUS_WAIT_JOIN, INVITE_ACCEPT_WAIT_TIME, 0, arenaType, TEAM_NONE);

plr->GetSession()->SendPacket(data);
});
Expand Down Expand Up @@ -947,6 +947,15 @@ void BattleGroundQueueItem::Update(BattleGroundQueue& queue, BattleGroundTypeId
}
}

auto pickRandomArena = [&](BattleGroundTypeId& bgTypeId, BattleGround*& bgTemplate)
{
BattleGroundTypeId arenas[] = { BATTLEGROUND_NA, BATTLEGROUND_BE, BATTLEGROUND_RL };
bgTypeId = arenas[urand(0, countof(arenas) - 1)];
bgTemplate = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId);
if (!bgTemplate)
sLog.outError("BattleGround: CreateNewBattleGround - bg template not found for %u", bgTypeId);
};

m_selectionPools[TEAM_INDEX_ALLIANCE].Init();
m_selectionPools[TEAM_INDEX_HORDE].Init();

Expand Down Expand Up @@ -1006,6 +1015,13 @@ void BattleGroundQueueItem::Update(BattleGroundQueue& queue, BattleGroundTypeId
return;
}

if (bgTypeId == BATTLEGROUND_AA)
{
pickRandomArena(bgTypeId, bgTemplate);
if (bgTemplate == nullptr)
return;
}

BattleGroundInQueueInfo bgInfo;
bgInfo.Fill(bgTemplate);
bgInfo.bracketId = bracketId;
Expand Down Expand Up @@ -1141,6 +1157,13 @@ void BattleGroundQueueItem::Update(BattleGroundQueue& queue, BattleGroundTypeId
return;
}

if (bgTypeId == BATTLEGROUND_AA)
{
pickRandomArena(bgTypeId, bgTemplate);
if (bgTemplate == nullptr)
return;
}

BattleGroundInQueueInfo bgInfo;
bgInfo.Fill(bgTemplate);
bgInfo.bracketId = bracketId;
Expand Down

0 comments on commit 7a1513a

Please sign in to comment.