当前位置: 首页>>代码示例>>C++>>正文


C++ Group::IsCreated方法代码示例

本文整理汇总了C++中Group::IsCreated方法的典型用法代码示例。如果您正苦于以下问题:C++ Group::IsCreated方法的具体用法?C++ Group::IsCreated怎么用?C++ Group::IsCreated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Group的用法示例。


在下文中一共展示了Group::IsCreated方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HandleGroupDeclineOpcode

void WorldSession::HandleGroupDeclineOpcode( WorldPacket & /*recv_data*/ )
{
    Group  *group  = GetPlayer()->GetGroupInvite();
    if (!group) return;

    Player *leader = objmgr.GetPlayer(group->GetLeaderGUID());

    /** error handling **/
    if(!leader || !leader->GetSession())
        return;
    /********************/

    // everything's fine, do it
    if(!group->IsCreated())
    {
        // note: this means that if you invite more than one person
        // and one of them declines before the first one accepts
        // all invites will be cleared
        // fixme: is that ok ?
        group->RemoveAllInvites();
        delete group;
    }

    GetPlayer()->SetGroupInvite(NULL);

    WorldPacket data( SMSG_GROUP_DECLINE, 10 );             // guess size
    data << GetPlayer()->GetName();
    leader->GetSession()->SendPacket( &data );
}
开发者ID:Actionfox,项目名称:mangos,代码行数:29,代码来源:GroupHandler.cpp

示例2: HandleGroupAcceptOpcode

void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recvData)
{
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_ACCEPT");
#endif

    recvData.read_skip<uint32>();
    Group* group = GetPlayer()->GetGroupInvite();

    if (!group)
        return;

    // Remove player from invitees in any case
    group->RemoveInvite(GetPlayer());

    if (GetPlayer()->IsSpectator())
    {
        SendPartyResult(PARTY_OP_INVITE, "", ERR_INVITE_RESTRICTED);
        return;
    }

    if (group->GetLeaderGUID() == GetPlayer()->GetGUID())
    {
        sLog->outError("HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow());
        return;
    }

    // Group is full
    if (group->IsFull())
    {
        SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL);
        return;
    }

    Player* leader = ObjectAccessor::FindPlayerInOrOutOfWorld(group->GetLeaderGUID());

    // Forming a new group, create it
    if (!group->IsCreated())
    {
        // This can happen if the leader is zoning. To be removed once delayed actions for zoning are implemented
        if (!leader || leader->IsSpectator())
        {
            group->RemoveAllInvites();
            return;
        }

        // If we're about to create a group there really should be a leader present
        ASSERT(leader);
        group->RemoveInvite(leader);
        group->Create(leader);
        sGroupMgr->AddGroup(group);
    }

    // Everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!!
    if (!group->AddMember(GetPlayer()))
        return;

    group->BroadcastGroupUpdate();
}
开发者ID:Helias,项目名称:azerothcore-wotlk,代码行数:59,代码来源:GroupHandler.cpp

示例3: HandleGroupAcceptOpcode

void WorldSession::HandleGroupAcceptOpcode(WorldPacket& recvData)
{
    TC_LOG_DEBUG("network", "WORLD: Received CMSG_GROUP_ACCEPT");

    recvData.read_skip<uint32>();
    Group* group = GetPlayer()->GetGroupInvite();

    if (!group)
        return;

    // Remove player from invitees in any case
    group->RemoveInvite(GetPlayer());

    if (group->GetLeaderGUID() == GetPlayer()->GetGUID())
    {
        TC_LOG_ERROR("network", "HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().GetCounter());
        return;
    }

    // Group is full
    if (group->IsFull())
    {
        SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL);
        return;
    }

    Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID());

    // Forming a new group, create it
    if (!group->IsCreated())
    {
        // This can happen if the leader is zoning. To be removed once delayed actions for zoning are implemented
        if (!leader)
        {
            group->RemoveAllInvites();
            return;
        }

        // If we're about to create a group there really should be a leader present
        ASSERT(leader);
        group->RemoveInvite(leader);
        group->Create(leader);
        sGroupMgr->AddGroup(group);
    }

    // Everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!!
    if (!group->AddMember(GetPlayer()))
        return;

    group->BroadcastGroupUpdate();
}
开发者ID:shaunk1593,项目名称:Crusade,代码行数:51,代码来源:GroupHandler.cpp

