Example #1
0
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;
}
Example #2
0
void WorldSession::HandlePVPLogDataOpcode(WorldPacket& /*recv_data*/)
{
    DEBUG_LOG("WORLD: Received opcode CMSG_PVP_LOG_DATA");

    BattleGround* bg = _player->GetBattleGround();
    if (!bg)
        return;

    // arena finish version will send in BattleGround::EndBattleGround directly
    if (bg->isArena())
        return;

    WorldPacket data;
    sBattleGroundMgr.BuildPvpLogDataPacket(&data, bg);
    SendPacket(&data);

    DEBUG_LOG("WORLD: Sent SMSG_PVP_LOG_DATA Message");
}