bool BattlegroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg, uint32 side) { // set side if needed if (side) ginfo->team = side; if (!ginfo->isInvitedToBGInstanceGUID) { // not yet invited // set invitation ginfo->isInvitedToBGInstanceGUID = bg->GetInstanceID(); BattlegroundTypeId bgTypeId = bg->GetTypeID(); BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, bg->GetRatedType()); BattlegroundBracketId bracket_id = bg->GetBracketId(); ginfo->removeInviteTime = getMSTime() + INVITE_ACCEPT_WAIT_TIME; // loop through the players for (std::map<uint64, PlayerQueueInfo*>::iterator itr = ginfo->players.begin(); itr != ginfo->players.end(); ++itr) { // get the player Player* player = ObjectAccessor::FindPlayer(itr->first); // if offline, skip him, this should not happen - player is removed from queue when he logs out if (!player) continue; // invite the player PlayerInvitedToBGUpdateAverageWaitTime(ginfo, bracket_id); //sBattlegroundMgr->InvitePlayer(player, bg, ginfo->Team); // set invited player counters bg->IncreaseInvitedCount(ginfo->team); player->SetInviteForBattlegroundQueueType(bgQueueTypeId, ginfo->isInvitedToBGInstanceGUID); // create remind invite events BGQueueInviteEvent* inviteEvent = new BGQueueInviteEvent(player->GetGUID(), ginfo->isInvitedToBGInstanceGUID, bgTypeId, ginfo->ratedType, ginfo->removeInviteTime); m_events.AddEvent(inviteEvent, m_events.CalculateTime(INVITATION_REMIND_TIME)); // create automatic remove events BGQueueRemoveEvent* removeEvent = new BGQueueRemoveEvent(player->GetGUID(), ginfo->isInvitedToBGInstanceGUID, bgTypeId, bgQueueTypeId, ginfo->removeInviteTime); m_events.AddEvent(removeEvent, m_events.CalculateTime(INVITE_ACCEPT_WAIT_TIME)); WorldPacket data; uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId); TC_LOG_DEBUG("bg.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 sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, player, queueSlot, STATUS_WAIT_JOIN, INVITE_ACCEPT_WAIT_TIME, player->GetBattlegroundQueueJoinTime(bgTypeId), ginfo->ratedType); player->GetSession()->SendPacket(&data); } return true; } return false; }
bool BattleGroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, BattleGround* bg, Team side) { // set side if needed if (side) ginfo->GroupTeam = side; if (!ginfo->IsInvitedToBGInstanceGUID) { // not yet invited // set invitation ginfo->IsInvitedToBGInstanceGUID = bg->GetInstanceID(); BattleGroundTypeId bgTypeId = bg->GetTypeID(); BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(bgTypeId, bg->GetArenaType()); BattleGroundBracketId bracket_id = bg->GetBracketId(); // set ArenaTeamId for rated matches if (bg->isArena() && bg->isRated()) bg->SetArenaTeamIdForTeam(ginfo->GroupTeam, ginfo->ArenaTeamId); ginfo->RemoveInviteTime = WorldTimer::getMSTime() + INVITE_ACCEPT_WAIT_TIME; // loop through the players for (GroupQueueInfoPlayers::iterator itr = ginfo->Players.begin(); itr != ginfo->Players.end(); ++itr) { // get the player Player* plr = sObjectMgr.GetPlayer(itr->first); // if offline, skip him, this should not happen - player is removed from queue when he logs out if (!plr) continue; // invite the player PlayerInvitedToBGUpdateAverageWaitTime(ginfo, bracket_id); // sBattleGroundMgr.InvitePlayer(plr, bg, ginfo->Team); // set invited player counters bg->IncreaseInvitedCount(ginfo->GroupTeam); plr->SetInviteForBattleGroundQueueType(bgQueueTypeId, ginfo->IsInvitedToBGInstanceGUID); // create remind invite events BGQueueInviteEvent* inviteEvent = new BGQueueInviteEvent(plr->GetObjectGuid(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, ginfo->arenaType, ginfo->RemoveInviteTime); plr->m_Events.AddEvent(inviteEvent, plr->m_Events.CalculateTime(INVITATION_REMIND_TIME)); // create automatic remove events BGQueueRemoveEvent* removeEvent = new BGQueueRemoveEvent(plr->GetObjectGuid(), ginfo->IsInvitedToBGInstanceGUID, bgTypeId, bgQueueTypeId, ginfo->RemoveInviteTime); plr->m_Events.AddEvent(removeEvent, plr->m_Events.CalculateTime(INVITE_ACCEPT_WAIT_TIME)); WorldPacket data; uint32 queueSlot = plr->GetBattleGroundQueueIndex(bgQueueTypeId); 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(), bg->GetInstanceID(), queueSlot, bg->GetTypeID()); // send status packet sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_JOIN, INVITE_ACCEPT_WAIT_TIME, 0, ginfo->arenaType, TEAM_NONE); plr->GetSession()->SendPacket(&data); } return true; } return false; }