示例4: HandleGroupAcceptOpcode

void WorldSession::HandleGroupAcceptOpcode( WorldPacket & recv_data )
{
    if (!GetPlayer()->GetPlayerbotAI())
        recv_data.read_skip<uint32>();                          // roles mask?

    Group *group = GetPlayer()->GetGroupInvite();
    if (!group)
        return;

    if (group->GetLeaderGuid() == GetPlayer()->GetObjectGuid())
    {
        sLog.outError("HandleGroupAcceptOpcode: %s tried to accept an invite to his own group",
            GetPlayer()->GetGuidStr().c_str());
        return;
    }

    // remove in from invites in any case
    group->RemoveInvite(GetPlayer());

    /** error handling **/
    /********************/

    // not have place
    if(group->IsFull())
    {
        SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL);
        return;
    }

    Player* leader = sObjectMgr.GetPlayer(group->GetLeaderGuid());

    // forming a new group, create it
    if (!group->IsCreated())
    {
        if (leader)
            group->RemoveInvite(leader);
        if (group->Create(group->GetLeaderGuid(), group->GetLeaderName()))
            sObjectMgr.AddGroup(group);
        else
            return;
    }

    // everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!!
    if(!group->AddMember(GetPlayer()->GetObjectGuid(), GetPlayer()->GetName()))
        return;

    // Frozen Mod
    group->BroadcastGroupUpdate();
    // Frozen Mod
}
开发者ID:xiaojie,项目名称:mangos,代码行数:50,代码来源:GroupHandler.cpp

示例5: HandleGroupAcceptOpcode

void WorldSession::HandleGroupAcceptOpcode(WorldPacket & /*recv_data*/)
{
    Group *group = GetPlayer()->GetGroupInvite();
    if (!group) return;

    if (group->GetLeaderGUID() == GetPlayer()->GetGUID())
    {
        sLog.outError("HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
        return;
    }

    // remove in from ivites in any case
    group->RemoveInvite(GetPlayer());

    /** error handling **/
    /********************/

    // not have place
    if (group->IsFull())
    {
        SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL);
        return;
    }

    Player* leader = objmgr.GetPlayer(group->GetLeaderGUID());

    // forming a new group, create it
    if (!group->IsCreated())
    {
        if (leader)
            group->RemoveInvite(leader);
        group->Create(group->GetLeaderGUID(), group->GetLeaderName());
        objmgr.AddGroup(group);
    }

    // everything's fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!!
    if (!group->AddMember(GetPlayer()->GetGUID(), GetPlayer()->GetName()))
        return;

    SendLfgUpdatePlayer(LFG_UPDATETYPE_REMOVED_FROM_QUEUE);
    for (GroupReference *itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
        if (Player *plrg = itr->getSource())
        {
            plrg->GetSession()->SendLfgUpdatePlayer(LFG_UPDATETYPE_CLEAR_LOCK_LIST);
            plrg->GetSession()->SendLfgUpdateParty(LFG_UPDATETYPE_CLEAR_LOCK_LIST);
        }

    group->BroadcastGroupUpdate();
}
开发者ID:Archives,项目名称:ro_core,代码行数:49,代码来源:GroupHandler.cpp

示例6: HandleGroupAcceptOpcode

void WorldSession::HandleGroupAcceptOpcode( WorldPacket & /*recv_data*/ )
{
    Group *group = GetPlayer()->GetGroupInvite();
    if (!group) return;

    if(group->GetLeaderGUID() == GetPlayer()->GetGUID())
    {
        sLog.outError("HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
        return;
    }

    // remove in from ivites in any case
    group->RemoveInvite(GetPlayer());

    /** error handling **/
    /********************/

    // not have place
    if(group->IsFull())
    {
        SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_PARTY_FULL);
        return;
    }

    Player* leader = objmgr.GetPlayer(group->GetLeaderGUID());

    if(leader && leader->InBattleGround())
    {
        SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_INVITE_RESTRICTED);
        return;
    }

    // forming a new group, create it
    if(!group->IsCreated())
    {
        if(leader) group->RemoveInvite(leader);
        group->Create(group->GetLeaderGUID(), group->GetLeaderName());
        objmgr.AddGroup(group);
    }

    // everything's fine, do it
    if(!group->AddMember(GetPlayer()->GetGUID(), GetPlayer()->GetName()))
        return;

    uint8 subgroup = group->GetMemberGroup(GetPlayer()->GetGUID());

    GetPlayer()->SetGroup(group, subgroup);
}
开发者ID:Actionfox,项目名称:mangos,代码行数:48,代码来源:GroupHandler.cpp

