Ejemplo n.º 1
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);
}
Ejemplo n.º 2
0
// Lists all recruits for a guild - Misses times
void WorldSession::HandleGuildFinderGetRecruits(WorldPacket& recvPacket)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_LF_GUILD_GET_RECRUITS");

    uint32 unkTime = 0;
    //recvPacket >> unkTime;

    Player* player = GetPlayer();
    if (!player->GetGuildId())
        return;

    std::vector<MembershipRequest> recruitsList = sGuildFinderMgr->GetAllMembershipRequestsForGuild(player->GetGuildId());
    uint32 recruitCount = recruitsList.size();

    ByteBuffer dataBuffer(53 * recruitCount);
    WorldPacket data(SMSG_LF_GUILD_RECRUIT_LIST_UPDATED, 7 + 26 * recruitCount + 53 * recruitCount);
    data.WriteBits(recruitCount, 20);

    for (std::vector<MembershipRequest>::const_iterator itr = recruitsList.begin(); itr != recruitsList.end(); ++itr)
    {
        MembershipRequest request = *itr;
        ObjectGuid playerGuid(MAKE_NEW_GUID(request.GetPlayerGUID(), 0, HIGHGUID_PLAYER));
        
        data.WriteBit(playerGuid[1]);
        data.WriteBit(playerGuid[4]);
        data.WriteBit(playerGuid[2]);
        data.WriteBit(playerGuid[6]);
        data.WriteBits(request.GetName().size(), 7);
        data.WriteBit(playerGuid[3]);
        data.WriteBit(playerGuid[7]);
        data.WriteBit(playerGuid[5]);
        data.WriteBits(request.GetComment().size(), 11);
        data.WriteBit(playerGuid[0]);
        
        dataBuffer << int32(request.GetAvailability());
        dataBuffer.WriteByteSeq(playerGuid[1]);
        dataBuffer << int32(time(NULL) <= request.GetExpiryTime());
        dataBuffer << int32(request.GetInterests());
        dataBuffer << int32(request.GetClassRoles());
        dataBuffer << int32(time(NULL) - request.GetSubmitTime()); // Time in seconds since application submitted.
        dataBuffer.WriteString(request.GetName());
        dataBuffer.WriteByteSeq(playerGuid[4]);
        dataBuffer.WriteByteSeq(playerGuid[6]);
        dataBuffer.WriteByteSeq(playerGuid[3]);
        dataBuffer.WriteByteSeq(playerGuid[7]);
        dataBuffer.WriteString(request.GetComment());
        dataBuffer << int32(request.GetLevel());
        dataBuffer << int32(request.GetExpiryTime() - time(NULL)); // TIme in seconds until application expires.
        dataBuffer.WriteByteSeq(playerGuid[2]);
        dataBuffer.WriteByteSeq(playerGuid[0]);
        dataBuffer << int32(request.GetClass());
        dataBuffer.WriteByteSeq(playerGuid[5]);
    }

    data.FlushBits();
    data.append(dataBuffer);
    data << uint32(time(NULL)); // Unk time

    player->SendDirectMessage(&data);
}
Ejemplo n.º 3
0
void WorldSession::HandleGuildFinderGetApplications(WorldPacket& /*recvPacket*/)
{
    TC_LOG_DEBUG("network", "WORLD: Received CMSG_LF_GUILD_GET_APPLICATIONS");

    std::list<MembershipRequest> applicatedGuilds = sGuildFinderMgr->GetAllMembershipRequestsForPlayer(GetPlayer()->GetGUIDLow());
    uint32 applicationsCount = applicatedGuilds.size();

    WorldPacket data(SMSG_LF_GUILD_MEMBERSHIP_LIST_UPDATED);

    data << uint32(10 - sGuildFinderMgr->CountRequestsFromPlayer(GetPlayer()->GetGUIDLow())); // Applications count left

    data.WriteBits(applicationsCount, 19);

    if (applicationsCount > 0)
    {
        ByteBuffer bufferData;
        for (std::list<MembershipRequest>::const_iterator itr = applicatedGuilds.begin(); itr != applicatedGuilds.end(); ++itr)
        {
            Guild* guild = sGuildMgr->GetGuildById(itr->GetGuildId());

            if (!guild)
                continue;

            LFGuildSettings guildSettings = sGuildFinderMgr->GetGuildSettings(itr->GetGuildId());
            MembershipRequest request = *itr;

            ObjectGuid guildGuid = ObjectGuid(guild->GetGUID());

            data.WriteBits(request.GetComment().size(), 10);
            data.WriteBits(guild->GetName().size(), 7);
            data.WriteBitSeq<2, 1, 4, 0, 6, 3, 5, 7>(guildGuid);

            bufferData << uint32(50397223);                             // unk Flags
            bufferData.WriteByteSeq<1, 5, 6>(guildGuid);

            bufferData.WriteString(request.GetComment());

            bufferData.WriteByteSeq<0, 2>(guildGuid);
            bufferData << uint32(guildSettings.GetClassRoles());
            bufferData.WriteByteSeq<4>(guildGuid);
            bufferData << uint32(guildSettings.GetAvailability());

            bufferData.WriteString(guild->GetName());

            bufferData << uint32(time(NULL) - request.GetSubmitTime()); // Time since application (seconds)
            bufferData << uint32(guildSettings.GetInterests());
            bufferData << uint32(request.GetExpiryTime() - time(NULL)); // Time left to application expiry (seconds)
            bufferData.WriteByteSeq<7, 3>(guildGuid);
        }

        data.FlushBits();
        data.append(bufferData);
    }
    else
    {
        data.FlushBits();
    }

    GetPlayer()->SendDirectMessage(&data);
}
Ejemplo n.º 4
0
void WorldSession::HandleGuildFinderGetApplications(WorldPacket& /*recvPacket*/)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_LF_GUILD_GET_APPLICATIONS"); // Empty opcode

    std::list<MembershipRequest> applicatedGuilds = sGuildFinderMgr->GetAllMembershipRequestsForPlayer(GetPlayer()->GetGUIDLow());
    uint32 applicationsCount = applicatedGuilds.size();
    WorldPacket data(SMSG_LF_GUILD_MEMBERSHIP_LIST_UPDATED, 7 + 54 * applicationsCount);
    data.WriteBits(applicationsCount, 20);

    if (applicationsCount > 0)
    {
        ByteBuffer bufferData(54 * applicationsCount);
        for (std::list<MembershipRequest>::const_iterator itr = applicatedGuilds.begin(); itr != applicatedGuilds.end(); ++itr)
        {
            Guild* guild = sGuildMgr->GetGuildById(itr->GetGuildId());
            LFGuildSettings guildSettings = sGuildFinderMgr->GetGuildSettings(itr->GetGuildId());
            MembershipRequest request = *itr;

            ObjectGuid guildGuid = ObjectGuid(guild->GetGUID());

            data.WriteBit(guildGuid[1]);
            data.WriteBit(guildGuid[0]);
            data.WriteBit(guildGuid[5]);
            data.WriteBits(request.GetComment().size(), 11);
            data.WriteBit(guildGuid[3]);
            data.WriteBit(guildGuid[7]);
            data.WriteBit(guildGuid[4]);
            data.WriteBit(guildGuid[6]);
            data.WriteBit(guildGuid[2]);
            data.WriteBits(guild->GetName().size(), 8);

            bufferData.WriteByteSeq(guildGuid[2]);
            bufferData.WriteString(request.GetComment());
            bufferData.WriteByteSeq(guildGuid[5]);
            bufferData.WriteString(guild->GetName());

            bufferData << uint32(guildSettings.GetAvailability());
            bufferData << uint32(request.GetExpiryTime() - time(NULL)); // Time left to application expiry (seconds)

            bufferData.WriteByteSeq(guildGuid[0]);
            bufferData.WriteByteSeq(guildGuid[6]);
            bufferData.WriteByteSeq(guildGuid[3]);
            bufferData.WriteByteSeq(guildGuid[7]);

            bufferData << uint32(guildSettings.GetClassRoles());

            bufferData.WriteByteSeq(guildGuid[4]);
            bufferData.WriteByteSeq(guildGuid[1]);

            bufferData << uint32(time(NULL) - request.GetSubmitTime()); // Time since application (seconds)
            bufferData << uint32(guildSettings.GetInterests());
        }

        data.FlushBits();
        data.append(bufferData);
    }
    data << uint32(10 - sGuildFinderMgr->CountRequestsFromPlayer(GetPlayer()->GetGUIDLow())); // Applications count left

    GetPlayer()->SendDirectMessage(&data);
}
Ejemplo n.º 5
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);
}
Ejemplo n.º 6
0
// Lists all recruits for a guild - Misses times
void WorldSession::HandleGuildFinderGetRecruits(WorldPacket& recvPacket)
{
    TC_LOG_DEBUG("network", "WORLD: Received CMSG_LF_GUILD_GET_RECRUITS");

    uint32 unkTime = 0;
    recvPacket >> unkTime;

    Player* player = GetPlayer();
    if (!player->GetGuildId())
        return;

    std::vector<MembershipRequest> recruitsList = sGuildFinderMgr->GetAllMembershipRequestsForGuild(player->GetGuildId());
    uint32 recruitCount = recruitsList.size();

    ByteBuffer dataBuffer;
    WorldPacket data(SMSG_LF_GUILD_RECRUIT_LIST_UPDATED);

    data << uint32(time(NULL)); // Unk time
    data.WriteBits(recruitCount, 18);

    for (std::vector<MembershipRequest>::const_iterator itr = recruitsList.begin(); itr != recruitsList.end(); ++itr)
    {
        MembershipRequest request = *itr;
        ObjectGuid playerGuid(MAKE_NEW_GUID(request.GetPlayerGUID(), 0, HIGHGUID_PLAYER));

        uint8 _class, _level = 0;
        std::string name;
        PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_NAME_QUERY_SIMPLE);
        stmt->setUInt32(0, request.GetPlayerGUID());
        if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
        {
            //name, race, gender, class, level
            Field* fields = result->Fetch();
            name = fields[0].GetString();
            _class = fields[3].GetUInt8();
            _level = fields[4].GetUInt8();
        }

        data.WriteBits(request.GetComment().size(), 10);
        data.WriteBitSeq<6, 3, 1, 4, 0, 5, 2>(playerGuid);
        data.WriteBits(name.size(), 6);
        data.WriteBitSeq<7>(playerGuid);

        dataBuffer << uint32(_class);
        dataBuffer << uint32(_level);
        dataBuffer << uint32(0);
        dataBuffer << uint32(time(NULL) <= request.GetExpiryTime());
        dataBuffer << uint32(request.GetAvailability());
        dataBuffer.WriteByteSeq<7>(playerGuid);
        dataBuffer << uint32(time(NULL) - request.GetSubmitTime()); // Time in seconds since application submitted.

        if (name.size() > 0)
            dataBuffer.append(name.c_str(), name.size());

        dataBuffer.WriteByteSeq<6>(playerGuid);

        if (name.size() > 0)
            dataBuffer.append(name.c_str(), name.size());

        dataBuffer << uint32(request.GetClassRoles());
        dataBuffer.WriteByteSeq<1>(playerGuid);
        dataBuffer << uint32(request.GetInterests());
        dataBuffer << uint32(request.GetExpiryTime() - time(NULL)); // TIme in seconds until application expires.
        dataBuffer.WriteByteSeq<2, 5, 0, 4, 3>(playerGuid);
    }

    data.FlushBits();
    data.append(dataBuffer);

    player->SendDirectMessage(&data);
}
Ejemplo n.º 7
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);
}