本文整理汇总了C++中Battleground类的典型用法代码示例。如果您正苦于以下问题:C++ Battleground类的具体用法?C++ Battleground怎么用?C++ Battleground使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Battleground类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnGossipSelect
bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
{
player->PlayerTalkClass->ClearMenus();
uint8 mode = ARENA_TYPE_2v2;
if (action == (GOSSIP_ACTION_INFO_DEF + 3)) // 3v3
mode = ARENA_TYPE_3v3;
if (action == (GOSSIP_ACTION_INFO_DEF + 5)) // 5v5
mode = ARENA_TYPE_5v5;
if (action <= GOSSIP_OFFSET)
{
BattlegroundSet arenasSet = sBattlegroundMgr->GetAllBattlegroundsWithTypeId(BATTLEGROUND_AA);
// Check for matches of chosen type
bool bracketMatchs = false;
for (BattlegroundSet::const_iterator itr = arenasSet.begin(); itr != arenasSet.end(); ++itr)
{
if (Battleground* bg = itr->second)
{
if (bg->GetArenaType() == mode)
{
bracketMatchs = true;
break;
}
}
}
if (!bracketMatchs)
{
std::stringstream errMsg;
errMsg << "Sorry " << player->GetName() << ", There are no current matches of the type you selected.";
creature->MonsterWhisper(errMsg.str().c_str(), player->GetGUID());
player->PlayerTalkClass->ClearMenus();
player->CLOSE_GOSSIP_MENU();
}
else
{
// team 1 and 2!
for (BattlegroundSet::const_iterator itr = arenasSet.begin(); itr != arenasSet.end(); ++itr)
{
if (Battleground* bg = itr->second)
{
ArenaTeam* teamOne = sArenaTeamMgr->GetArenaTeamById(bg->GetArenaTeamIdByIndex(0));
ArenaTeam* teamTwo = sArenaTeamMgr->GetArenaTeamById(bg->GetArenaTeamIdByIndex(1));
if (teamOne && teamTwo)
{
std::stringstream gossipItem;
gossipItem << teamOne->GetName() << " (";
gossipItem << teamOne->GetRating() << ") VS ";
gossipItem << teamTwo->GetName() << " (";
gossipItem << teamTwo->GetRating() << ")";
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, gossipItem.str(), GOSSIP_SENDER_MAIN + 1, itr->first + GOSSIP_OFFSET);
}
}
}
player->PlayerTalkClass->SendGossipMenu(player->GetGossipTextId(creature), creature->GetGUID());
}
}
else
{
uint32 arenaId = action - GOSSIP_OFFSET;
// Don't really bother about WPE injection here, we are allowing pretty much any arena selection
BattlegroundSet arenasSet = sBattlegroundMgr->GetAllBattlegroundsWithTypeId(BATTLEGROUND_AA);
if (arenasSet[arenaId] != NULL)
{
Battleground* arenaChosen = arenasSet[arenaId];
// spectator crap
if (arenaChosen->GetStatus() != STATUS_NONE && arenaChosen->GetStatus() != STATUS_IN_PROGRESS)
{
std::stringstream errMsg;
errMsg << "Sorry " << player->GetName() << ", the chosen arena has ended";
creature->MonsterWhisper(errMsg.str().c_str(), player->GetGUID());
player->PlayerTalkClass->ClearMenus();
player->CLOSE_GOSSIP_MENU();
return false;
}
// OK. In the case of a selected arena, we teleport in the center of the arena.
player->SetBattlegroundId(arenaChosen->GetInstanceID(), arenaChosen->GetTypeID());
player->SetBattlegroundEntryPoint();
float x, y, z;
switch (arenaChosen->GetMapId())
{
case 617:
x = 1299.046f;
y = 784.825f;
z = 9.338f;
break; // Dalaran Sewers
case 618:
x = 763.5f;
y = -284;
z = 28.276f;
break; // Ring of Valor
case 572:
x = 1285.810547f;
y = 1667.896851f;
//.........这里部分代码省略.........
示例2: id
void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recvData)
{
ObjectGuid guid;
uint32 bgTypeId_;
uint32 instanceId;
uint8 joinAsGroup;
bool isPremade = false;
Group* grp = NULL;
recvData >> guid; // battlemaster guid
recvData >> bgTypeId_; // battleground type id (DBC id)
recvData >> instanceId; // instance id, 0 if First Available selected
recvData >> joinAsGroup; // join as group
if (!sBattlemasterListStore.LookupEntry(bgTypeId_))
{
TC_LOG_ERROR("network", "Battleground: invalid bgtype (%u) received. possible cheater? player guid %u", bgTypeId_, _player->GetGUIDLow());
return;
}
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeId_, NULL))
{
ChatHandler(this).PSendSysMessage(LANG_BG_DISABLED);
return;
}
BattlegroundTypeId bgTypeId = BattlegroundTypeId(bgTypeId_);
TC_LOG_DEBUG("network", "WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from %s", guid.ToString().c_str());
// can do this, since it's battleground, not arena
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, 0);
BattlegroundQueueTypeId bgQueueTypeIdRandom = BattlegroundMgr::BGQueueTypeId(BATTLEGROUND_RB, 0);
// ignore if player is already in BG
if (_player->InBattleground())
return;
// get bg instance or bg template if instance not found
Battleground* bg = NULL;
if (instanceId)
bg = sBattlegroundMgr->GetBattlegroundThroughClientInstance(instanceId, bgTypeId);
if (!bg)
bg = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
if (!bg)
return;
// expected bracket entry
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
if (!bracketEntry)
return;
GroupJoinBattlegroundResult err;
// check queue conditions
if (!joinAsGroup)
{
if (GetPlayer()->isUsingLfg())
{
// player is using dungeon finder or raid finder
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_LFG_CANT_USE_BATTLEGROUND);
GetPlayer()->GetSession()->SendPacket(&data);
return;
}
// check Deserter debuff
if (!_player->CanJoinToBattleground(bg))
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS);
_player->GetSession()->SendPacket(&data);
return;
}
if (_player->GetBattlegroundQueueIndex(bgQueueTypeIdRandom) < PLAYER_MAX_BATTLEGROUND_QUEUES)
{
// player is already in random queue
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_IN_RANDOM_BG);
_player->GetSession()->SendPacket(&data);
return;
}
if (_player->InBattlegroundQueue() && bgTypeId == BATTLEGROUND_RB)
{
// player is already in queue, can't start random queue
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_IN_NON_RANDOM_BG);
_player->GetSession()->SendPacket(&data);
return;
}
// check if already in queue
if (_player->GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
// player is already in this queue
return;
// check if has free queue slots
//.........这里部分代码省略.........
示例3: OnCheck
bool OnCheck(Player* source, Unit* /*target*/)
{
Battleground* bg = source->GetBattleground();
return bg && bg->GetBgTypeID() == BATTLEGROUND_AV && bg->ToBattlegroundAV()->IsAllTowersControlledAndCaptainAlive(source->GetTeamId());
}
示例4: while
/*
this method is called when group is inserted, or player / group is removed from BG Queue - there is only one player's status changed, so we don't use while (true) cycles to invite whole queue
it must be called after fully adding the members of a group to ensure group joining
should be called from Battleground::RemovePlayer function in some cases
*/
void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id, uint8 arenaType, bool isRated, uint32 arenaRating)
{
//if no players in queue - do nothing
if (m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].empty() &&
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].empty() &&
m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].empty() &&
m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].empty())
return;
// battleground with free slot for player should be always in the beggining of the queue
// maybe it would be better to create bgfreeslotqueue for each bracket_id
BGFreeSlotQueueContainer& bgQueues = sBattlegroundMgr->GetBGFreeSlotQueueStore(bgTypeId);
for (BGFreeSlotQueueContainer::iterator itr = bgQueues.begin(); itr != bgQueues.end();)
{
Battleground* bg = *itr; ++itr;
// DO NOT allow queue manager to invite new player to rated games
if (!bg->isRated() && bg->GetTypeID() == bgTypeId && bg->GetBracketId() == bracket_id &&
bg->GetStatus() > STATUS_WAIT_QUEUE && bg->GetStatus() < STATUS_WAIT_LEAVE)
{
// clear selection pools
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[TEAM_ALLIANCE].SelectedGroups.begin(); citr != m_SelectionPools[TEAM_ALLIANCE].SelectedGroups.end(); ++citr)
InviteGroupToBG((*citr), bg, (*citr)->Team);
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())
bg->RemoveFromBGFreeSlotQueue();
}
}
// finished iterating through the bgs with free slots, maybe we need to create a new bg
Battleground* bg_template = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
if (!bg_template)
{
TC_LOG_ERROR("bg.battleground", "Battleground: Update: bg template not found for %u", bgTypeId);
return;
}
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketById(bg_template->GetMapId(), bracket_id);
if (!bracketEntry)
{
TC_LOG_ERROR("bg.battleground", "Battleground: Update: bg bracket entry not found for map %u bracket id %u", bg_template->GetMapId(), bracket_id);
return;
}
// get the min. players per team, properly for larger arenas as well. (must have full teams for arena matches!)
uint32 MinPlayersPerTeam = bg_template->GetMinPlayersPerTeam();
uint32 MaxPlayersPerTeam = bg_template->GetMaxPlayersPerTeam();
if (bg_template->isArena())
{
MaxPlayersPerTeam = arenaType;
MinPlayersPerTeam = sBattlegroundMgr->isArenaTesting() ? 1 : arenaType;
}
else if (sBattlegroundMgr->isTesting())
MinPlayersPerTeam = 1;
m_SelectionPools[TEAM_ALLIANCE].Init();
m_SelectionPools[TEAM_HORDE].Init();
if (bg_template->isBattleground())
{
if (CheckPremadeMatch(bracket_id, MinPlayersPerTeam, MaxPlayersPerTeam))
{
// create new battleground
Battleground* bg2 = sBattlegroundMgr->CreateNewBattleground(bgTypeId, bracketEntry, 0, false);
if (!bg2)
{
TC_LOG_ERROR("bg.battleground", "BattlegroundQueue::Update - Cannot create battleground: %u", bgTypeId);
return;
}
// invite those selection pools
for (uint32 i = 0; i < BG_TEAMS_COUNT; i++)
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);
bg2->StartBattleground();
//clear structures
m_SelectionPools[TEAM_ALLIANCE].Init();
m_SelectionPools[TEAM_HORDE].Init();
}
}
// now check if there are in queues enough players to start new game of (normal battleground, or non-rated arena)
if (!isRated)
{
//.........这里部分代码省略.........
示例5: TC_LOG_DEBUG
void WorldSession::HandleBattlefieldStatusOpcode(WorldPacket & /*recvData*/)
{
// empty opcode
TC_LOG_DEBUG("network", "WORLD: Battleground status");
WorldPacket data;
// we must update all queues here
Battleground* bg = NULL;
for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
{
BattlegroundQueueTypeId bgQueueTypeId = _player->GetBattlegroundQueueTypeId(i);
if (!bgQueueTypeId)
continue;
BattlegroundTypeId bgTypeId = BattlegroundMgr::BGTemplateId(bgQueueTypeId);
uint8 arenaType = BattlegroundMgr::BGArenaType(bgQueueTypeId);
if (bgTypeId == _player->GetBattlegroundTypeId())
{
bg = _player->GetBattleground();
//i cannot check any variable from player class because player class doesn't know if player is in 2v2 / 3v3 or 5v5 arena
//so i must use bg pointer to get that information
if (bg && bg->GetArenaType() == arenaType)
{
// this line is checked, i only don't know if GetStartTime is changing itself after bg end!
// send status in Battleground
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, i, STATUS_IN_PROGRESS, bg->GetEndTime(), bg->GetStartTime(), arenaType, _player->GetBGTeam());
SendPacket(&data);
continue;
}
}
//we are sending update to player about queue - he can be invited there!
//get GroupQueueInfo for queue status
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
GroupQueueInfo ginfo;
if (!bgQueue.GetPlayerGroupInfoData(_player->GetGUID(), &ginfo))
continue;
if (ginfo.IsInvitedToBGInstanceGUID)
{
bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
if (!bg)
continue;
uint32 remainingTime = getMSTimeDiff(getMSTime(), ginfo.RemoveInviteTime);
// send status invited to Battleground
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, i, STATUS_WAIT_JOIN, remainingTime, 0, arenaType, 0);
SendPacket(&data);
}
else
{
bg = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
if (!bg)
continue;
// expected bracket entry
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
if (!bracketEntry)
continue;
uint32 avgTime = bgQueue.GetAverageQueueWaitTime(&ginfo, bracketEntry->GetBracketId());
// send status in Battleground Queue
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, i, STATUS_WAIT_QUEUE, avgTime, getMSTimeDiff(ginfo.JoinTime, getMSTime()), arenaType, 0);
SendPacket(&data);
}
}
}
示例6: Reward
void Reward(Player* player, uint8 killed, uint8 killedType)
{
if (!MultiKillEnable)
return;
for (uint16 i = 0; i < MultiKillInfo.size(); ++i)
{
if (MultiKillInfo[i].Count == killed && MultiKillInfo[i].Type == killedType)
{
Battleground* bg = NULL;
if (player->InBattleground())
bg = player->GetBattleground();
if (MultiKillInfo[i].BuffFirst != 0)
player->CastSpell(player, MultiKillInfo[i].BuffFirst, true);
if (MultiKillInfo[i].BuffSecond != 0)
player->CastSpell(player, MultiKillInfo[i].BuffSecond, true);
if (MultiKillInfo[i].Gold != 0)
player->ModifyMoney(MultiKillInfo[i].Gold * GOLD);
if (MultiKillInfo[i].Sound != 0)
{
if (bg)
bg->PlaySoundToAll(MultiKillInfo[i].Sound);
else
{
WorldPacket data(SMSG_PLAY_SOUND, 4);
data << uint32(MultiKillInfo[i].Sound) << player->GetGUIDLow();
sWorld->SendGlobalMessage(&data);
}
}
// Reward Honor
if (MultiKillInfo[i].Honor != 0)
player->RewardHonor(NULL, 1, MultiKillInfo[i].Honor);
// TrinityStringId
if (MultiKillInfo[i].Text != 0)
{
if (bg)
bg->SendWarningToAll(MultiKillInfo[i].Text, player->GetName());
else
sWorld->SendWorldText(MultiKillInfo[i].Text, player->GetName());
}
// KillCredit for quests/achi.
if (MultiKillInfo[i].KillCredit != 0)
player->KilledMonsterCredit(MultiKillInfo[i].KillCredit, 0);
if (!MultiKillLog)
return;
CharacterDatabase.PExecute(
"INSERT INTO `character_multikill` (`guid`, `count`, `type`, `time`) VALUES ('%u', '%u', '%u', CURRENT_TIMESTAMP())",
player->GetGUIDLow(), killed, killedType
);
return;
}
}
}
示例7: player
void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_BATTLEFIELD_PORT Message");
uint32 time;
uint32 queueSlot;
uint32 unk;
uint8 action; // enter battle 0x1, leave queue 0x0
ObjectGuid guid;
recvData >> time;
recvData >> queueSlot;
recvData >> unk;
guid[0] = recvData.ReadBit();
guid[1] = recvData.ReadBit();
guid[5] = recvData.ReadBit();
guid[6] = recvData.ReadBit();
guid[7] = recvData.ReadBit();
guid[4] = recvData.ReadBit();
guid[3] = recvData.ReadBit();
guid[2] = recvData.ReadBit();
action = recvData.ReadBit();
recvData.ReadByteSeq(guid[1]);
recvData.ReadByteSeq(guid[3]);
recvData.ReadByteSeq(guid[5]);
recvData.ReadByteSeq(guid[7]);
recvData.ReadByteSeq(guid[0]);
recvData.ReadByteSeq(guid[2]);
recvData.ReadByteSeq(guid[6]);
recvData.ReadByteSeq(guid[4]);
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(), _player->GetGUIDLow());
return;
}
BattlegroundQueueTypeId bgQueueTypeId = _player->GetBattlegroundQueueTypeId(queueSlot);
if (bgQueueTypeId == BATTLEGROUND_QUEUE_NONE)
{
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "BattlegroundHandler: invalid queueSlot (%u) received.", queueSlot);
return;
}
BattlegroundTypeId bgTypeId = BattlegroundMgr::BGTemplateId(bgQueueTypeId);
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
//we must use temporary variable, because GroupQueueInfo pointer can be deleted in BattlegroundQueue::RemovePlayer() function
GroupQueueInfo ginfo;
if (!bgQueue.GetPlayerGroupInfoData(_player->GetGUID(), &ginfo))
{
sLog->outError(LOG_FILTER_NETWORKIO, "BattlegroundHandler: itrplayerstatus not found.");
return;
}
// if action == 1, then instanceId is required
if (!ginfo.IsInvitedToBGInstanceGUID && action == 1)
{
sLog->outError(LOG_FILTER_NETWORKIO, "BattlegroundHandler: instance not found.");
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;
}
// expected bracket entry
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
if (!bracketEntry)
return;
//some checks if player isn't cheating - it is not exactly cheating, but we cannot allow it
if (action == 1 && ginfo.ArenaType == 0)
{
//if player is trying to enter battleground (not arena!) and he has deserter debuff, we must just remove him from queue
if (!_player->CanJoinToBattleground())
{
//send bg command result to show nice message
WorldPacket data2;
sBattlegroundMgr->BuildStatusFailedPacket(&data2, bg, _player, 0, 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(), _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!",
_player->GetName(), _player->GetGUIDLow(), _player->getLevel(), bg->GetMaxLevel(), bg->GetTypeID());
action = 0;
}
//.........这里部分代码省略.........
示例8: bg
bool ChallengeMgr::InviteGroupsToArena(Player *leader1, Player *leader2, ArenaChallengeType type)
{
uint8 arenatype = (type == ARENA_CHALLENGE_TYPE_1v1) ? ARENA_CHALLENGE_TYPE_2v2 : type;
uint32 matchmakerRating = 0;
//check existance
Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(BATTLEGROUND_AA);
if (!bg)
{
sLog->outError("Battleground: template bg (all arenas) not found");
return false;
}
BattlegroundTypeId bgTypeId = bg->GetTypeID();
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, arenatype);
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), 80);
if (!bracketEntry)
return false;
GroupQueueInfo *group1, *group2;
if (type == ARENA_CHALLENGE_TYPE_1v1)
{
group1 = CreateGroupQueueInfo(leader1, bgTypeId, arenatype);
group2 = CreateGroupQueueInfo(leader2, bgTypeId, arenatype);
}
else
{
group1 = CreateGroupQueueInfo(leader1->GetGroup(), bgTypeId, arenatype);
group2 = CreateGroupQueueInfo(leader2->GetGroup(), bgTypeId, arenatype);
}
if (!group1 || !group2)
return false;
for (std::map<uint64, PlayerQueueInfo*>::iterator itr = group1->Players.begin(); itr != group1->Players.end(); ++itr)
{
Player *player = ObjectAccessor::FindPlayer(itr->first);
if (!player)
return false;
if (!CanInvitePlayer(player, bgQueueTypeId))
return false;
}
for (std::map<uint64, PlayerQueueInfo*>::iterator itr = group2->Players.begin(); itr != group2->Players.end(); ++itr)
{
Player *player = ObjectAccessor::FindPlayer(itr->first);
if (!player)
return false;
if (!CanInvitePlayer(player, bgQueueTypeId))
return false;
}
sBattlegroundMgr->ScheduleQueueUpdate(matchmakerRating, arenatype, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
Battleground *arena = sBattlegroundMgr->CreateNewBattleground(bgTypeId, bracketEntry, arenatype, true);
arena->SetRated(false);
if (type == ARENA_CHALLENGE_TYPE_1v1)
arena->Set1vs1(true);
for (std::map<uint64, PlayerQueueInfo*>::iterator itr = group1->Players.begin(); itr != group1->Players.end(); ++itr)
{
Player *player = ObjectAccessor::FindPlayer(itr->first);
if (!player)
return false;
uint32 queueSlot = player->AddBattlegroundQueueId(bgQueueTypeId);
WorldPacket data;
// send status packet (in queue)
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, 0, 0, arenatype);
player->GetSession()->SendPacket(&data);
player->challengeData->bg = arena;
player->challengeData->ginfo = CreateGroupQueueInfo(player, bgTypeId, arenatype);
player->challengeData->ginfo->IsInvitedToBGInstanceGUID = arena->GetInstanceID();
player->challengeData->ginfo->Team = ALLIANCE;
}
for (std::map<uint64, PlayerQueueInfo*>::iterator itr = group2->Players.begin(); itr != group2->Players.end(); ++itr)
{
Player *player = ObjectAccessor::FindPlayer(itr->first);
if (!player)
return false;
uint32 queueSlot = player->AddBattlegroundQueueId(bgQueueTypeId);
WorldPacket data;
// send status packet (in queue)
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, 0, 0, arenatype);
player->GetSession()->SendPacket(&data);
player->challengeData->bg = arena;
player->challengeData->ginfo = CreateGroupQueueInfo(player, bgTypeId, arenatype);
player->challengeData->ginfo->IsInvitedToBGInstanceGUID = arena->GetInstanceID();
player->challengeData->ginfo->Team = HORDE;
}
//.........这里部分代码省略.........
示例9: bgtype
void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recv_data)
{
uint32 bgTypeId_ = 0; // fix this
uint8 joinFlags;
bool isPremade = false;
Group* grp = NULL;
// Packet size is 8 bytes, lots of unknown data
recv_data >> joinFlags; // join flags
recv_data.read_skip<uint8>(); // unk
recv_data.read_skip<uint32>(); // BG id? somewhy is always 0
recv_data.read_skip<uint8>(); // unk
recv_data.read_skip<uint8>(); // unk
bool joinAsGroup = (joinFlags & 0x01); // Make flags enum?
if (!sBattlemasterListStore.LookupEntry(bgTypeId_))
{
sLog->outError("Battleground: invalid bgtype (%u) received. possible cheater? player guid %u", bgTypeId_, _player->GetGUIDLow());
return;
}
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeId_, NULL))
{
ChatHandler(this).PSendSysMessage(LANG_BG_DISABLED);
return;
}
BattlegroundTypeId bgTypeId = BattlegroundTypeId(bgTypeId_);
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd CMSG_BATTLEMASTER_JOIN Message from");
// can do this, since it's battleground, not arena
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, 0);
BattlegroundQueueTypeId bgQueueTypeIdRandom = BattlegroundMgr::BGQueueTypeId(BATTLEGROUND_RB, 0);
// ignore if player is already in BG
if (_player->InBattleground())
return;
// As of 4.x BG instances are not selectable
Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
if (!bg)
return;
// expected bracket entry
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
if (!bracketEntry)
return;
GroupJoinBattlegroundResult err;
// check queue conditions
if (!joinAsGroup)
{
if (GetPlayer()->isUsingLfg())
{
// player is using dungeon finder or raid finder
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_LFG_CANT_USE_BATTLEGROUND);
GetPlayer()->GetSession()->SendPacket(&data);
return;
}
// check Deserter debuff
if (!_player->CanJoinToBattleground())
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS);
_player->GetSession()->SendPacket(&data);
return;
}
if (_player->GetBattlegroundQueueIndex(bgQueueTypeIdRandom) < PLAYER_MAX_BATTLEGROUND_QUEUES)
{
//player is already in random queue
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_IN_RANDOM_BG);
_player->GetSession()->SendPacket(&data);
return;
}
if (_player->InBattlegroundQueue() && bgTypeId == BATTLEGROUND_RB)
{
//player is already in queue, can't start random queue
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_IN_NON_RANDOM_BG);
_player->GetSession()->SendPacket(&data);
return;
}
// check if already in queue
if (_player->GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
//player is already in this queue
return;
// check if has free queue slots
if (!_player->HasFreeBattlegroundQueueId())
{
//.........这里部分代码省略.........
示例10: HandleSpectateCommand
static bool HandleSpectateCommand(ChatHandler* handler, char const* args)
{
Player* target;
ObjectGuid target_guid;
std::string target_name;
if (!handler->extractPlayerTarget((char*)args, &target, &target_guid, &target_name))
return false;
Player* player = handler->GetSession()->GetPlayer();
if (target == player || target_guid == player->GetGUID())
{
handler->PSendSysMessage("You can't spectate yourself.");
handler->SetSentErrorMessage(true);
return false;
}
if (player->IsInCombat())
{
handler->PSendSysMessage("You are in combat.");
handler->SetSentErrorMessage(true);
return false;
}
if (!target)
{
handler->PSendSysMessage("Target is not online or does not exist.");
handler->SetSentErrorMessage(true);
return false;
}
if (player->GetPet())
{
handler->PSendSysMessage("You must hide your pet.");
handler->SetSentErrorMessage(true);
return false;
}
if (player->GetMap()->IsBattlegroundOrArena() && !player->IsSpectator())
{
handler->PSendSysMessage("You are already in a battleground or arena.");
handler->SetSentErrorMessage(true);
return false;
}
Map* cMap = target->GetMap();
if (!cMap->IsBattleArena())
{
handler->PSendSysMessage("Player is not in an Arena match.");
handler->SetSentErrorMessage(true);
return false;
}
if (player->GetMap()->IsBattleground())
{
handler->PSendSysMessage("You can't do that while in a battleground.");
handler->SetSentErrorMessage(true);
return false;
}
if (target->HasAura(32728) || target->HasAura(32727))
{
handler->PSendSysMessage("You can't do that. The Arena match didn't start yet.");
handler->SetSentErrorMessage(true);
return false;
}
if (target->IsSpectator())
{
handler->PSendSysMessage("You can't do that. Your target is a spectator.");
handler->SetSentErrorMessage(true);
return false;
}
if (player->IsMounted())
{
handler->PSendSysMessage("Cannot Spectate while mounted.");
handler->SetSentErrorMessage(true);
return false;
}
// all's well, set bg id
// when porting out from the bg, it will be reset to 0
player->SetBattlegroundId(target->GetBattlegroundId(), target->GetBattlegroundTypeId());
// remember current position as entry point for return at bg end teleportation
if (!player->GetMap()->IsBattlegroundOrArena())
player->SetBattlegroundEntryPoint();
// stop flight if need
if (player->IsInFlight())
{
player->GetMotionMaster()->MovementExpired();
player->CleanupAfterTaxiFlight();
}
// save only in non-flight case
else
player->SaveRecallPosition();
// search for two teams
Battleground *bGround = target->GetBattleground();
if (bGround->isRated())
//.........这里部分代码省略.........
示例11: ShowPage
void ShowPage(Player* player, uint16 page, uint32 IsTop)
{
uint32 firstTeamId = 0;
uint16 TypeOne = 0;
uint16 TypeTwo = 0;
uint16 TypeThree = 0;
uint16 mmr = 0;
uint16 mmrTwo = 0;
bool haveNextPage = false;
for (uint8 i = 0; i <= MAX_BATTLEGROUND_TYPE_ID; ++i)
{
if (!sBattlegroundMgr->IsArenaType(BattlegroundTypeId(i)))
continue;
//BattlegroundContainer arenas = sBattlegroundMgr->GetBattlegroundsByType((BattlegroundTypeId)i);
BattlegroundData* arenas = sBattlegroundMgr->GetAllBattlegroundsWithTypeId(BattlegroundTypeId(i));
if (!arenas || arenas->m_Battlegrounds.empty())
continue;
for (BattlegroundContainer::const_iterator itr = arenas->m_Battlegrounds.begin(); itr != arenas->m_Battlegrounds.end(); ++itr)
{
Battleground* arena = itr->second;
Player* target = ObjectAccessor::FindPlayer(GetFirstPlayerGuid(arena));
if (target && (target->HasAura(32728) || target->HasAura(32727)))
continue;
if (!arena->GetPlayersSize())
continue;
if (arena->GetArenaType() == ARENA_TYPE_2v2)
{
mmr = arena->GetArenaMatchmakerRating(0);
firstTeamId = target->GetArenaTeamId(0);
Battleground::BattlegroundPlayerMap::const_iterator citr = arena->GetPlayers().begin();
for (; citr != arena->GetPlayers().end(); ++citr)
if (Player* plrs = ObjectAccessor::FindPlayer(citr->first))
if (plrs->GetArenaTeamId(0) != firstTeamId)
mmrTwo = arena->GetArenaMatchmakerRating(citr->second.Team);
}
else if (arena->GetArenaType() == ARENA_TYPE_3v3)
{
mmr = arena->GetArenaMatchmakerRating(1);
firstTeamId = target->GetArenaTeamId(1);
Battleground::BattlegroundPlayerMap::const_iterator citr = arena->GetPlayers().begin();
for (; citr != arena->GetPlayers().end(); ++citr)
if (Player* plrs = ObjectAccessor::FindPlayer(citr->first))
if (plrs->GetArenaTeamId(1) != firstTeamId)
mmrTwo = arena->GetArenaMatchmakerRating(citr->second.Team);
}
else if (arena->GetArenaType() == ARENA_TYPE_5v5)
{
mmr = arena->GetArenaMatchmakerRating(2);
firstTeamId = target->GetArenaTeamId(2);
Battleground::BattlegroundPlayerMap::const_iterator citr = arena->GetPlayers().begin();
for (; citr != arena->GetPlayers().end(); ++citr)
if (Player* plrs = ObjectAccessor::FindPlayer(citr->first))
if (plrs->GetArenaTeamId(2) != firstTeamId)
mmrTwo = arena->GetArenaMatchmakerRating(citr->second.Team);
}
if (IsTop == 1 && arena->GetArenaType() == ARENA_TYPE_2v2)
{
TypeOne++;
if (TypeOne > (page + 1) * GamesOnPage)
{
haveNextPage = true;
break;
}
if (TypeOne >= page * GamesOnPage)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, GetGamesStringData(arena, mmr, mmrTwo), GOSSIP_SENDER_MAIN, NPC_SPECTATOR_ACTION_SELECTED_PLAYER + GetFirstPlayerGuid(arena));
}
else if (IsTop == 2 && arena->GetArenaType() == ARENA_TYPE_3v3)
{
TypeTwo++;
if (TypeTwo > (page + 1) * GamesOnPage)
{
haveNextPage = true;
break;
}
if (TypeTwo >= page * GamesOnPage)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, GetGamesStringData(arena, mmr, mmrTwo), GOSSIP_SENDER_MAIN, NPC_SPECTATOR_ACTION_SELECTED_PLAYER + GetFirstPlayerGuid(arena));
}
else if (IsTop == 3 && arena->GetArenaType() == ARENA_TYPE_5v5)
{
TypeThree++;
if (TypeThree > (page + 1) * GamesOnPage)
{
haveNextPage = true;
break;
}
if (TypeThree >= page * GamesOnPage)
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, GetGamesStringData(arena, mmr, mmrTwo), GOSSIP_SENDER_MAIN, NPC_SPECTATOR_ACTION_SELECTED_PLAYER + GetFirstPlayerGuid(arena));
}
}
}
//.........这里部分代码省略.........
示例12: id
void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recvData)
{
uint64 guid;
uint32 bgTypeId_;
uint32 instanceId; // sent to queue for particular bg from battlemaster's list, currently not used
uint8 joinAsGroup;
recvData >> guid; // battlemaster guid
recvData >> bgTypeId_; // battleground type id (DBC id)
recvData >> instanceId; // instance id, 0 if First Available selected
recvData >> joinAsGroup; // join as group
// entry not found
if (!sBattlemasterListStore.LookupEntry(bgTypeId_))
return;
// chosen battleground type is disabled
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeId_, NULL))
{
ChatHandler(this).PSendSysMessage(LANG_BG_DISABLED);
return;
}
// get queue typeid and random typeid to check if already queued for them
BattlegroundTypeId bgTypeId = BattlegroundTypeId(bgTypeId_);
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, 0);
BattlegroundQueueTypeId bgQueueTypeIdRandom = BattlegroundMgr::BGQueueTypeId(BATTLEGROUND_RB, 0);
// safety check - bgQueueTypeId == BATTLEGROUND_QUEUE_NONE if tried to queue for arena using this function
if (bgQueueTypeId == BATTLEGROUND_QUEUE_NONE)
return;
// get bg template
Battleground* bgt = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
if (!bgt)
return;
// expected bracket entry
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgt->GetMapId(), _player->getLevel());
if (!bracketEntry)
return;
// pussywizard: if trying to queue for already queued
// just remove from queue and it will requeue!
uint32 qSlot = _player->GetBattlegroundQueueIndex(bgQueueTypeId);
if (qSlot < PLAYER_MAX_BATTLEGROUND_QUEUES)
{
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
if (bgQueue.IsPlayerInvitedToRatedArena(_player->GetGUID()))
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_JOIN_FAILED);
SendPacket(&data);
return;
}
bgQueue.RemovePlayer(_player->GetGUID(), false, qSlot);
_player->RemoveBattlegroundQueueId(bgQueueTypeId);
}
// must have free queue slot
if (!_player->HasFreeBattlegroundQueueId())
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_TOO_MANY_QUEUES);
SendPacket(&data);
return;
}
// queue result (default ok)
GroupJoinBattlegroundResult err = GroupJoinBattlegroundResult(bgt->GetBgTypeID());
// check if player can queue:
if (!joinAsGroup)
{
if (GetPlayer()->InBattleground()) // currently in battleground
err = ERR_BATTLEGROUND_NOT_IN_BATTLEGROUND;
else if (GetPlayer()->isUsingLfg()) // using lfg system
err = ERR_LFG_CANT_USE_BATTLEGROUND;
else if (!_player->CanJoinToBattleground()) // has deserter debuff
err = ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS;
else if (_player->InBattlegroundQueueForBattlegroundQueueType(bgQueueTypeIdRandom)) // queued for random bg, so can't queue for anything else
err = ERR_IN_RANDOM_BG;
else if (_player->InBattlegroundQueue() && bgTypeId == BATTLEGROUND_RB) // already in queue, so can't queue for random
err = ERR_IN_NON_RANDOM_BG;
else if (_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_2v2) ||
_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_3v3) ||
_player->InBattlegroundQueueForBattlegroundQueueType(BATTLEGROUND_QUEUE_5v5)) // can't be already queued for arenas
err = ERR_BATTLEGROUND_QUEUED_FOR_RATED;
if (err <= 0)
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, err);
SendPacket(&data);
return;
}
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
//.........这里部分代码省略.........
示例13: GetPlayer
void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recvData)
{
uint64 guid; // arena Battlemaster guid
uint8 arenaslot; // 2v2, 3v3 or 5v5
uint8 asGroup; // asGroup
uint8 isRated; // isRated
recvData >> guid >> arenaslot >> asGroup >> isRated;
// can't queue for rated without a group
if (isRated && !asGroup)
return;
// find creature by guid
Creature* unit = GetPlayer()->GetMap()->GetCreature(guid);
if (!unit || !unit->IsBattleMaster())
return;
// get arena type
uint8 arenatype = 0;
switch (arenaslot)
{
case 0:
arenatype = ARENA_TYPE_2v2;
break;
case 1:
arenatype = ARENA_TYPE_3v3;
break;
case 2:
arenatype = ARENA_TYPE_5v5;
break;
default:
return;
}
// get template for all arenas
Battleground* bgt = sBattlegroundMgr->GetBattlegroundTemplate(BATTLEGROUND_AA);
if (!bgt)
return;
// arenas disabled
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, BATTLEGROUND_AA, NULL))
{
ChatHandler(this).PSendSysMessage(LANG_ARENA_DISABLED);
return;
}
BattlegroundTypeId bgTypeId = bgt->GetBgTypeID();
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, arenatype);
// expected bracket entry
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgt->GetMapId(), _player->getLevel());
if (!bracketEntry)
return;
// pussywizard: if trying to queue for already queued
// just remove from queue and it will requeue!
uint32 qSlot = _player->GetBattlegroundQueueIndex(bgQueueTypeId);
if (qSlot < PLAYER_MAX_BATTLEGROUND_QUEUES)
{
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
if (bgQueue.IsPlayerInvitedToRatedArena(_player->GetGUID()))
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_JOIN_FAILED);
SendPacket(&data);
return;
}
bgQueue.RemovePlayer(_player->GetGUID(), false, qSlot);
_player->RemoveBattlegroundQueueId(bgQueueTypeId);
}
// must have free queue slot
// pussywizard: allow being queued only in one arena queue, and it even cannot be together with bg queues
if (_player->InBattlegroundQueue())
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_BATTLEGROUND_CANNOT_QUEUE_FOR_RATED);
SendPacket(&data);
return;
}
// queue result (default ok)
GroupJoinBattlegroundResult err = GroupJoinBattlegroundResult(bgt->GetBgTypeID());
// check if player can queue:
if (!asGroup)
{
if (GetPlayer()->InBattleground()) // currently in battleground
err = ERR_BATTLEGROUND_NOT_IN_BATTLEGROUND;
else if (GetPlayer()->isUsingLfg()) // using lfg system
err = ERR_LFG_CANT_USE_BATTLEGROUND;
if (err <= 0)
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, err);
SendPacket(&data);
//.........这里部分代码省略.........
示例14: BattlegroundTypeId
void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recvData)
{
uint8 arenaType; // arenatype if arena
uint8 unk2; // unk, can be 0x0 (may be if was invited?) and 0x1
uint32 bgTypeId_; // type id from dbc
uint16 unk; // 0x1F90 constant?
uint8 action; // enter battle 0x1, leave queue 0x0
recvData >> arenaType >> unk2 >> bgTypeId_ >> unk >> action;
// bgTypeId not valid
if (!sBattlemasterListStore.LookupEntry(bgTypeId_))
return;
// player not in any queue, so can't really answer
if (!_player->InBattlegroundQueue())
return;
// get BattlegroundQueue for received
BattlegroundTypeId bgTypeId = BattlegroundTypeId(bgTypeId_);
BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, arenaType);
BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
// get group info from queue
GroupQueueInfo ginfo;
if (!bgQueue.GetPlayerGroupInfoData(_player->GetGUID(), &ginfo))
return;
// to accept, player must be invited to particular battleground id
if (!ginfo.IsInvitedToBGInstanceGUID && action == 1)
return;
Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID);
// use template if leaving queue (instance might not be created yet)
if (!bg && action == 0)
bg = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
if (!bg)
return;
// expected bracket entry
PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
if (!bracketEntry)
return;
// safety checks
if (action == 1 && ginfo.ArenaType == 0)
{
// can't join with deserter, check it here right before joining to be sure
if (!_player->CanJoinToBattleground())
{
WorldPacket data;
sBattlegroundMgr->BuildGroupJoinedBattlegroundPacket(&data, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS);
SendPacket(&data);
action = 0;
}
if (_player->getLevel() > bg->GetMaxLevel())
action = 0;
}
// get player queue slot index for this bg (can be in up to 2 queues at the same time)
uint32 queueSlot = _player->GetBattlegroundQueueIndex(bgQueueTypeId);
WorldPacket data;
switch (action)
{
case 1: // accept
{
// set entry point if not in battleground
if (!_player->InBattleground())
_player->SetEntryPoint();
// resurrect the player
if (!_player->IsAlive())
{
_player->ResurrectPlayer(1.0f);
_player->SpawnCorpseBones();
}
// remove player from all bg queues
for (uint32 qslot = 0; qslot < PLAYER_MAX_BATTLEGROUND_QUEUES; ++qslot)
if (BattlegroundQueueTypeId q = _player->GetBattlegroundQueueTypeId(qslot))
{
BattlegroundQueue& queue = sBattlegroundMgr->GetBattlegroundQueue(q);
queue.RemovePlayer(_player->GetGUID(), (bgQueueTypeId == q), qslot);
_player->RemoveBattlegroundQueueId(q);
}
// send status packet
sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, bg, queueSlot, STATUS_IN_PROGRESS, 0, bg->GetStartTime(), bg->GetArenaType(), ginfo.teamId);
SendPacket(&data);
_player->SetBattlegroundId(bg->GetInstanceID(), bg->GetBgTypeID(), queueSlot, true, bgTypeId == BATTLEGROUND_RB, ginfo.teamId);
sBattlegroundMgr->SendToBattleground(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
}
break;
case 0: // leave queue
//.........这里部分代码省略.........
示例15: instance
/*
- return the right instance for the object, based on its InstanceId
- create the instance if it's not created already
- the player is not actually added to the instance (only in InstanceMap::Add)
*/
Map* MapInstanced::CreateInstanceForPlayer(const uint32 mapId, Player* player)
{
if (GetId() != mapId || !player)
return NULL;
Map* map = NULL;
if (IsBattlegroundOrArena())
{
// instantiate or find existing bg map for player
// the instance id is set in battlegroundid
uint32 newInstanceId = player->GetBattlegroundId();
if (!newInstanceId)
return NULL;
map = sMapMgr->FindMap(mapId, newInstanceId);
if (!map)
{
Battleground* bg = player->GetBattleground(true);
if (bg && bg->GetStatus() < STATUS_WAIT_LEAVE)
map = CreateBattleground(newInstanceId, bg);
else
{
player->TeleportToEntryPoint();
return NULL;
}
}
}
else
{
Difficulty realdiff = player->GetDifficulty(IsRaid());
uint32 destInstId = sInstanceSaveMgr->PlayerGetDestinationInstanceId(player, GetId(), realdiff);
if (destInstId)
{
InstanceSave* pSave = sInstanceSaveMgr->GetInstanceSave(destInstId);
ASSERT(pSave); // pussywizard: must exist
map = FindInstanceMap(destInstId);
if (!map)
map = CreateInstance(destInstId, pSave, realdiff);
else if ((mapId == 631 || mapId == 724) && !map->HavePlayers() && map->GetDifficulty() != realdiff)
{
if (player->isBeingLoaded()) // pussywizard: crashfix (assert(passengers.empty) fail in ~transport), could be added to a transport during loading from db
return NULL;
if (!map->AllTransportsEmpty())
map->AllTransportsRemovePassengers(); // pussywizard: gameobjects / summons (assert(passengers.empty) fail in ~transport)
for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
if (i->first == destInstId)
{
DestroyInstance(i);
map = CreateInstance(destInstId, pSave, realdiff);
break;
}
}
}
else
{
uint32 newInstanceId = sMapMgr->GenerateInstanceId();
ASSERT(!FindInstanceMap(newInstanceId)); // pussywizard: instance with new id can't exist
Difficulty diff = player->GetGroup() ? player->GetGroup()->GetDifficulty(IsRaid()) : player->GetDifficulty(IsRaid());
map = CreateInstance(newInstanceId, NULL, diff);
}
}
return map;
}