示例7: HandleGroupAcceptOpcode

void WorldSession::HandleGroupAcceptOpcode( WorldPacket & /*recv_data*/ )
{
    Group *group = GetPlayer()->GetGroupInvite();
    if (!group)
        return;

    if(group->GetLeaderGUID() == GetPlayer()->GetGUID())
    {
        sLog.outError("HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
        return;
    }

    // remove in from invites in any case
    group->RemoveInvite(GetPlayer());

    /** error handling **/
    /********************/

    // not have place
    if(group->IsFull())
    {
        SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL);
        return;
    }

    Player* leader = sObjectMgr.GetPlayer(group->GetLeaderGUID());

    if(leader && leader->InBattleGround())
    {
        SendPartyResult(PARTY_OP_INVITE, "", ERR_INVITE_RESTRICTED);
        return;
    }

    // forming a new group, create it
    if(!group->IsCreated())
    {
        if (leader)
            group->RemoveInvite(leader);
        if (group->Create(group->GetLeaderGUID(), group->GetLeaderName()))
            sObjectMgr.AddGroup(group);
        else
            return;
    }

    // everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!!
    if(!group->AddMember(GetPlayer()->GetGUID(), GetPlayer()->GetName()))
        return;
}
开发者ID:daemonaps,项目名称:mangoszero,代码行数:48,代码来源:GroupHandler.cpp

示例8: HandleGroupAcceptOpcode

void WorldSession::HandleGroupAcceptOpcode( WorldPacket & recv_data )
{
    recv_data.read_skip<uint32>();                          // value received in WorldSession::HandleGroupInviteOpcode and also skipeed currently?

    Group *group = GetPlayer()->GetGroupInvite();
    if (!group) return;

    if(group->GetLeaderGUID() == GetPlayer()->GetGUID())
    {
        sLog.outError("HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow());
        return;
    }

    // remove in from ivites in any case
    group->RemoveInvite(GetPlayer());

    /** error handling **/
    /********************/

    // not have place
    if(group->IsFull())
    {
        SendPartyResult(PARTY_OP_INVITE, "", PARTY_RESULT_PARTY_FULL);
        return;
    }

    Player* leader = sObjectMgr.GetPlayer(group->GetLeaderGUID());

    // forming a new group, create it
    if(!group->IsCreated())
    {
        if( leader )
            group->RemoveInvite(leader);
        group->Create(group->GetLeaderGUID(), group->GetLeaderName());
        sObjectMgr.AddGroup(group);
    }

    // everything's fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!!
    if(!group->AddMember(GetPlayer()->GetGUID(), GetPlayer()->GetName()))
        return;

}
开发者ID:AdharRuafo,项目名称:mangos,代码行数:42,代码来源:GroupHandler.cpp

示例9: AddPlayerToGroup

bool Battlefield::AddPlayerToGroup(Player * player)
{
    Group* grp;
    if(player->GetTeam() == ALLIANCE)
        grp = m_raidGroup[TEAM_ALLIANCE];
    else
        grp = m_raidGroup[TEAM_HORDE];

    if(!grp->IsCreated())
    {
        grp->Create(player->GetObjectGuid(),player->GetName());
        grp->ConvertToRaid();
        grp->AddMember(player->GetObjectGuid(),player->GetName());
    }
    else if(!grp->IsFull())
    {
        grp->AddMember(player->GetObjectGuid(),player->GetName());
    }
    else
        return false;

    return true;
}
开发者ID:Stylerdk,项目名称:StrawberryCore,代码行数:23,代码来源:Battlefield.cpp

示例10: HandleGroupInviteResponseOpcode

void WorldSession::HandleGroupInviteResponseOpcode(WorldPacket& recvData)
{
    TC_LOG_DEBUG(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_INVITE_RESPONSE");

    recvData.ReadBit(); // unk always 0
    bool accept = recvData.ReadBit();

    // Never actually received?
    /*if (accept)
        recvData.read_skip<uint32>(); // unk*/

    Group* group = GetPlayer()->GetGroupInvite();

    if (!group)
        return;

    if (accept)
    {
        // Remove player from invitees in any case
        group->RemoveInvite(GetPlayer());

        if (group->GetLeaderGUID() == GetPlayer()->GetGUID())
        {
            TC_LOG_ERROR(LOG_FILTER_NETWORKIO, "HandleGroupAcceptOpcode: player %s(%d) tried to accept an invite to his own group", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUIDLow());
            return;
        }

        // Group is full
        if (group->IsFull())
        {
            SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL);
            return;
        }

        Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID());

        // Forming a new group, create it
        if (!group->IsCreated())
        {
            // This can happen if the leader is zoning. To be removed once delayed actions for zoning are implemented
            if (!leader)
            {
                group->RemoveAllInvites();
                return;
            }

            // If we're about to create a group there really should be a leader present
            ASSERT(leader);
            group->RemoveInvite(leader);
            group->Create(leader);
            sGroupMgr->AddGroup(group);
        }

        // Everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!!
        if (!group->AddMember(GetPlayer()))
            return;

        group->BroadcastGroupUpdate();
    }
    else
    {
        // Remember leader if online (group pointer will be invalid if group gets disbanded)
        Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID());

        // uninvite, group can be deleted
        GetPlayer()->UninviteFromGroup();

        if (!leader || !leader->GetSession())
            return;

        // report
        WorldPacket data(SMSG_GROUP_DECLINE, GetPlayer()->GetName().size());
        data << GetPlayer()->GetName();
        leader->GetSession()->SendPacket(&data);
    }
}
开发者ID:Drasgon,项目名称:WoD,代码行数:76,代码来源:GroupHandler.cpp

