Пример #1
0
void Antispam::addMessage(const std::string& msg, uint32 type, PlayerPointer from, PlayerPointer to)
{
    if (!m_enabled || from->isGameMaster())
        return;

    if (from->getLevel() > m_restrictionLevel)
        return;

    uint8 chatType = getConvertedChatType(type);

    if (chatType == A_CHAT_TYPE_MAX)
        return;

    if (m_chatMask && (m_chatMask & (1 << chatType)) == 0)
        return;

    MessageBlock messageBlock;
    messageBlock.fromGuid = from->GetObjectGuid();
    messageBlock.fromAccount = from->GetSession()->GetAccountId();
    messageBlock.toGuid = (to && !m_mergeAllWhispers ? to->GetObjectGuid() : ObjectGuid());
    messageBlock.msg = msg;
    messageBlock.type = chatType;
    messageBlock.count = 1;
    messageBlock.time = time(nullptr);

    m_messageQueue.push(messageBlock);
}
Пример #2
0
void Channel::Invite(ObjectGuid p, const char *newname)
{
    if (!IsOn(p))
    {
        WorldPacket data;
        MakeNotMember(&data);
        SendToOne(&data, p);
        return;
    }

    PlayerPointer newp = GetPlayer(newname);
    if (!newp)
    {
        WorldPacket data;
        MakePlayerNotFound(&data, newname);
        SendToOne(&data, p);
        return;
    }

    PlayerPointer plr = GetPlayer(p);
    if (!plr.get())
        return;

    if (newp->GetTeam() != plr->GetTeam() && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
    {
        WorldPacket data;
        MakeInviteWrongFaction(&data);
        SendToOne(&data, p);
        return;
    }

    if (IsOn(newp->GetObjectGuid()))
    {
        WorldPacket data;
        MakePlayerAlreadyMember(&data, newp->GetObjectGuid());
        SendToOne(&data, p);
        return;
    }

    WorldPacket data;
    if (!newp->GetSocial()->HasIgnore(p))
    {
        MakeInvite(&data, p);
        SendToOne(&data, newp->GetObjectGuid());
        data.clear();
    }
    MakePlayerInvited(&data, newp->GetName());
    SendToOne(&data, p);
}
Пример #3
0
void Channel::List(PlayerPointer player)
{
    ObjectGuid p = player->GetObjectGuid();

    MasterPlayer* masterPlayer = player->ToMasterPlayer();
    Player* asPlayer = player->ToPlayer();

    if (!IsOn(p))
    {
        WorldPacket data;
        MakeNotMember(&data);
        SendToOne(&data, p);
    }
    else
    {
        WorldPacket data(SMSG_CHANNEL_LIST, 1 + (GetName().size() + 1) + 1 + 4 + m_players.size() * (8 + 1));
        data << uint8(1);                                   // channel type?
        data << GetName();                                  // channel name
        data << uint8(GetFlags());                          // channel flags?

        size_t pos = data.wpos();
        data << uint32(0);                                  // size of list, placeholder

        AccountTypes gmLevelInWhoList = (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST);

        uint32 count  = 0;
        for (PlayerList::const_iterator i = m_players.begin(); i != m_players.end(); ++i)
        {
            if (masterPlayer)
            {
                MasterPlayer* plr = sObjectAccessor.FindMasterPlayer(i->first);
                // PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
                // MODERATOR, GAME MASTER, ADMINISTRATOR can see all
                if (plr && (masterPlayer->GetSession()->GetSecurity() > SEC_PLAYER || plr->GetSession()->GetSecurity() <= gmLevelInWhoList) &&
                        plr->IsVisibleGloballyFor(masterPlayer))
                {
                    data << ObjectGuid(i->first);
                    data << uint8(i->second.flags);             // flags seems to be changed...
                    ++count;
                }
            }
            else
            {
                Player *plr = sObjectMgr.GetPlayer(i->first);

                // PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
                // MODERATOR, GAME MASTER, ADMINISTRATOR can see all
                if (plr && (asPlayer->GetSession()->GetSecurity() > SEC_PLAYER || plr->GetSession()->GetSecurity() <= gmLevelInWhoList) &&
                        plr->IsVisibleGloballyFor(asPlayer))
                {
                    data << ObjectGuid(i->first);
                    data << uint8(i->second.flags);             // flags seems to be changed...
                    ++count;
                }
            }
        }

        data.put<uint32>(pos, count);

        SendToOne(&data, p);
    }
}
Пример #4
0
void Channel::SetMode(ObjectGuid p, const char *p2n, bool mod, bool set)
{
    PlayerPointer plr = GetPlayer(p);
    if (!plr.get())
        return;

    uint32 sec = plr->GetSession()->GetSecurity();

    if (!IsOn(p))
    {
        WorldPacket data;
        MakeNotMember(&data);
        SendToOne(&data, p);
    }
    else if (!m_players[p].IsModerator() && sec < SEC_GAMEMASTER)
    {
        WorldPacket data;
        MakeNotModerator(&data);
        SendToOne(&data, p);
    }
    else
    {
        PlayerPointer newp = GetPlayer(p2n);
        if (!newp.get())
        {
            WorldPacket data;
            MakePlayerNotFound(&data, p2n);
            SendToOne(&data, p);
            return;
        }

        PlayerInfo inf = m_players[newp->GetObjectGuid()];
        if (p == m_ownerGuid && newp->GetObjectGuid() == m_ownerGuid && mod)
            return;

        if (!IsOn(newp->GetObjectGuid()))
        {
            WorldPacket data;
            MakePlayerNotFound(&data, p2n);
            SendToOne(&data, p);
            return;
        }

        // allow make moderator from another team only if both is GMs
        // at this moment this only way to show channel post for GM from another team
        if ((plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || newp->GetSession()->GetSecurity() < SEC_GAMEMASTER) &&
                plr->GetTeam() != newp->GetTeam() && !sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
        {
            WorldPacket data;
            MakePlayerNotFound(&data, p2n);
            SendToOne(&data, p);
            return;
        }

        if (m_ownerGuid == newp->GetObjectGuid() && m_ownerGuid != p)
        {
            WorldPacket data;
            MakeNotOwner(&data);
            SendToOne(&data, p);
            return;
        }

        if (mod)
        {
            if (HasFlag(CHANNEL_FLAG_GENERAL) && newp->GetSession()->GetSecurity() < SEC_GAMEMASTER)
                return;

            SetModerator(newp->GetObjectGuid(), set);
        }
        else
            SetMute(newp->GetObjectGuid(), set);
    }
}