本文整理汇总了C++中BattleGround::GetPlayers方法的典型用法代码示例。如果您正苦于以下问题:C++ BattleGround::GetPlayers方法的具体用法?C++ BattleGround::GetPlayers怎么用?C++ BattleGround::GetPlayers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BattleGround
的用法示例。
在下文中一共展示了BattleGround::GetPlayers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendBattleGroundChat
bool CPlayer::SendBattleGroundChat(ChatMsg msgtype, std::string message)
{
// Select distance to broadcast to.
float distance = sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_SAY);
if (msgtype == CHAT_MSG_YELL)
sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_YELL);
else if (msgtype == CHAT_MSG_EMOTE)
sWorld.getConfig(CONFIG_FLOAT_LISTEN_RANGE_TEXTEMOTE);
BattleGround* pBattleGround = GetBattleGround();
if (!pBattleGround || pBattleGround->isArena()) // Only fake chat in BG's. CFBG should not interfere with arenas.
return false;
for (auto& itr : pBattleGround->GetPlayers())
{
if (Player* pPlayer = sObjectMgr.GetPlayer(itr.first))
{
if (GetDistance2d(pPlayer->GetPositionX(), pPlayer->GetPositionY()) <= distance)
{
WorldPacket data(SMSG_MESSAGECHAT, 200);
if (GetTeam() == pPlayer->GetTeam())
ChatHandler::BuildChatPacket(data, msgtype, message.c_str(), LANG_UNIVERSAL, GetChatTag(), GetObjectGuid(), GetName());
else if (msgtype != CHAT_MSG_EMOTE)
ChatHandler::BuildChatPacket(data, msgtype, message.c_str(), pPlayer->GetOTeam() == ALLIANCE ? LANG_ORCISH : LANG_COMMON, GetChatTag(), GetObjectGuid(), GetName());
pPlayer->GetSession()->SendPacket(&data);
}
}
}
return true;
}
示例2: RecachePlayersFromBG
void CPlayer::RecachePlayersFromBG()
{
BattleGround* bg = GetBattleGround();
if (!bg)
return;
for (auto& itr : bg->GetPlayers())
{
if (Player* player = sObjectMgr.GetPlayer(itr.first))
{
if (!player->ToCPlayer()->NativeTeam())
{
// Erase bg players from source player cache
WorldPacket data(SMSG_INVALIDATE_PLAYER, 8);
data << player->GetObjectGuid();
GetSession()->SendPacket(&data);
// Send bg player data to source player
data = player->ToCPlayer()->BuildNameQuery();
GetSession()->SendPacket(&data);
}
if (!NativeTeam())
{
// Erase source player from bg players cache
WorldPacket data(SMSG_INVALIDATE_PLAYER, 8);
data << GetObjectGuid();
player->GetSession()->SendPacket(&data);
// Send new source data to bg players
data = BuildNameQuery();
player->GetSession()->SendPacket(&data);
}
}
else
{
// Couldn't find bgplayer, recache him for source player in case he logs in again.
WorldPacket data(SMSG_INVALIDATE_PLAYER, 8);
data << itr.first;
GetSession()->SendPacket(&data);
}
}
}