示例11: HandleGroupInviteResponseOpcode

void WorldSession::HandleGroupInviteResponseOpcode(WorldPacket& recv_data)
{
    bool unk = recv_data.ReadBit();
    bool accepted = recv_data.ReadBit();
    if (unk)
        recv_data.read_skip<uint32>();

    Group* group = GetPlayer()->GetGroupInvite();
    if (!group)
        return;

    if (accepted)
    {
        // remove in from invites in any case
        group->RemoveInvite(GetPlayer());

        if (group->GetLeaderGuid() == GetPlayer()->GetObjectGuid())
        {
            sLog.outError("HandleGroupInviteResponseOpcode: %s tried to accept an invite to his own group",
                          GetPlayer()->GetGuidStr().c_str());
            return;
        }

        /** error handling **/
        /********************/

        // not have place
        if (group->IsFull())
        {
            SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL);
            return;
        }

        Player* leader = sObjectMgr.GetPlayer(group->GetLeaderGuid());

        // forming a new group, create it
        if (!group->IsCreated())
        {
            if (leader)
                group->RemoveInvite(leader);
            if (group->Create(group->GetLeaderGuid(), group->GetLeaderName()))
                sObjectMgr.AddGroup(group);
            else
                return;
        }

        // everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!!
        if (!group->AddMember(GetPlayer()->GetObjectGuid(), GetPlayer()->GetName()))
            return;
    }
    else
    {
        // uninvite, group can be deleted
        GetPlayer()->UninviteFromGroup();

        // remember leader if online
        Player* leader = sObjectMgr.GetPlayer(group->GetLeaderGuid());
        if (!leader || !leader->GetSession())
            return;

        // report
        WorldPacket data(SMSG_GROUP_DECLINE, 10);               // guess size
        data << GetPlayer()->GetName();
        leader->GetSession()->SendPacket(&data);
    }
}
开发者ID:BooYoods,项目名称:cmangos-wod,代码行数:66,代码来源:GroupHandler.cpp

示例12: Update


