void GuildFinderMgr::RemoveMembershipRequest(uint32 playerId, uint32 guildId)
{
    std::vector<MembershipRequest>::iterator itr = _membershipRequests[guildId].begin();
    for (; itr != _membershipRequests[guildId].end(); ++itr)
        if (itr->GetPlayerGUID() == playerId)
            break;

    if (itr == _membershipRequests[guildId].end())
        return;

    SQLTransaction trans = CharacterDatabase.BeginTransaction();

    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_FINDER_APPLICANT);
    stmt->setUInt32(0, itr->GetGuildId());
    stmt->setUInt32(1, itr->GetPlayerGUID());
    trans->Append(stmt);

    CharacterDatabase.CommitTransaction(trans);

    _membershipRequests[guildId].erase(itr);

    // Notify the applicant his submittion has been removed
    if (Player* player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(playerId, 0, HIGHGUID_PLAYER)))
        SendMembershipRequestListUpdate(*player);

    // Notify the guild master and officers the list changed
    if (Guild* guild = sGuildMgr->GetGuildById(guildId))
        SendApplicantListUpdate(*guild);
}
void GuildFinderMgr::DeleteGuild(uint32 guildId)
{
    std::vector<MembershipRequest>::iterator itr = _membershipRequests[guildId].begin();
    while (itr != _membershipRequests[guildId].end())
    {
        SQLTransaction trans = CharacterDatabase.BeginTransaction();

        uint32 applicant = itr->GetPlayerGUID();

        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_FINDER_APPLICANT);
        stmt->setUInt32(0, itr->GetGuildId());
        stmt->setUInt32(1, applicant);
        trans->Append(stmt);

        stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_FINDER_GUILD_SETTINGS);
        stmt->setUInt32(0, itr->GetGuildId());
        trans->Append(stmt);

        CharacterDatabase.CommitTransaction(trans);

        // Notify the applicant his submition has been removed
        if (Player* player = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(applicant, 0, HIGHGUID_PLAYER)))
            SendMembershipRequestListUpdate(*player);

        ++itr;
    }

    _membershipRequests.erase(guildId);
    _guildSettings.erase(guildId);

    // Notify the guild master the list changed (even if he's not a GM any more, not sure if needed)
    if (Guild* guild = sGuildMgr->GetGuildById(guildId))
        SendApplicantListUpdate(*guild);
}
Esempio n. 3
0
void GuildFinderMgr::RemoveAllMembershipRequestsFromPlayer(ObjectGuid const& playerId)
{
    auto playerItr = _membershipRequestsByPlayer.find(playerId);
    if (playerItr == _membershipRequestsByPlayer.end())
        return;

    SQLTransaction trans = CharacterDatabase.BeginTransaction();
    for (auto& guildRequestPair : playerItr->second)
    {
        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_FINDER_APPLICANT);
        stmt->setUInt64(0, guildRequestPair.first.GetCounter());
        stmt->setUInt64(1, playerId.GetCounter());
        trans->Append(stmt);

        // Notify the guild master and officers the list changed
        if (Guild* guild = sGuildMgr->GetGuildByGuid(guildRequestPair.first))
            SendApplicantListUpdate(guild);

        auto guildItr = _membershipRequestsByGuild.find(guildRequestPair.first);
        if (guildItr == _membershipRequestsByGuild.end())
            continue;

        guildItr->second.erase(playerId);
        if (guildItr->second.empty())
            _membershipRequestsByGuild.erase(guildItr);
    }

    CharacterDatabase.CommitTransaction(trans);

    _membershipRequestsByPlayer.erase(playerItr);
}
void GuildFinderMgr::RemoveAllMembershipRequestsFromPlayer(uint32 playerId)
{
    for (MembershipRequestStore::iterator itr = _membershipRequests.begin(); itr != _membershipRequests.end(); ++itr)
    {
        std::vector<MembershipRequest>::iterator itr2 = itr->second.begin();
        for (; itr2 != itr->second.end(); ++itr2)
            if (itr2->GetPlayerGUID() == playerId)
                break;

        if (itr2 == itr->second.end())
            continue;

        SQLTransaction trans = CharacterDatabase.BeginTransaction();
        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_FINDER_APPLICANT);
        stmt->setUInt32(0, itr2->GetGuildId());
        stmt->setUInt32(1, itr2->GetPlayerGUID());
        trans->Append(stmt);

        CharacterDatabase.CommitTransaction(trans);
        itr->second.erase(itr2);

        // Notify the guild master and officers the list changed
        if (Guild* guild = sGuildMgr->GetGuildById(itr->first))
            SendApplicantListUpdate(*guild);
    }
}
Esempio n. 5
0
void GuildFinderMgr::RemoveMembershipRequest(ObjectGuid const& playerId, ObjectGuid const& guildId)
{
    auto guildItr = _membershipRequestsByGuild.find(guildId);
    if (guildItr != _membershipRequestsByGuild.end())
    {
        guildItr->second.erase(playerId);
        if (guildItr->second.empty())
            _membershipRequestsByGuild.erase(guildItr);
    }

    auto playerItr = _membershipRequestsByPlayer.find(playerId);
    if (playerItr != _membershipRequestsByPlayer.end())
    {
        playerItr->second.erase(guildId);
        if (playerItr->second.empty())
            _membershipRequestsByPlayer.erase(playerItr);
    }

    SQLTransaction trans = CharacterDatabase.BeginTransaction();

    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_FINDER_APPLICANT);
    stmt->setUInt64(0, guildId.GetCounter());
    stmt->setUInt64(1, playerId.GetCounter());
    trans->Append(stmt);

    CharacterDatabase.CommitTransaction(trans);

    // Notify the applicant his submittion has been removed
    if (Player* player = ObjectAccessor::FindPlayer(playerId))
        SendMembershipRequestListUpdate(player);

    // Notify the guild master and officers the list changed
    if (Guild* guild = sGuildMgr->GetGuildByGuid(guildId))
        SendApplicantListUpdate(guild);
}
Esempio n. 6
0
void GuildFinderMgr::RemoveAllMembershipRequestsFromPlayer(uint32 playerId)
{
    CharacterDatabase.BeginTransaction();

    for (MembershipRequestStore::iterator itr = _membershipRequests.begin(); itr != _membershipRequests.end(); ++itr)
    {
        std::vector<MembershipRequest>::iterator itr2 = itr->second.begin();
        for(; itr2 != itr->second.end(); ++itr2)
            if (itr2->GetPlayerGUID() == playerId)
                break;

        if (itr2 == itr->second.end())
            continue;

        CharacterDatabase.PExecute("DELETE FROM guild_finder_applicant WHERE guildId = '%u' AND playerGuid = '%u'", itr2->GetGuildId(), itr2->GetPlayerGUID());

        itr->second.erase(itr2);

        // Notify the guild master and officers the list changed
        if (Guild* guild = sGuildMgr.GetGuildById(itr->first))
            SendApplicantListUpdate(*guild);
    }

    CharacterDatabase.CommitTransaction();
}
Esempio n. 7
0
void GuildFinderMgr::AddMembershipRequest(ObjectGuid const& guildGuid, MembershipRequest const& request)
{
    _membershipRequestsByGuild[guildGuid][request.GetPlayerGUID()] = request;
    _membershipRequestsByPlayer[request.GetPlayerGUID()][guildGuid] = request;

    SQLTransaction trans = CharacterDatabase.BeginTransaction();
    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_GUILD_FINDER_APPLICANT);
    stmt->setUInt64(0, request.GetGuildGuid().GetCounter());
    stmt->setUInt64(1, request.GetPlayerGUID().GetCounter());
    stmt->setUInt8(2, request.GetAvailability());
    stmt->setUInt8(3, request.GetClassRoles());
    stmt->setUInt8(4, request.GetInterests());
    stmt->setString(5, request.GetComment());
    stmt->setUInt32(6, request.GetSubmitTime());
    trans->Append(stmt);
    CharacterDatabase.CommitTransaction(trans);

    // Notify the applicant his submittion has been added
    if (Player* player = ObjectAccessor::FindPlayer(request.GetPlayerGUID()))
        SendMembershipRequestListUpdate(player);

    // Notify the guild master and officers the list changed
    if (Guild* guild = sGuildMgr->GetGuildByGuid(guildGuid))
        SendApplicantListUpdate(guild);
}
Esempio n. 8
0
void GuildFinderMgr::RemoveMembershipRequest(uint32 playerId, uint32 guildId)
{
    std::vector<MembershipRequest>::iterator itr = m_membershipRequests[guildId].begin();
    for(; itr != m_membershipRequests[guildId].end(); ++itr)
        if (itr->GetPlayerGuid() == playerId)
            break;

    if (itr == m_membershipRequests[guildId].end())
        return;

    static SqlStatementID deleteFinderApplicant;
    SqlStatement stmt = CharacterDatabase.CreateStatement(deleteFinderApplicant, "DELETE FROM guild_finder_applicant WHERE guildId = ? AND playerGuid = ?");
    stmt.addUInt32(itr->GetGuildId());
    stmt.addUInt32(itr->GetPlayerGuid());
    stmt.Execute();

    m_membershipRequests[guildId].erase(itr);

    // Notify the applicant his submittion has been removed
    if (Player* player = sObjectAccessor.FindPlayer(ObjectGuid(HIGHGUID_PLAYER, playerId)))
        SendMembershipRequestListUpdate(*player);

    // Notify the guild master and officers the list changed
    if (Guild* guild = sGuildMgr.GetGuildById(guildId))
        SendApplicantListUpdate(*guild);
}
Esempio n. 9
0
void GuildFinderMgr::RemoveAllMembershipRequestsFromPlayer(uint32 playerId)
{
    CharacterDatabase.BeginTransaction();

    for (MembershipRequestStore::iterator itr = m_membershipRequests.begin(); itr != m_membershipRequests.end(); ++itr)
    {
        std::vector<MembershipRequest>::iterator itr2 = itr->second.begin();
        for(; itr2 != itr->second.end(); ++itr2)
            if (itr2->GetPlayerGuid() == playerId)
                break;

        if (itr2 == itr->second.end())
            continue;

        static SqlStatementID deleteFinderApplicant;
        CharacterDatabase.BeginTransaction();
        SqlStatement stmt = CharacterDatabase.CreateStatement(deleteFinderApplicant, "DELETE FROM guild_finder_applicant WHERE guildId = ? AND playerGuid = ?");
        stmt.addUInt32(itr2->GetGuildId());
        stmt.addUInt32(itr2->GetPlayerGuid());
        stmt.Execute();
        CharacterDatabase.CommitTransaction();

        itr->second.erase(itr2);

        // Notify the guild master and officers the list changed
        if (Guild* guild = sGuildMgr.GetGuildById(itr->first))
            SendApplicantListUpdate(*guild);
    }

    CharacterDatabase.CommitTransaction();
}
Esempio n. 10
0
void GuildFinderMgr::AddMembershipRequest(uint32 guildGuid, MembershipRequest const& request)
{
    m_membershipRequests[guildGuid].push_back(request);

    static SqlStatementID insertFinderApplicant;
    CharacterDatabase.BeginTransaction();
    SqlStatement stmt = CharacterDatabase.CreateStatement(insertFinderApplicant, "REPLACE INTO guild_finder_applicant (guildId, playerGuid, availability, classRole, interests, comment, submitTime) VALUES(?, ?, ?, ?, ?, ?, ?)");
    stmt.addUInt32(request.GetGuildId());
    stmt.addUInt32(request.GetPlayerGuid());
    stmt.addUInt8(request.GetAvailability());
    stmt.addUInt8(request.GetClassRoles());
    stmt.addUInt8(request.GetInterests());
    stmt.addString(request.GetComment());
    stmt.addUInt32(request.GetSubmitTime());
    stmt.Execute();
    CharacterDatabase.CommitTransaction();

    // Notify the applicant his submittion has been added
    if (Player* player = sObjectAccessor.FindPlayer(ObjectGuid(HIGHGUID_PLAYER, request.GetPlayerGuid())))
        SendMembershipRequestListUpdate(*player);

    // Notify the guild master and officers the list changed
    if (Guild* guild = sGuildMgr.GetGuildById(guildGuid))
        SendApplicantListUpdate(*guild);
}
Esempio n. 11
0
void GuildFinderMgr::AddMembershipRequest(uint32 guildGuid, MembershipRequest const& request)
{
    _membershipRequests[guildGuid].push_back(request);

    std::string comment = request.GetComment();
    CharacterDatabase.escape_string(comment);

    CharacterDatabase.PExecute("REPLACE INTO guild_finder_applicant (guildId, playerGuid, availability, classRole, interests, comment, submitTime) VALUES('%u', '%u', '%u', '%u', '%u', '%s', '%u')", request.GetGuildId(), request.GetPlayerGUID(), request.GetAvailability(), request.GetClassRoles(), request.GetInterests(), comment.c_str(), request.GetSubmitTime());

    // Notify the applicant his submittion has been added
    if (Player* player = sObjectAccessor.FindPlayer(ObjectGuid(HIGHGUID_PLAYER, request.GetPlayerGUID())))
        SendMembershipRequestListUpdate(*player);

    // Notify the guild master and officers the list changed
    if (Guild* guild = sGuildMgr.GetGuildById(guildGuid))
        SendApplicantListUpdate(*guild);
}
Esempio n. 12
0
void GuildFinderMgr::DeleteGuild(ObjectGuid const& guildId)
{
    SQLTransaction trans = CharacterDatabase.BeginTransaction();
    auto guildItr = _membershipRequestsByGuild.find(guildId);
    if (guildItr != _membershipRequestsByGuild.end())
    {
        for (auto playerRequestPair : guildItr->second)
        {
            PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_FINDER_APPLICANT);
            stmt->setUInt64(0, guildId.GetCounter());
            stmt->setUInt64(1, playerRequestPair.first.GetCounter());
            trans->Append(stmt);

            auto playerItr = _membershipRequestsByPlayer.find(playerRequestPair.first);
            if (playerItr != _membershipRequestsByPlayer.end())
            {
                playerItr->second.erase(guildId);
                if (playerItr->second.empty())
                    _membershipRequestsByPlayer.erase(playerItr);
            }

            // Notify the applicant his submition has been removed
            if (Player* player = ObjectAccessor::FindPlayer(playerRequestPair.first))
                SendMembershipRequestListUpdate(player);
        }
    }

    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_FINDER_GUILD_SETTINGS);
    stmt->setUInt64(0, guildId.GetCounter());
    trans->Append(stmt);

    CharacterDatabase.CommitTransaction(trans);

    _membershipRequestsByGuild.erase(guildId);
    _guildSettings.erase(guildId);

    // Notify the guild master the list changed (even if he's not a GM any more, not sure if needed)
    if (Guild* guild = sGuildMgr->GetGuildByGuid(guildId))
        SendApplicantListUpdate(guild);
}
Esempio n. 13
0
void GuildFinderMgr::RemoveMembershipRequest(uint32 playerId, uint32 guildId)
{
    std::vector<MembershipRequest>::iterator itr = _membershipRequests[guildId].begin();
    for(; itr != _membershipRequests[guildId].end(); ++itr)
        if (itr->GetPlayerGUID() == playerId)
            break;

    if (itr == _membershipRequests[guildId].end())
        return;

    CharacterDatabase.PExecute("DELETE FROM guild_finder_applicant WHERE guildId = '%u' AND playerGuid = '%u'", itr->GetGuildId(), itr->GetPlayerGUID());

    _membershipRequests[guildId].erase(itr);

    // Notify the applicant his submittion has been removed
    if (Player* player = sObjectAccessor.FindPlayer(ObjectGuid(HIGHGUID_PLAYER, playerId)))
        SendMembershipRequestListUpdate(*player);

    // Notify the guild master and officers the list changed
    if (Guild* guild = sGuildMgr.GetGuildById(guildId))
        SendApplicantListUpdate(*guild);
}
Esempio n. 14
0
void GuildFinderMgr::DeleteGuild(uint32 guildId)
{
    std::vector<MembershipRequest>::iterator itr = _membershipRequests[guildId].begin();
    while (itr != _membershipRequests[guildId].end())
    {
        uint32 applicant = itr->GetPlayerGUID();

        CharacterDatabase.PExecute("DELETE FROM guild_finder_applicant WHERE guildId = '%u' AND playerGuid = '%u'", itr->GetGuildId(), applicant);
        CharacterDatabase.PExecute("DELETE FROM guild_finder_guild_settings WHERE guildId = '%u'", itr->GetGuildId());

        _membershipRequests[guildId].erase(itr);

        // Notify the applicant his submition has been removed
        if (Player* player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, applicant)))
            SendMembershipRequestListUpdate(*player);
    }

    _membershipRequests.erase(guildId);
    _guildSettings.erase(guildId);

    // Notify the guild master the list changed (even if he's not a GM any more, not sure if needed)
    if (Guild* guild = sGuildMgr.GetGuildById(guildId))
        SendApplicantListUpdate(*guild);
}
Esempio n. 15
0
void GuildFinderMgr::DeleteGuild(uint32 guildId)
{
    std::vector<MembershipRequest>::iterator itr = m_membershipRequests[guildId].begin();
    while (itr != m_membershipRequests[guildId].end())
    {
        uint32 applicant = itr->GetPlayerGuid();

        CharacterDatabase.BeginTransaction();

        static SqlStatementID deleteFinderApplicant;
        static SqlStatementID deleteGuildFinderSettings;
        SqlStatement stmt = CharacterDatabase.CreateStatement(deleteFinderApplicant, "DELETE FROM guild_finder_applicant WHERE guildId = ? AND playerGuid = ?");
        stmt.addUInt32(itr->GetGuildId());
        stmt.addUInt32(itr->GetPlayerGuid());
        stmt.Execute();

        SqlStatement stmt2 = CharacterDatabase.CreateStatement(deleteGuildFinderSettings, "DELETE FROM guild_finder_guild_settings WHERE guildId = ?");
        stmt2.addUInt32(itr->GetGuildId());
        stmt2.Execute();

        CharacterDatabase.CommitTransaction();

        m_membershipRequests[guildId].erase(itr);

        // Notify the applicant his submition has been removed
        if (Player* player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, applicant)))
            SendMembershipRequestListUpdate(*player);
    }

    m_membershipRequests.erase(guildId);
    m_guildSettings.erase(guildId);

    // Notify the guild master the list changed (even if he's not a GM any more, not sure if needed)
    if (Guild* guild = sGuildMgr.GetGuildById(guildId))
        SendApplicantListUpdate(*guild);
}