//.........这里部分代码省略.........
                    {
                        if(FindRoleToGroup(plr, grp, LFG_ROLE_HEALER))
                        {
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    // Check if player can perform dps role
                    if((canPerformRole(qPlayer->second.roleMask, LFG_ROLE_DPS) & qGroup->second.availableRoles) == LFG_ROLE_DPS)
                    {
                        if(FindRoleToGroup(plr, grp, LFG_ROLE_DPS))
                        {
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    // Check if group is full, no need to try to iterate same group if it's already full.
                    if(grp->IsFull())
                    {
                        RemoveGroupFromQueue(qGroup->first, GROUP_SYSTEM_LEAVE);
                        break;
                    }
                }
            }

            // Update group timer. After each 5 minutes group will be broadcasted they're still waiting more members.
            if (qGroup->second.groupTimer <= diff)
            {
                WorldPacket data;
                BuildInProgressPacket(data);

                grp->BroadcastPacket(&data, true);

                qGroup->second.groupTimer = 5 * MINUTE * IN_MILLISECONDS;
            }
            else
            {
                qGroup->second.groupTimer -= diff;
            }
        }
    }

    // Pick first 2 players and form group out of them also inserting them into queue as group.
    if(m_QueuedPlayers.size() > 5)
    {
        // Pick Leader as first target.
        QueuedPlayersMap::iterator nPlayer1 = m_QueuedPlayers.begin();

        if(findInArea(nPlayer1->second.areaId) > 5)
        {
            Group* newQueueGroup = new Group;

            // Iterate of QueuedPlayersMap and pick first member to accompany leader.
            for(QueuedPlayersMap::iterator nPlayer2 = m_QueuedPlayers.begin(); nPlayer2 != m_QueuedPlayers.end(); ++nPlayer2)
            {
                if(nPlayer1->first == nPlayer2->first)
                    continue;

                if(nPlayer1->second.team == nPlayer2->second.team &&
                    nPlayer1->second.areaId == nPlayer2->second.areaId)
                {
                    Player* leader = sObjectMgr.GetPlayer(nPlayer1->first);
                    Player* member = sObjectMgr.GetPlayer(nPlayer2->first);
                    uint32 areaId = nPlayer1->second.areaId;

                    if(!newQueueGroup->IsCreated())
                    {
                        if(newQueueGroup->Create(leader->GetObjectGuid(), leader->GetName()))
                            sObjectMgr.AddGroup(newQueueGroup);
                        else
                            return;
                    }

                    WorldPacket data;
                    BuildMemberAddedPacket(data, member->GetGUID());

                    leader->GetSession()->SendPacket(&data);

                    // Add member to the group. Leader is already added upon creation of group.
                    newQueueGroup->AddMember(member->GetObjectGuid(), member->GetName(), GROUP_LFG);

                    // Add this new group to GroupQueue now and remove players from PlayerQueue
                    RemovePlayerFromQueue(nPlayer1->first, PLAYER_SYSTEM_LEAVE);
                    RemovePlayerFromQueue(nPlayer2->first, PLAYER_SYSTEM_LEAVE);
                    AddToQueue(leader, areaId);

                    break;
                }
            }
        }
    }
}
开发者ID:billy1arm,项目名称:MangosMC,代码行数:101,代码来源:LFGMgr.cpp

示例13: HandlePartyInviteResponseOpcode

void WorldSession::HandlePartyInviteResponseOpcode(WorldPackets::Party::PartyInviteResponse& packet)
{
    Group* group = GetPlayer()->GetGroupInvite();

    if (!group)
        return;

    if (packet.Accept)
    {
        // Remove player from invitees in any case
        group->RemoveInvite(GetPlayer());

        if (group->GetLeaderGUID() == GetPlayer()->GetGUID())
        {
            TC_LOG_ERROR("network", "HandleGroupAcceptOpcode: player %s (%s) tried to accept an invite to his own group", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str());
            return;
        }

        // Group is full
        if (group->IsFull())
        {
            SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL);
            return;
        }

        Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID());

        // Forming a new group, create it
        if (!group->IsCreated())
        {
            // This can happen if the leader is zoning. To be removed once delayed actions for zoning are implemented
            if (!leader)
            {
                group->RemoveAllInvites();
                return;
            }

            // If we're about to create a group there really should be a leader present
            ASSERT(leader);
            group->RemoveInvite(leader);
            group->Create(leader);
            sGroupMgr->AddGroup(group);
        }

        // Everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!!
        if (!group->AddMember(GetPlayer()))
            return;

        group->BroadcastGroupUpdate();
    }
    else
    {
        // Remember leader if online (group pointer will be invalid if group gets disbanded)
        Player* leader = ObjectAccessor::FindConnectedPlayer(group->GetLeaderGUID());

        // uninvite, group can be deleted
        GetPlayer()->UninviteFromGroup();

        if (!leader || !leader->GetSession())
            return;

        // report
        WorldPackets::Party::GroupDecline decline(GetPlayer()->GetName());
        leader->GetSession()->SendPacket(decline.Write());
    }
}
开发者ID:welder1976,项目名称:DraenorCore,代码行数:66,代码来源:GroupHandler.cpp

示例14: HandleGroupInviteOpcode


//.........这里部分代码省略.........
        return;
    }

    if (invitedPlayer->GetSocial()->HasIgnore(invitingPlayer->GetGUID()))
    {
        SendPartyResult(PARTY_OP_INVITE, membername, ERR_IGNORING_YOU_S);
        return;
    }

    if (!invitedPlayer->GetSocial()->HasFriend(invitingPlayer->GetGUID()) && invitingPlayer->getLevel() < sWorld->getIntConfig(CONFIG_PARTY_LEVEL_REQ))
    {
        SendPartyResult(PARTY_OP_INVITE, membername, ERR_INVITE_RESTRICTED);
        return;
    }

    Group* group = invitingPlayer->GetGroup();
    if (group && group->isBGGroup())
        group = invitingPlayer->GetOriginalGroup();
    if (!group)
        group = invitingPlayer->GetGroupInvite();

    Group* group2 = invitedPlayer->GetGroup();
    if (group2 && group2->isBGGroup())
        group2 = invitedPlayer->GetOriginalGroup();
    // player already in another group or invited
    if (group2 || invitedPlayer->GetGroupInvite())
    {
        SendPartyResult(PARTY_OP_INVITE, membername, ERR_ALREADY_IN_GROUP_S);

        if (group2)
        {
            // tell the player that they were invited but it failed as they were already in a group
            WorldPacket data(SMSG_GROUP_INVITE, 10);                // guess size
            data << uint8(0);                                       // invited/already in group flag
            data << invitingPlayer->GetName();                      // max len 48
            data << uint32(0);                                      // unk
            data << uint8(0);                                       // count
            data << uint32(0);                                      // unk
            invitedPlayer->SendDirectMessage(&data);
        }

        return;
    }

    if (group)
    {
        // not have permissions for invite
        if (!group->IsLeader(invitingPlayer->GetGUID()) && !group->IsAssistant(invitingPlayer->GetGUID()))
        {
            if (group->IsCreated())
                SendPartyResult(PARTY_OP_INVITE, "", ERR_NOT_LEADER);
            return;
        }
        // not have place
        if (group->IsFull())
        {
            SendPartyResult(PARTY_OP_INVITE, "", ERR_GROUP_FULL);
            return;
        }
    }

    // ok, but group not exist, start a new group
    // but don't create and save the group to the DB until
    // at least one person joins
    if (!group)
    {
        group = new Group();
        // new group: if can't add then delete
        if (!group->AddLeaderInvite(invitingPlayer))
        {
            delete group;
            return;
        }
        if (!group->AddInvite(invitedPlayer))
        {
            group->RemoveAllInvites();
            delete group;
            return;
        }
    }
    else
    {
        // already existed group: if can't add then just leave
        if (!group->AddInvite(invitedPlayer))
        {
            return;
        }
    }

    // ok, we do it
    WorldPacket data(SMSG_GROUP_INVITE, 10);                // guess size
    data << uint8(1);                                       // invited/already in group flag
    data << invitingPlayer->GetName();                         // max len 48
    data << uint32(0);                                      // unk
    data << uint8(0);                                       // count
    data << uint32(0);                                      // unk
    invitedPlayer->SendDirectMessage(&data);

    SendPartyResult(PARTY_OP_INVITE, membername, ERR_PARTY_RESULT_OK);
}
开发者ID:lasyan3,项目名称:TrinityCore,代码行数:101,代码来源:GroupHandler.cpp

示例15: LFGLoop

void WorldSession::LFGLoop() {

	QueryResult *result = WorldDatabase.Query("SELECT guid,zoneid,is_group FROM lfg_queue");
	if (result)
	{

		do
		{
			Field* fields = result->Fetch();

			//is this entry a group?
			if(fields[2].GetUInt32() == 1) {
				//is there anyone in the queue looking for a group for this groups instance?
				QueryResult *resultLFG = WorldDatabase.PQuery("SELECT guid,zoneid,is_group,player_name FROM lfg_queue WHERE zoneid = '%u' AND is_group = 0", fields[1].GetUInt32());
				if (resultLFG) {
					do
					{
						Field* fieldsLFG = resultLFG->Fetch();
						Player *plr = sObjectAccessor.FindPlayerByName(fieldsLFG[3].GetString());
						Group *grp = sObjectMgr.GetGroupById(fields[0].GetUInt32());

						if(!grp->IsFull()) {
							//check for roles
							if(GroupHasRole(ROLE_TANK, grp) && GroupHasRole(ROLE_HEALER, grp)) {
								//group has both dps & tank, add anyone.
								grp->AddMember(plr->GetGUID(), plr->GetName());
								RemovePlayerFromQueue(plr->GetGUIDLow());

								if(grp->IsFull()) {
									SendMeetingStoneCompleteToParty(grp);
								}
							}
							else if(GroupHasRole(ROLE_TANK, grp) && !GroupHasRole(ROLE_HEALER, grp)) {
								//tank but healers missing
								//is player healer?
								if(isPlayerHealer(plr)) {

									grp->AddMember(plr->GetGUID(), plr->GetName());
									RemovePlayerFromQueue(plr->GetGUIDLow());
									if(grp->IsFull()) {
										SendMeetingStoneCompleteToParty(grp);
									}

								}
								//player is not healer but group can take one more random..
								else if(!isPlayerHealer(plr) && grp->GetMembersCount() < 4) {
									grp->AddMember(plr->GetGUID(), plr->GetName());
									RemovePlayerFromQueue(plr->GetGUIDLow());
									if(grp->IsFull()) {
										SendMeetingStoneCompleteToParty(grp);
									}
								}
							}
							else if(!GroupHasRole(ROLE_TANK, grp) && !GroupHasRole(ROLE_HEALER, grp)) {
								//group has neither tank or healer
								if(isPlayerHealer(plr) || isPlayerTank(plr)) {
									grp->AddMember(plr->GetGUID(), plr->GetName());
									RemovePlayerFromQueue(plr->GetGUIDLow());
									if(grp->IsFull()) {
										SendMeetingStoneCompleteToParty(grp);
									}
								}
								else {
									if(grp->GetMembersCount() < 3) {
										//theres room for 1 more random, let the player join.
										grp->AddMember(plr->GetGUID(), plr->GetName());
										RemovePlayerFromQueue(plr->GetGUIDLow());
										if(grp->IsFull()) {
											SendMeetingStoneCompleteToParty(grp);
										}
									}
								}

							}
						}
					}
					while (resultLFG->NextRow());
				}

			}
			else {
				//its a player, is there any other non-grouped players thats looking for the same instance?

				QueryResult *result_mp = WorldDatabase.PQuery("SELECT guid,zoneid,is_group,player_name FROM lfg_queue WHERE zoneid = '%u' AND is_group = 0", fields[1].GetUInt32());
				if(result_mp->GetRowCount() > 1) {
					int i = 1;
					Group* grp;
					grp = new Group;
					do {
						
						Field* fields_mp = result_mp->Fetch();
						Player *plr = sObjectAccessor.FindPlayerByName(fields_mp[3].GetString());

						if(!grp->IsCreated()) {
							if (grp->Create(plr->GetGUID(), plr->GetName())) {
								sObjectMgr.AddGroup(grp);
								RemovePlayerFromQueue(plr->GetGUIDLow());
							}
						}
						else {
//.........这里部分代码省略.........
开发者ID:Gramish,项目名称:mangos-classic,代码行数:101,代码来源:LFGHandler.cpp


注:本文中的Group::IsCreated方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。