void PacketBuilder::WriteCreateData(MoveSpline const& moveSpline, ByteBuffer& data)
    {
        if (!moveSpline.Finalized())
        {
            MoveSplineFlag splineFlags = moveSpline.splineflags;

            if ((splineFlags & MoveSplineFlag::Parabolic) && moveSpline.effect_start_time < moveSpline.Duration())
                data << moveSpline.vertical_acceleration;   // added in 3.1

            data << moveSpline.timePassed();

            if (splineFlags.final_angle)
                data << moveSpline.facing.angle;
            else if (splineFlags.final_target)
            {
                ObjectGuid facingGuid = moveSpline.facing.target;
                data.WriteByteSeq(facingGuid[5]);
                data.WriteByteSeq(facingGuid[3]);
                data.WriteByteSeq(facingGuid[7]);
                data.WriteByteSeq(facingGuid[1]);
                data.WriteByteSeq(facingGuid[6]);
                data.WriteByteSeq(facingGuid[4]);
                data.WriteByteSeq(facingGuid[2]);
                data.WriteByteSeq(facingGuid[0]);
            }

            uint32 nodes = moveSpline.getPath().size();
            for (uint32 i = 0; i < nodes; ++i)
            {
                data << float(moveSpline.getPath()[i].z);
                data << float(moveSpline.getPath()[i].x);
                data << float(moveSpline.getPath()[i].y);
            }

            if (splineFlags.final_point)
                data << moveSpline.facing.f.x << moveSpline.facing.f.z << moveSpline.facing.f.y;

            data << float(1.f);                             // splineInfo.duration_mod_next; added in 3.1
            data << moveSpline.Duration();
            if (splineFlags & (MoveSplineFlag::Parabolic | MoveSplineFlag::Animation))
                data << moveSpline.effect_start_time;       // added in 3.1

            data << float(1.f);                             // splineInfo.duration_mod; added in 3.1
        }

        if (!moveSpline.isCyclic())
        {
            Vector3 dest = moveSpline.FinalDestination();
            data << float(dest.z);
            data << float(dest.x);
            data << float(dest.y);
        }
        else
            data << Vector3::zero();

        data << moveSpline.GetId();
    }
示例#2
0
void GuildEventLogEntry::writeGuildLogPacket(WorldPacket& data, ByteBuffer& content) const
{
    ObjectGuid guid1 = MAKE_NEW_GUID(mPlayerGuid1, 0, HIGHGUID_TYPE_PLAYER);
    ObjectGuid guid2 = MAKE_NEW_GUID(mPlayerGuid2, 0, HIGHGUID_TYPE_PLAYER);

    data.writeBit(guid1[2]);
    data.writeBit(guid1[4]);
    data.writeBit(guid2[7]);
    data.writeBit(guid2[6]);
    data.writeBit(guid1[3]);
    data.writeBit(guid2[3]);
    data.writeBit(guid2[5]);
    data.writeBit(guid1[7]);
    data.writeBit(guid1[5]);
    data.writeBit(guid1[0]);
    data.writeBit(guid2[4]);
    data.writeBit(guid2[2]);
    data.writeBit(guid2[0]);
    data.writeBit(guid2[1]);
    data.writeBit(guid1[1]);
    data.writeBit(guid1[6]);

    content.WriteByteSeq(guid2[3]);
    content.WriteByteSeq(guid2[2]);
    content.WriteByteSeq(guid2[5]);

    content << uint8_t(mNewRank);

    content.WriteByteSeq(guid2[4]);
    content.WriteByteSeq(guid1[0]);
    content.WriteByteSeq(guid1[4]);

    content << uint32_t(::time(nullptr) - mTimestamp);

    content.WriteByteSeq(guid1[7]);
    content.WriteByteSeq(guid1[3]);
    content.WriteByteSeq(guid2[0]);
    content.WriteByteSeq(guid2[6]);
    content.WriteByteSeq(guid2[7]);
    content.WriteByteSeq(guid1[5]);

    content << uint8_t(mEventType);

    content.WriteByteSeq(guid2[1]);
    content.WriteByteSeq(guid1[2]);
    content.WriteByteSeq(guid1[6]);
    content.WriteByteSeq(guid1[1]);
}
    void PacketBuilder::WriteFacingTargetPart(MoveSpline const& moveSpline, ByteBuffer& data)
    {
        if (GetMonsterMoveType(moveSpline) == MonsterMoveFacingTarget && !moveSpline.Finalized())
        {
            ObjectGuid facingGuid = moveSpline.facing.target;
            data.WriteBit(facingGuid[4]);
            data.WriteBit(facingGuid[7]);
            data.WriteBit(facingGuid[0]);
            data.WriteBit(facingGuid[5]);
            data.WriteBit(facingGuid[1]);
            data.WriteBit(facingGuid[2]);
            data.WriteBit(facingGuid[3]);
            data.WriteBit(facingGuid[6]);

            data.WriteByteSeq(facingGuid[4]);
            data.WriteByteSeq(facingGuid[2]);
            data.WriteByteSeq(facingGuid[0]);
            data.WriteByteSeq(facingGuid[5]);
            data.WriteByteSeq(facingGuid[6]);
            data.WriteByteSeq(facingGuid[3]);
            data.WriteByteSeq(facingGuid[1]);
            data.WriteByteSeq(facingGuid[7]);
        }
    }
    void PacketBuilder::WriteStopMovement(Vector3 const& pos, uint32 splineId, ByteBuffer& data, Unit* unit)
    {

        ObjectGuid guid = unit->GetGUID();
        ObjectGuid transport = unit->GetTransGUID();

        data << float(pos.z);
        data << float(pos.x);
        data << uint32(splineId);
        data << float(pos.y);
        data << float(0.f); // Most likely transport Y
        data << float(0.f); // Most likely transport Z
        data << float(0.f); // Most likely transport X

        data.WriteBit(1); // Parabolic speed // esi+4Ch
        data.WriteBit(guid[0]);
        data.WriteBits(MonsterMoveStop, 3);
        data.WriteBit(1);
        data.WriteBit(1);
        data.WriteBit(1);
        data.WriteBits(0,  20);
        data.WriteBit(1);
        data.WriteBit(guid[3]);
        data.WriteBit(1);
        data.WriteBit(1);
        data.WriteBit(1);
        data.WriteBit(1);
        data.WriteGuidMask(guid, 7, 4);
        data.WriteBit(1);
        data.WriteBit(guid[5]);
        data.WriteBits(0, 22); // WP count
        data.WriteBit(guid[6]);
        data.WriteBit(0); // Fake bit
        data.WriteGuidMask(transport, 7, 1, 3, 0, 6, 4, 5, 2);
        data.WriteBit(0); // Send no block
        data.WriteBit(0);
        data.WriteGuidMask(guid, 2, 1);

        data.FlushBits();

        data.WriteByteSeq(guid[1]);
        data.WriteGuidBytes(transport, 6, 4, 1, 7, 0, 3, 5, 2);
        data.WriteGuidBytes(guid, 5, 3, 6, 0, 7, 2, 4);
    }
    void PacketBuilder::WriteStopMovement(Vector3 const& pos, uint32 splineId, ByteBuffer& data)
	{
		ObjectGuid moverGUID;
		ObjectGuid transportGUID;

		data << float(pos.z);
		data << float(pos.x);
		data << uint32(splineId); //SplineId
		data << float(pos.y);
		data << float(0.f); // Most likely transport Y
		data << float(0.f); // Most likely transport Z
		data << float(0.f); // Most likely transport X

		data.WriteBit(1); // Parabolic speed // esi+4Ch
		data.WriteBit(moverGUID[0]);
		data.WriteBits(MonsterMoveStop, 3);
		data.WriteBit(1);
		data.WriteBit(1);
		data.WriteBit(1);
		data.WriteBits(0, 20);
		data.WriteBit(1);
		data.WriteBit(moverGUID[3]);
		data.WriteBit(1);
		data.WriteBit(1);
		data.WriteBit(1);
		data.WriteBit(1);
		data.WriteBit(moverGUID[7]);
		data.WriteBit(moverGUID[4]);
		data.WriteBit(1);
		data.WriteBit(moverGUID[5]);
		data.WriteBits(0, 22); // WP count
		data.WriteBit(moverGUID[6]);
		data.WriteBit(0); // Fake bit
		data.WriteBit(transportGUID[7]);
		data.WriteBit(transportGUID[1]);
		data.WriteBit(transportGUID[3]);
		data.WriteBit(transportGUID[0]);
		data.WriteBit(transportGUID[6]);
		data.WriteBit(transportGUID[4]);
		data.WriteBit(transportGUID[5]);
		data.WriteBit(transportGUID[2]);
		data.WriteBit(0); // Send no block
		data.WriteBit(0);
		data.WriteBit(moverGUID[2]);
		data.WriteBit(moverGUID[1]);

		data.FlushBits();

		data.WriteByteSeq(moverGUID[1]);

		data.WriteByteSeq(transportGUID[6]);
		data.WriteByteSeq(transportGUID[4]);
		data.WriteByteSeq(transportGUID[1]);
		data.WriteByteSeq(transportGUID[7]);
		data.WriteByteSeq(transportGUID[0]);
		data.WriteByteSeq(transportGUID[3]);
		data.WriteByteSeq(transportGUID[5]);
		data.WriteByteSeq(transportGUID[2]);

		data.WriteByteSeq(moverGUID[5]);
		data.WriteByteSeq(moverGUID[3]);
		data.WriteByteSeq(moverGUID[6]);
		data.WriteByteSeq(moverGUID[0]);
		data.WriteByteSeq(moverGUID[7]);
		data.WriteByteSeq(moverGUID[2]);
		data.WriteByteSeq(moverGUID[4]);
    }
void WorldSession::HandleGuildFinderBrowse(WorldPacket& recvPacket)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_LF_GUILD_BROWSE");

    uint32 classRoles = 0;
    uint32 availability = 0;
    uint32 guildInterests = 0;
    uint32 playerLevel = 0; // Raw player level (1-90), do they use MAX_FINDER_LEVEL when on level 90 ?

	recvPacket >> playerLevel >> availability >> classRoles >> guildInterests;

    Player* player = GetPlayer();

    LFGuildPlayer settings(player->GetGUIDLow(), classRoles, availability, guildInterests, ANY_FINDER_LEVEL);
    LFGuildStore guildList = sGuildFinderMgr->GetGuildsMatchingSetting(settings, player->GetTeamId());
    uint32 guildCount = guildList.size();

    if (guildCount == 0)
    {
        WorldPacket packet(SMSG_LF_GUILD_BROWSE_UPDATED);
        packet.WriteBits(0, 18);
        player->SendDirectMessage(&packet);
        return;
    }

    bool returned = false;

    if (!(classRoles & GUILDFINDER_ALL_ROLES) || classRoles > GUILDFINDER_ALL_ROLES)
        returned = true;
    if (!(availability & ALL_WEEK) || availability > ALL_WEEK)
        returned = true;
    if (!(guildInterests & ALL_INTERESTS) || guildInterests > ALL_INTERESTS)
        returned = true;
    if (playerLevel > sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) || playerLevel < 1)
        returned = true;

    if (returned)
    {
        WorldPacket packet(SMSG_LF_GUILD_BROWSE_UPDATED);
        packet.WriteBits(0, 18);
        player->SendDirectMessage(&packet);
        return;
    }

    ByteBuffer bufferData;
    WorldPacket data(SMSG_LF_GUILD_BROWSE_UPDATED);

    data.WriteBits(guildCount, 18);

    for (LFGuildStore::const_iterator itr = guildList.begin(); itr != guildList.end(); ++itr)
    {
        LFGuildSettings guildSettings = itr->second;
        Guild* guild = sGuildMgr->GetGuildById(itr->first);

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

		data.WriteBit(guildGUID[6]);
		data.WriteBit(guildGUID[5]);
        data.WriteBit(guildGUID[4]);
        data.WriteBit(guildGUID[0]);
        data.WriteBit(guildGUID[1]);
        data.WriteBits(guildSettings.GetComment().size(), 10);
        data.WriteBit(guildGUID[3]);

		data.WriteBits(guild->GetName().size(), 7);

        data.WriteBit(guildGUID[7]);
        data.WriteBit(guildGUID[2]);

		bufferData.WriteByteSeq(guildGUID[3]);
		bufferData << uint32(guild->GetEmblemInfo().GetStyle());
		bufferData << uint8(sGuildFinderMgr->HasRequest(player->GetGUIDLow(), guild->GetGUID()));

		bufferData.WriteByteSeq(guildGUID[0]);

		bufferData << uint32(guild->GetAchievementMgr().GetAchievementPoints());

		bufferData.WriteByteSeq(guildGUID[2]);

		bufferData << uint32(guildSettings.GetInterests());
		bufferData << int32(guild->GetEmblemInfo().GetBackgroundColor());
		bufferData << guild->GetLevel();
		bufferData << uint32(guildSettings.GetAvailability());
		bufferData << uint32(guildSettings.GetClassRoles());

		bufferData.WriteByteSeq(guildGUID[5]);
		bufferData << uint32(0);                                                              // Unk

		if (guild->GetName().size() > 0)
			bufferData.append(guild->GetName().c_str(), guild->GetName().size());

		bufferData << uint32(0);                                                              // Unk
		bufferData << uint32(guild->GetEmblemInfo().GetBorderStyle());
		bufferData.WriteByteSeq(guildGUID[7]);
		bufferData << uint32(guild->GetEmblemInfo().GetColor());
		bufferData.WriteByteSeq(guildGUID[6]);
		bufferData << uint32(0);                                                              // Unk

		if (guildSettings.GetComment().size() > 0)
			bufferData.append(guildSettings.GetComment().c_str(), guildSettings.GetComment().size());

		bufferData << uint32(guild->GetEmblemInfo().GetBorderColor());
		bufferData << uint32(guild->GetMembersCount());

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

    }

    data.FlushBits();
    data.append(bufferData);

    player->SendDirectMessage(&data);
}
void WorldSession::HandleGuildFinderGetApplications(WorldPacket& /*recvPacket*/)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_LF_GUILD_GET_APPLICATIONS");

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

	ByteBuffer bufferDataHead;
	ByteBuffer bufferDataTail;

    if (applicationsCount > 0)
	{
		bufferDataHead.WriteBits(applicationsCount, 19);

        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());

			bufferDataHead.WriteBit(guildGuid[0]);
			bufferDataHead.WriteBit(guildGuid[4]);
			bufferDataHead.WriteBit(guildGuid[2]);
			bufferDataHead.WriteBit(guildGuid[7]);

			bufferDataHead.WriteBits(guild->GetName().size(), 7);

			bufferDataHead.WriteBit(guildGuid[1]);
			bufferDataHead.WriteBit(guildGuid[3]);

			bufferDataHead.WriteBits(request.GetComment().size(), 10);

			bufferDataHead.WriteBit(guildGuid[6]);
			bufferDataHead.WriteBit(guildGuid[5]);

			bufferDataTail << uint32(guildSettings.GetInterests());
			bufferDataTail << uint32(0);

			if (guild->GetName().size() > 0)
				bufferDataTail.append(guild->GetName().c_str(), guild->GetName().size());

			bufferDataTail.WriteByteSeq(guildGuid[4]);

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

			bufferDataTail.WriteByteSeq(guildGuid[6]);
			bufferDataTail.WriteByteSeq(guildGuid[5]);

			bufferDataTail << uint32(time(NULL) - request.GetSubmitTime()); // Time since application (seconds)

			bufferDataTail.WriteByteSeq(guildGuid[1]);
			bufferDataTail.WriteByteSeq(guildGuid[3]);
			bufferDataTail.WriteByteSeq(guildGuid[0]);
			bufferDataTail.WriteByteSeq(guildGuid[7]);
			bufferDataTail.WriteByteSeq(guildGuid[2]);

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

			bufferDataTail << uint32(guildSettings.GetAvailability());

            if (request.GetComment().size() > 0)
				bufferDataTail.append(request.GetComment().c_str(), request.GetComment().size());
        }

		bufferDataHead.FlushBits();
	}
	else
	{
		bufferDataHead.WriteBits(0, 24);
	}

	WorldPacket data(SMSG_LF_GUILD_MEMBERSHIP_LIST_UPDATED, bufferDataHead.size() + bufferDataTail.size() + 8);

	data.append(bufferDataHead);

	if (bufferDataTail.size() > 0)
		data.append(bufferDataTail);

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

	GetPlayer()->SendDirectMessage(&data);
}
//called when player lists his received mails
void WorldSession::HandleGetMailList(WorldPacket& recvData)
{
    ObjectGuid mailbox;

    mailbox[6] = recvData.ReadBit();
    mailbox[3] = recvData.ReadBit();
    mailbox[7] = recvData.ReadBit();
    mailbox[5] = recvData.ReadBit();
    mailbox[4] = recvData.ReadBit();
    mailbox[1] = recvData.ReadBit();
    mailbox[2] = recvData.ReadBit();
    mailbox[0] = recvData.ReadBit();

    recvData.ReadByteSeq(mailbox[7]);
    recvData.ReadByteSeq(mailbox[1]);
    recvData.ReadByteSeq(mailbox[6]);
    recvData.ReadByteSeq(mailbox[5]);
    recvData.ReadByteSeq(mailbox[4]);
    recvData.ReadByteSeq(mailbox[2]);
    recvData.ReadByteSeq(mailbox[3]);
    recvData.ReadByteSeq(mailbox[0]);

    if (!GetPlayer()->GetGameObjectIfCanInteractWith(mailbox, GAMEOBJECT_TYPE_MAILBOX))
        return;

    Player* player = _player;

    //load players mails, and mailed items
    if (!player->m_mailsLoaded)
        player->_LoadMail();

    // client can't work with packets > max int16 value
    const uint32 maxPacketSize = 32767;

    uint32 mailCount = 0;
    uint32 realCount = 0;                               // true mail count (includes any skipped mail)
    time_t cur_time = time(NULL);
    ByteBuffer mailData;

    WorldPacket data(SMSG_MAIL_LIST_RESULT, 200);       // guess size
    data << uint32(0);                                  // placeholder

    size_t mailCountPos = data.bitwpos();
    data.WriteBits(0, 18);                              // placeholder

    for (PlayerMails::iterator itr = player->GetMailBegin(); itr != player->GetMailEnd(); ++itr)
    {
        Mail* mail = *itr;

        // Only first 50 mails are displayed
        if (mailCount >= 50)
        {
            realCount += 1;
            continue;
        }

        // skip deleted or not delivered (deliver delay not expired) mails
        if (mail->state == MAIL_STATE_DELETED || cur_time < mail->deliver_time)
            continue;

        // skip mail with more than MAX_MAIL_ITEMS items (should not occur)
        uint8 itemCount = mail->items.size();
        if (itemCount > MAX_MAIL_ITEMS)
        {
            realCount += 1;
            continue;
        }

        // skip mail if the packet has become too large (should not occur)
        size_t nextMailSize = 6 + 1 + 8 + itemCount * (4 + 4 + 4 + 4 + 4 + MAX_INSPECTED_ENCHANTMENT_SLOT * (4 + 4 + 4) +
            4 + 4 + 4 + 4 + 1 + 4) + mail->body.size() + mail->subject.size() + 4 + 4 + 8 + 4 + 8 + 4 + 4 + 1 + 4;

        if (data.wpos() + nextMailSize > maxPacketSize)
        {
            realCount += 1;
            continue;
        }

        data.WriteBit(mail->messageType != MAIL_NORMAL ? 1 : 0);
        data.WriteBits(mail->subject.size(), 8);
        data.WriteBits(mail->body.size(), 13);
        data.WriteBit(0);
        data.WriteBit(0);

        size_t itemCountPos = data.bitwpos();
        data.WriteBits(0, 17);                          // placeholder

        data.WriteBit(1);                               // has guid

        ObjectGuid guid = mail->messageType == MAIL_NORMAL ? MAKE_NEW_GUID(mail->sender, 0, HIGHGUID_PLAYER) : 0;
        data.WriteBit(guid[2]);
        data.WriteBit(guid[6]);
        data.WriteBit(guid[7]);
        data.WriteBit(guid[0]);
        data.WriteBit(guid[5]);
        data.WriteBit(guid[3]);
        data.WriteBit(guid[1]);
        data.WriteBit(guid[4]);

        uint8 trueItemCount = 0;
        for (uint8 i = 0; i < itemCount; i++)
        {
            Item* item = player->GetMItem(mail->items[i].item_guid);
            if (!item)
                continue;

            data.WriteBit(0);

            mailData << uint32(item->GetGUIDLow());
            mailData << uint32(4);                      // unknown
            mailData << uint32(item->GetSpellCharges());
            mailData << uint32(item->GetUInt32Value(ITEM_FIELD_DURABILITY));
            mailData << uint32(0);                      // unknown

            for (uint8 j = 0; j < MAX_INSPECTED_ENCHANTMENT_SLOT; j++)
            {
                mailData << uint32(item->GetEnchantmentCharges((EnchantmentSlot)j));
                mailData << uint32(item->GetEnchantmentDuration((EnchantmentSlot)j));
                mailData << uint32(item->GetEnchantmentId((EnchantmentSlot)j));
            }

            mailData << uint32(item->GetItemSuffixFactor());
            mailData << int32(item->GetItemRandomPropertyId());
            mailData << uint32(item->GetUInt32Value(ITEM_FIELD_MAX_DURABILITY));
            mailData << uint32(item->GetCount());
            mailData << uint8(i);
            mailData << uint32(item->GetEntry());

            trueItemCount++;
        }

        data.PutBits(itemCountPos, trueItemCount, 17);

        mailData.WriteString(mail->body);
        mailData << uint32(mail->messageID);
        mailData.WriteByteSeq(guid[4]);
        mailData.WriteByteSeq(guid[0]);
        mailData.WriteByteSeq(guid[5]);
        mailData.WriteByteSeq(guid[3]);
        mailData.WriteByteSeq(guid[1]);
        mailData.WriteByteSeq(guid[7]);
        mailData.WriteByteSeq(guid[2]);
        mailData.WriteByteSeq(guid[6]);
        mailData << uint32(mail->mailTemplateId);
        mailData << uint64(mail->COD);
        mailData.WriteString(mail->subject);
        mailData << uint32(mail->stationery);
        mailData << float(float(mail->expire_time - time(NULL)) / DAY);
        mailData << uint64(mail->money);
        mailData << uint32(mail->checked);

        if (mail->messageType != MAIL_NORMAL)
            mailData << uint32(mail->sender);

        mailData << uint8(mail->messageType);
        mailData << uint32(0);                          // unknown

        realCount++;
        mailCount++;
    }

    data.FlushBits();
    data.append(mailData);

    data.put<uint32>(0, realCount);
    data.PutBits(mailCountPos, mailCount, 18);

    SendPacket(&data);

    // recalculate m_nextMailDelivereTime and unReadMails
    _player->UpdateNextMailTimeAndUnreads();
}
    void PacketBuilder::WriteStopMovement(Vector3 const& pos, uint32 splineId, ByteBuffer& data, Unit* unit)
    {

        ObjectGuid guid = unit->GetGUID();
        ObjectGuid transport = unit->GetTransGUID();

        data << float(0.f); // Most likely transport Y
        data << uint32(getMSTime());
        data << float(0.f); // Most likely transport Z
        data << float(0.f); // Most likely transport X
        data << float(pos.x);
        data << float(pos.y);
        data << float(pos.z);

        data.WriteBit(guid[3]);
        data.WriteBit(1);
        data.WriteBit(guid[6]);

        data.WriteBit(1);
        data.WriteBit(1);

        data.WriteBits(0, 3);
        data.WriteBit(1);
        data.WriteBit(guid[2]);
        data.WriteBit(guid[7]);
        data.WriteBit(guid[5]);
        data.WriteBit(1);
        data.WriteBit(guid[4]);

        data.WriteBits(0, 22); // WP count
        data.WriteBit(1);
        data.WriteBit(0);

        data.WriteBit(guid[0]);
        data.WriteBit(transport[3]);
        data.WriteBit(transport[6]);
        data.WriteBit(transport[5]);
        data.WriteBit(transport[0]);
        data.WriteBit(transport[1]);
        data.WriteBit(transport[2]);
        data.WriteBit(transport[4]);
        data.WriteBit(transport[7]);

        data.WriteBit(1);
        data.WriteBit(1); // Parabolic speed // esi+4Ch
        data.WriteBit(1);

        data.WriteBits(0, 20);

        data.WriteBit(guid[1]);
        data.WriteBit(0);
        data.WriteBit(0);
        data.WriteBit(1);

        data.FlushBits();

        data.WriteByteSeq(guid[3]);
        data.WriteByteSeq(transport[7]);
        data.WriteByteSeq(transport[3]);
        data.WriteByteSeq(transport[2]);
        data.WriteByteSeq(transport[0]);
        data.WriteByteSeq(transport[6]);
        data.WriteByteSeq(transport[4]);
        data.WriteByteSeq(transport[5]);
        data.WriteByteSeq(transport[1]);
        data.WriteByteSeq(guid[7]);
        data.WriteByteSeq(guid[5]);
        data.WriteByteSeq(guid[1]);
        data.WriteByteSeq(guid[2]);
        data.WriteByteSeq(guid[6]);
        data.WriteByteSeq(guid[0]);
        data.WriteByteSeq(guid[4]);
}
void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/)
{
    uint64 guid = _player->GetGUID();
    TC_LOG_DEBUG("network", "CMSG_CALENDAR_GET_CALENDAR [" UI64FMTD "]", guid);

    time_t currTime = time(NULL);
    uint32 counter = 0;
    CalendarInviteStore invites = sCalendarMgr->GetPlayerInvites(guid);
    CalendarEventStore playerEvents = sCalendarMgr->GetPlayerEvents(guid);
    ResetTimeByMapDifficultyMap const& resets = sInstanceSaveMgr->GetResetTimeMap();

    ByteBuffer lockoutInfoBuffer;
    ByteBuffer invitesInfoBuffer;
    ByteBuffer eventsInfoBuffer;
    WorldPacket data(SMSG_CALENDAR_SEND_CALENDAR, 1000); // Average size if no instance
    size_t resetPos = data.bitwpos();
    data.WriteBits(0, 20);  // Reset placeholder
    data.WriteBits(0, 16);  // Holidays -> f**k that shit... Necessary to find out when this should be sent
    size_t lockoutPos = data.bitwpos();
    data.WriteBits(0, 20);  // Lockout placeholder

    for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
    {
        Player::BoundInstancesMap boundInstances = _player->GetBoundInstances(Difficulty(i));
        for (Player::BoundInstancesMap::const_iterator itr = boundInstances.begin(); itr != boundInstances.end(); ++itr)
        {
            if (itr->second.perm)
            {
                InstanceSave const* save = itr->second.save;
                ObjectGuid guid = save->GetInstanceId();
                data.WriteBit(guid[6]);
                data.WriteBit(guid[7]);
                data.WriteBit(guid[2]);
                data.WriteBit(guid[1]);
                data.WriteBit(guid[5]);
                data.WriteBit(guid[4]);
                data.WriteBit(guid[0]);
                data.WriteBit(guid[3]);

                lockoutInfoBuffer << uint32(save->GetDifficulty());
                lockoutInfoBuffer.WriteByteSeq(guid[3]);
                lockoutInfoBuffer.WriteByteSeq(guid[0]);
                lockoutInfoBuffer.WriteByteSeq(guid[1]);
                lockoutInfoBuffer.WriteByteSeq(guid[5]);
                lockoutInfoBuffer << uint32(save->GetResetTime() - currTime);
                lockoutInfoBuffer << uint32(save->GetMapId());
                lockoutInfoBuffer.WriteByteSeq(guid[2]);
                lockoutInfoBuffer.WriteByteSeq(guid[7]);
                lockoutInfoBuffer.WriteByteSeq(guid[6]);
                lockoutInfoBuffer.WriteByteSeq(guid[4]);

                ++counter;
            }
        }
    }

    data.WriteBits(invites.size(), 19);
    for (CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
    {
        CalendarEvent* calendarEvent = sCalendarMgr->GetEvent((*itr)->GetEventId());
        ObjectGuid guid = (*itr)->GetSenderGUID();
        data.WriteBit(guid[1]);
        data.WriteBit(guid[2]);
        data.WriteBit(guid[6]);
        data.WriteBit(guid[7]);
        data.WriteBit(guid[3]);
        data.WriteBit(guid[0]);
        data.WriteBit(guid[4]);
        data.WriteBit(guid[5]);

        invitesInfoBuffer.WriteByteSeq(guid[2]);
        invitesInfoBuffer << uint64((*itr)->GetInviteId());
        invitesInfoBuffer << uint8((*itr)->GetStatus());
        invitesInfoBuffer.WriteByteSeq(guid[6]);
        invitesInfoBuffer.WriteByteSeq(guid[3]);
        invitesInfoBuffer.WriteByteSeq(guid[4]);
        invitesInfoBuffer.WriteByteSeq(guid[1]);
        invitesInfoBuffer.WriteByteSeq(guid[0]);
        invitesInfoBuffer << uint64((*itr)->GetEventId());
        invitesInfoBuffer.WriteByteSeq(guid[7]);
        invitesInfoBuffer.WriteByteSeq(guid[5]);

        invitesInfoBuffer << uint8((*itr)->GetRank());
        invitesInfoBuffer << uint8((calendarEvent && calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == _player->GetGuildId()) ? 1 : 0);
    }

    data.WriteBits(playerEvents.size(), 19);
    for (CalendarEventStore::const_iterator itr = playerEvents.begin(); itr != playerEvents.end(); ++itr)
    {
        CalendarEvent* calendarEvent = *itr;
        Guild* guild = sGuildMgr->GetGuildById(calendarEvent->GetGuildId());
        ObjectGuid guildGuid = guild ? guild->GetGUID() : 0;
        ObjectGuid creatorGuid = calendarEvent->GetCreatorGUID();

        data.WriteBit(creatorGuid[2]);
        data.WriteBit(guildGuid[1]);
        data.WriteBit(guildGuid[7]);
        data.WriteBit(creatorGuid[4]);
        data.WriteBit(guildGuid[5]);
        data.WriteBit(guildGuid[6]);
        data.WriteBit(guildGuid[3]);
        data.WriteBit(guildGuid[4]);
        data.WriteBit(creatorGuid[7]);
        data.WriteBits(calendarEvent->GetTitle().size(), 8);
        data.WriteBit(creatorGuid[1]);
        data.WriteBit(guildGuid[2]);
        data.WriteBit(guildGuid[0]);
        data.WriteBit(creatorGuid[0]);
        data.WriteBit(creatorGuid[3]);
        data.WriteBit(creatorGuid[6]);
        data.WriteBit(creatorGuid[5]);

        eventsInfoBuffer.WriteByteSeq(creatorGuid[5]);
        eventsInfoBuffer.WriteByteSeq(guildGuid[3]);
        eventsInfoBuffer.WriteString(calendarEvent->GetTitle());
        eventsInfoBuffer.WriteByteSeq(guildGuid[7]);
        eventsInfoBuffer << int32(calendarEvent->GetDungeonId());
        eventsInfoBuffer.WriteByteSeq(creatorGuid[0]);
        eventsInfoBuffer.WriteByteSeq(creatorGuid[4]);
        eventsInfoBuffer.WriteByteSeq(guildGuid[2]);
        eventsInfoBuffer.WriteByteSeq(creatorGuid[7]);
        eventsInfoBuffer.WriteByteSeq(creatorGuid[2]);
        eventsInfoBuffer.AppendPackedTime(calendarEvent->GetEventTime());
        eventsInfoBuffer.WriteByteSeq(creatorGuid[3]);
        eventsInfoBuffer.WriteByteSeq(creatorGuid[1]);
        eventsInfoBuffer.WriteByteSeq(guildGuid[6]);
        eventsInfoBuffer.WriteByteSeq(guildGuid[1]);
        eventsInfoBuffer.WriteByteSeq(creatorGuid[6]);
        eventsInfoBuffer << uint32(calendarEvent->GetFlags());
        eventsInfoBuffer.WriteByteSeq(guildGuid[4]);
        eventsInfoBuffer.WriteByteSeq(guildGuid[5]);
        eventsInfoBuffer.WriteByteSeq(guildGuid[0]);
        eventsInfoBuffer << uint64(calendarEvent->GetEventId());
        eventsInfoBuffer << uint8(calendarEvent->GetType());
    }

    data.FlushBits();
    data.PutBits(lockoutPos, counter, 20);
    data.append(eventsInfoBuffer);
    data.append(lockoutInfoBuffer);
    data.append(invitesInfoBuffer);
    data.AppendPackedTime(currTime);                       // zone time

    counter = 0;
    std::set<uint32> sentMaps;
    for (ResetTimeByMapDifficultyMap::const_iterator itr = resets.begin(); itr != resets.end(); ++itr)
    {
        uint32 mapId = PAIR32_LOPART(itr->first);
        if (sentMaps.find(mapId) != sentMaps.end())
            continue;

        MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
        if (!mapEntry || !mapEntry->IsRaid())
            continue;

        sentMaps.insert(mapId);

        data << int32(mapId);
        data << int32(itr->second - currTime);
        data << int32(0); // offset => found it different only once
        counter++;
    }

    data.PutBits(resetPos, counter, 20);
    data << uint32(1135753200); // Constant date, unk (28.12.2005 07:00)
    data << uint32(currTime);   // server time

    SendPacket(&data);
}
示例#11
0
void WorldSession::SendLfgRoleCheckUpdate(const LfgRoleCheck* pRoleCheck)
{
    ASSERT(pRoleCheck);
    LfgDungeonSet dungeons;
    if (pRoleCheck->rDungeonId)
        dungeons.insert(pRoleCheck->rDungeonId);
    else
        dungeons = pRoleCheck->dungeons;

    ObjectGuid unkGuid = 0;

    sLog->outDebug(LOG_FILTER_NETWORKIO, "SMSG_LFG_ROLE_CHECK_UPDATE [" UI64FMTD "]", GetPlayer()->GetGUID());
    
    WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + dungeons.size() * 4 + 1 + pRoleCheck->roles.size() * (8 + 1 + 4 + 1));
    ByteBuffer dataBuffer;

    data.WriteBit(unkGuid[0]);
    data.WriteBit(unkGuid[1]);
    data.WriteBit(unkGuid[6]);
    data.WriteBits(pRoleCheck->roles.size(), 21);
    if (!pRoleCheck->roles.empty())
    {
        ObjectGuid guid = pRoleCheck->leader;
        uint8 roles = pRoleCheck->roles.find(guid)->second;
        Player* player = ObjectAccessor::FindPlayer(guid);

        data.WriteBit(guid[4]);
        data.WriteBit(guid[1]);
        data.WriteBit(guid[2]);
        data.WriteBit(guid[6]);
        data.WriteBit(roles > 0);
        data.WriteBit(guid[5]);
        data.WriteBit(guid[7]);
        data.WriteBit(guid[0]);
        data.WriteBit(guid[3]);

        dataBuffer << uint32(roles);                                   // Roles
        dataBuffer.WriteByteSeq(guid[0]);
        dataBuffer.WriteByteSeq(guid[2]);
        dataBuffer.WriteByteSeq(guid[5]);
        dataBuffer.WriteByteSeq(guid[4]);
        dataBuffer.WriteByteSeq(guid[7]);
        dataBuffer.WriteByteSeq(guid[6]);
        dataBuffer.WriteByteSeq(guid[1]);
        dataBuffer.WriteByteSeq(guid[3]);
        dataBuffer << uint8(player ? player->getLevel() : 0);          // Level

        for (LfgRolesMap::const_reverse_iterator it = pRoleCheck->roles.rbegin(); it != pRoleCheck->roles.rend(); ++it)
        {
            if (it->first == pRoleCheck->leader)
                continue;

            guid = it->first;
            roles = it->second;
            player = ObjectAccessor::FindPlayer(guid);

            data.WriteBit(guid[4]);
            data.WriteBit(guid[1]);
            data.WriteBit(guid[2]);
            data.WriteBit(guid[6]);
            data.WriteBit(roles > 0);
            data.WriteBit(guid[5]);
            data.WriteBit(guid[7]);
            data.WriteBit(guid[0]);
            data.WriteBit(guid[3]);

            dataBuffer << uint32(roles);                                   // Roles
            dataBuffer.WriteByteSeq(guid[0]);
            dataBuffer.WriteByteSeq(guid[2]);
            dataBuffer.WriteByteSeq(guid[5]);
            dataBuffer.WriteByteSeq(guid[4]);
            dataBuffer.WriteByteSeq(guid[7]);
            dataBuffer.WriteByteSeq(guid[6]);
            dataBuffer.WriteByteSeq(guid[1]);
            dataBuffer.WriteByteSeq(guid[3]);
            dataBuffer << uint8(player ? player->getLevel() : 0);          // Level
        }
    }

    data.WriteBit(unkGuid[7]);
    data.WriteBits(dungeons.size(), 22);
    data.WriteBit(pRoleCheck->state == LFG_ROLECHECK_INITIALITING);
    data.WriteBit(unkGuid[3]);
    data.WriteBit(unkGuid[5]);
    data.WriteBit(unkGuid[4]);
    data.WriteBit(unkGuid[2]);
    data.FlushBits();
    data.append(dataBuffer);
    data.WriteByteSeq(unkGuid[4]);
    if (!dungeons.empty())
    {
        for (LfgDungeonSet::iterator it = dungeons.begin(); it != dungeons.end(); ++it)
        {
            LFGDungeonEntry const* dungeon = sLFGDungeonStore.LookupEntry(*it);
            data << uint32(dungeon ? dungeon->Entry() : 0); // Dungeon
        }
    }
    data.WriteByteSeq(unkGuid[6]);
    data.WriteByteSeq(unkGuid[7]);
    data.WriteByteSeq(unkGuid[0]);
    data.WriteByteSeq(unkGuid[3]);
    data << uint8(1);
    data.WriteByteSeq(unkGuid[5]);
    data << uint8(pRoleCheck->state);
    data.WriteByteSeq(unkGuid[2]);
    data.WriteByteSeq(unkGuid[1]);

    SendPacket(&data);
}
示例#12
0
void WorldSession::HandleOfferPetitionOpcode(WorldPacket& recvData)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_OFFER_PETITION");

    ObjectGuid petitionGuid, playerGuid;
    uint32 type, junk;
    Player* player;

    ObjectGuid guid1;
    ObjectGuid guid2;
    recvData >> junk;                                      // this is not petition type!

    guid1[3] = recvData.ReadBit();
    guid1[2] = recvData.ReadBit();
    guid1[5] = recvData.ReadBit();
    guid2[4] = recvData.ReadBit();
    guid1[7] = recvData.ReadBit();
    guid1[6] = recvData.ReadBit();
    guid2[3] = recvData.ReadBit();
    guid2[7] = recvData.ReadBit();
    guid2[0] = recvData.ReadBit();
    guid1[4] = recvData.ReadBit();
    guid2[1] = recvData.ReadBit();
    guid2[6] = recvData.ReadBit();
    guid2[2] = recvData.ReadBit();
    guid1[1] = recvData.ReadBit();
    guid2[5] = recvData.ReadBit();
    guid1[0] = recvData.ReadBit();

    recvData.FlushBits();

    recvData.ReadByteSeq(guid2[2]);
    recvData.ReadByteSeq(guid2[3]);
    recvData.ReadByteSeq(guid2[1]);
    recvData.ReadByteSeq(guid2[5]);
    recvData.ReadByteSeq(guid2[4]);
    recvData.ReadByteSeq(guid1[7]);
    recvData.ReadByteSeq(guid2[0]);
    recvData.ReadByteSeq(guid1[2]);
    recvData.ReadByteSeq(guid1[0]);
    recvData.ReadByteSeq(guid1[6]);
    recvData.ReadByteSeq(guid2[7]);
    recvData.ReadByteSeq(guid1[1]);
    recvData.ReadByteSeq(guid1[4]);
    recvData.ReadByteSeq(guid1[3]);
    recvData.ReadByteSeq(guid1[5]);
    recvData.ReadByteSeq(guid2[6]);

    petitionGuid = guid1;
    playerGuid = guid2;

    player = ObjectAccessor::FindPlayer(playerGuid);
    if (!player)
        return;

    type = GUILD_CHARTER_TYPE;

    uint32 petitionGuidLow = GUID_LOPART(petitionGuid);

    sLog->outDebug(LOG_FILTER_NETWORKIO, "OFFER PETITION: type %u, GUID1 %u, to player id: %u", type, petitionGuidLow, GUID_LOPART(playerGuid));

    if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != player->GetTeam())
    {
        if (type == GUILD_CHARTER_TYPE)
            Guild::SendCommandResult(this, GUILD_COMMAND_CREATE, ERR_GUILD_NOT_ALLIED);
        return;
    }

    if (type == GUILD_CHARTER_TYPE)
    {
        if (player->GetGuildIdInvited())
        {
            SendPetitionSignResult(_player->GetGUID(), MAKE_NEW_GUID(petitionGuidLow, 0, HIGHGUID_ITEM), PETITION_SIGN_ALREADY_SIGNED_OTHER);
            return;
        }

        if (player->GetGuildId())
        {
            SendPetitionSignResult(_player->GetGUID(), MAKE_NEW_GUID(petitionGuidLow, 0, HIGHGUID_ITEM), PETITION_SIGN_ALREADY_IN_GUILD);
            return;
        }
    }

    auto stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_SIGNATURE);
    stmt->setUInt32(0, petitionGuidLow);
    auto result = CharacterDatabase.Query(stmt);

    typedef std::vector<uint32> storage;
    storage loParts;

    // result == NULL also correct charter without signs
    if (result)
    {
        loParts.reserve(uint32(result->GetRowCount()));

        do
        {
            auto fields = result->Fetch();
            auto loPart = fields[0].GetUInt32();
            if (GUID_LOPART(playerGuid) == loPart)
            {
                player->GetSession()->SendAlreadySigned(playerGuid);
                return;
            }

            loParts.push_back(loPart);
        }
        while (result->NextRow());
    }

    WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES);
    ByteBuffer signsBuffer;

    guid2 = _player->GetGUID();
    //ObjectGuid guid1 = petitionGuid;

    data.WriteBit(guid2[4]);
    data.WriteBit(guid1[4]);
    data.WriteBit(guid2[5]);
    data.WriteBit(guid2[0]);
    data.WriteBit(guid2[6]);
    data.WriteBit(guid1[7]);
    data.WriteBit(guid2[7]);
    data.WriteBit(guid1[0]);
    data.WriteBit(guid2[2]);
    data.WriteBit(guid2[3]);

    data.WriteBits(loParts.size(), 21);

    for (auto lowGuid : loParts)
    {
        ObjectGuid signerGuid = MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER);

        uint8 bitsSendOrder[8] = { 6, 2, 4, 5, 3, 0, 7, 1 };
        data.WriteBitInOrder(signerGuid, bitsSendOrder);

        signsBuffer.WriteByteSeq(signerGuid[4]);
        signsBuffer.WriteByteSeq(signerGuid[7]);
        signsBuffer.WriteByteSeq(signerGuid[5]);
        signsBuffer.WriteByteSeq(signerGuid[3]);
        signsBuffer.WriteByteSeq(signerGuid[2]);

        signsBuffer << uint32(0);

        signsBuffer.WriteByteSeq(signerGuid[6]);
        signsBuffer.WriteByteSeq(signerGuid[1]);
        signsBuffer.WriteByteSeq(signerGuid[0]);
    }

    data.WriteBit(guid1[5]);
    data.WriteBit(guid1[6]);
    data.WriteBit(guid1[1]);
    data.WriteBit(guid1[3]);
    data.WriteBit(guid2[1]);
    data.WriteBit(guid1[2]);

    data.FlushBits();

    data << uint32(petitionGuidLow);

    if (signsBuffer.size())
        data.append(signsBuffer);

    data.WriteByteSeq(guid1[2]);
    data.WriteByteSeq(guid2[1]);
    data.WriteByteSeq(guid2[6]);
    data.WriteByteSeq(guid1[3]);
    data.WriteByteSeq(guid2[7]);
    data.WriteByteSeq(guid1[0]);
    data.WriteByteSeq(guid2[0]);
    data.WriteByteSeq(guid2[2]);
    data.WriteByteSeq(guid1[4]);
    data.WriteByteSeq(guid1[7]);
    data.WriteByteSeq(guid1[6]);
    data.WriteByteSeq(guid2[4]);
    data.WriteByteSeq(guid2[3]);
    data.WriteByteSeq(guid2[5]);
    data.WriteByteSeq(guid1[5]);
    data.WriteByteSeq(guid1[1]);

    player->GetSession()->SendPacket(&data);
}
示例#13
0
void WorldSession::HandlePetitionShowSignOpcode(WorldPacket& recvData)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "Received opcode CMSG_PETITION_SHOW_SIGNATURES");

    uint8 signs = 0;
    ObjectGuid petitionguid;

    uint8 bitsOrder[8] = { 4, 3, 5, 6, 2, 1, 0, 7 };
    recvData.ReadBitInOrder(petitionguid, bitsOrder);

    recvData.FlushBits();

    uint8 bytesOrder[8] = { 2, 0, 3, 7, 4, 1, 5, 6 };
    recvData.ReadBytesSeq(petitionguid, bytesOrder);

    // solve (possible) some strange compile problems with explicit use GUID_LOPART(petitionguid) at some GCC versions (wrong code optimization in compiler?)
    uint32 petitionGuidLow = GUID_LOPART(petitionguid);

    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_TYPE);

    stmt->setUInt32(0, petitionGuidLow);

    PreparedQueryResult result = CharacterDatabase.Query(stmt);

    if (!result)
    {
        sLog->outDebug(LOG_FILTER_PLAYER_ITEMS, "Petition %u is not found for player %u %s", GUID_LOPART(petitionguid), GetPlayer()->GetGUIDLow(), GetPlayer()->GetName());
        return;
    }
    Field* fields = result->Fetch();
    uint32 type = fields[0].GetUInt8();

    // if guild petition and has guild => error, return;
    if (type == GUILD_CHARTER_TYPE && _player->GetGuildId())
        return;

    stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PETITION_SIGNATURE);

    stmt->setUInt32(0, petitionGuidLow);

    result = CharacterDatabase.Query(stmt);

    // result == NULL also correct in case no sign yet
    if (result)
        signs = uint8(result->GetRowCount());

    sLog->outDebug(LOG_FILTER_NETWORKIO, "CMSG_PETITION_SHOW_SIGNATURES petition entry: '%u'", petitionGuidLow);

    WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES);
    ByteBuffer signsBuffer;
    ObjectGuid guid2 = _player->GetGUID();
    ObjectGuid guid1 = petitionguid;

    data.WriteBit(guid2[4]);
    data.WriteBit(guid1[4]);
    data.WriteBit(guid2[5]);
    data.WriteBit(guid2[0]);
    data.WriteBit(guid2[6]);
    data.WriteBit(guid1[7]);
    data.WriteBit(guid2[7]);
    data.WriteBit(guid1[0]);
    data.WriteBit(guid2[2]);
    data.WriteBit(guid2[3]);
    data.WriteBits(signs, 21);

    for (uint8 i = 1; i <= signs; ++i)
    {
        Field* fields2 = result->Fetch();
        uint32 lowGuid = fields2[0].GetUInt32();

        ObjectGuid signerGuid = MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER);

        uint8 bitsSendOrder[8] = { 6, 2, 4, 5, 3, 0, 7, 1 };
        data.WriteBitInOrder(signerGuid, bitsSendOrder);

        signsBuffer.WriteByteSeq(signerGuid[4]);
        signsBuffer.WriteByteSeq(signerGuid[7]);
        signsBuffer.WriteByteSeq(signerGuid[5]);
        signsBuffer.WriteByteSeq(signerGuid[3]);
        signsBuffer.WriteByteSeq(signerGuid[2]);
        signsBuffer << uint32(0);
        signsBuffer.WriteByteSeq(signerGuid[6]);
        signsBuffer.WriteByteSeq(signerGuid[1]);
        signsBuffer.WriteByteSeq(signerGuid[0]);

        result->NextRow();
    }

    data.WriteBit(guid1[5]);
    data.WriteBit(guid1[6]);
    data.WriteBit(guid1[1]);
    data.WriteBit(guid1[3]);
    data.WriteBit(guid2[1]);
    data.WriteBit(guid1[2]);

    data.FlushBits();

    data << uint32(petitionGuidLow);

    if (signsBuffer.size())
        data.append(signsBuffer);

    data.WriteByteSeq(guid1[2]);
    data.WriteByteSeq(guid2[1]);
    data.WriteByteSeq(guid2[6]);
    data.WriteByteSeq(guid1[3]);
    data.WriteByteSeq(guid2[7]);
    data.WriteByteSeq(guid1[0]);
    data.WriteByteSeq(guid2[0]);
    data.WriteByteSeq(guid2[2]);
    data.WriteByteSeq(guid1[4]);
    data.WriteByteSeq(guid1[7]);
    data.WriteByteSeq(guid1[6]);
    data.WriteByteSeq(guid2[4]);
    data.WriteByteSeq(guid2[3]);
    data.WriteByteSeq(guid2[5]);
    data.WriteByteSeq(guid1[5]);
    data.WriteByteSeq(guid1[1]);

    SendPacket(&data);
}
    void PacketBuilder::WriteStopMovement(Vector3 const& pos, uint32 splineId, ByteBuffer& data, Unit* unit)
    {
        ObjectGuid guid = unit->GetGUID();
        ObjectGuid transport = unit->GetTransGUID();

        data << float(0.f); // Most likely transport Y
        data << uint32(splineId);
        data << float(0.f); // Most likely transport Z
        data << float(0.f); // Most likely transport X
        data << float(pos.x);
        data << float(pos.y);
        data << float(pos.z);

        data.WriteBit(guid[3]);
        data.WriteBit(1);
        data.WriteBit(guid[6]);

        data.WriteBit(1);
        data.WriteBit(1);

        data.WriteBits(MonsterMoveStop, 3);
        data.WriteBit(1);
        data.WriteBit(guid[2]);
        data.WriteBit(guid[7]);
        data.WriteBit(guid[5]);
        data.WriteBit(1);
        data.WriteBit(guid[4]);

        data.WriteBits(0, 22); // WP count
        data.WriteBit(1);
        data.WriteBit(0);

        data.WriteBit(guid[0]);
        
        uint8 transportBitsOrder[8] = {3, 6, 5, 0, 1, 2, 4, 7};
        uint8 transportBytesOrder[8] = {7, 3, 2, 0, 6, 4, 5, 1};
        data.WriteBitInOrder(transport, transportBitsOrder);

        data.WriteBit(1);
        data.WriteBit(1); // Parabolic speed // esi+4Ch
        data.WriteBit(1);

        data.WriteBits(0, 20);

        data.WriteBit(guid[1]);
        data.WriteBit(0);
        data.WriteBit(0);
        data.WriteBit(1);

        data.FlushBits();

        data.WriteByteSeq(guid[3]);
        data.WriteBytesSeq(transport, transportBytesOrder);
        data.WriteByteSeq(guid[7]);
        data.WriteByteSeq(guid[5]);
        data.WriteByteSeq(guid[1]);
        data.WriteByteSeq(guid[2]);
        data.WriteByteSeq(guid[6]);
        data.WriteByteSeq(guid[0]);
        data.WriteByteSeq(guid[4]);
    }
    void PacketBuilder::WriteStopMovement(Vector3 const& pos, uint32 splineId, ByteBuffer& data, Unit* unit)
    {

        ObjectGuid guid = unit->GetGUID();
        ObjectGuid transport = unit->GetTransGUID();

        data << float(0.f);
        data << uint32(getMSTime());
        data << float(0.f);
        data << float(0.f);
        data << float(unit->GetPositionX());
        data << float(unit->GetPositionY());
        data << float(unit->GetPositionZ());

        data.WriteBit(guid[3]);
        data.WriteBit(!unit->movespline->splineflags.raw());
        data.WriteBit(guid[6]);

        data.WriteBit(1);
        data.WriteBit(1);

        data.WriteBits(0, 3);
        data.WriteBit(1);
        data.WriteBit(guid[2]);
        data.WriteBit(guid[7]);
        data.WriteBit(guid[5]);

        data.WriteBit(1);
        data.WriteBit(guid[4]);

        data.WriteBits(0, 22); // WP count

        data.WriteBit(1);
        data.WriteBit(0);

        data.WriteBit(guid[0]);
        data.WriteBit(transport[3]);
        data.WriteBit(transport[6]);
        data.WriteBit(transport[5]);
        data.WriteBit(transport[0]);
        data.WriteBit(transport[1]);
        data.WriteBit(transport[2]);
        data.WriteBit(transport[4]);
        data.WriteBit(transport[7]);

        data.WriteBit(1);
        data.WriteBit(1); // Parabolic speed // esi+4Ch
        data.WriteBit(1);

        data.WriteBits(0, 20);

        data.WriteBit(guid[1]);
        data.WriteBit(0);
        data.WriteBit(0);
        data.WriteBit(0);

        data.FlushBits();

        data.WriteByteSeq(guid[3]);
        data.WriteByteSeq(transport[7]);
        data.WriteByteSeq(transport[3]);
        data.WriteByteSeq(transport[2]);
        data.WriteByteSeq(transport[0]);
        data.WriteByteSeq(transport[6]);
        data.WriteByteSeq(transport[5]);
        data.WriteByteSeq(transport[4]);
        data.WriteByteSeq(transport[1]);

        if (unit->movespline->splineflags.raw())
            data << uint32(unit->movespline->splineflags.raw());

        data.WriteByteSeq(guid[7]);

        data.WriteByteSeq(guid[5]);
        data.WriteByteSeq(guid[1]);
        data.WriteByteSeq(guid[2]);
        data.WriteByteSeq(guid[6]);
        data.WriteByteSeq(guid[0]);
        data.WriteByteSeq(guid[4]);
}
示例#16
0
void WorldSession::HandleQuestgiverStatusMultipleQuery(WorldPacket& /*recvPacket*/)
{
    TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_MULTIPLE_QUERY");

    uint32 count = 0;
    ByteBuffer byteData;

    WorldPacket data(SMSG_QUESTGIVER_STATUS_MULTIPLE, 3 + count * (1 + 8 + 4));

    size_t pos = data.bitwpos();
    data.WriteBits(count, 21);      // placeholder

    for (Player::ClientGUIDs::const_iterator itr = _player->m_clientGUIDs.begin(); itr != _player->m_clientGUIDs.end(); ++itr)
    {
        uint32 questStatus = DIALOG_STATUS_NONE;
        uint32 defstatus = DIALOG_STATUS_NONE;

        if (IS_CRE_OR_VEH_OR_PET_GUID(*itr))
        {
            // need also pet quests case support
            Creature* questgiver = ObjectAccessor::GetCreatureOrPetOrVehicle(*GetPlayer(), *itr);
            if (!questgiver || questgiver->IsHostileTo(_player))
                continue;
            if (!questgiver->HasFlag(UNIT_FIELD_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER))
                continue;
            questStatus = sScriptMgr->GetDialogStatus(_player, questgiver);
            if (questStatus > 6)
                questStatus = getDialogStatus(_player, questgiver, defstatus);

            ObjectGuid guid = questgiver->GetGUID();

            data.WriteBit(guid[4]);
            data.WriteBit(guid[0]);
            data.WriteBit(guid[3]);
            data.WriteBit(guid[6]);
            data.WriteBit(guid[5]);
            data.WriteBit(guid[7]);
            data.WriteBit(guid[1]);
            data.WriteBit(guid[2]);

            byteData.WriteByteSeq(guid[6]);
            byteData.WriteByteSeq(guid[2]);
            byteData.WriteByteSeq(guid[7]);
            byteData.WriteByteSeq(guid[5]);
            byteData.WriteByteSeq(guid[4]);
            byteData << uint32(questStatus);
            byteData.WriteByteSeq(guid[1]);
            byteData.WriteByteSeq(guid[3]);
            byteData.WriteByteSeq(guid[0]);

            ++count;
        }
        else if (IS_GAMEOBJECT_GUID(*itr))
        {
            GameObject* questgiver = GetPlayer()->GetMap()->GetGameObject(*itr);
            if (!questgiver)
                continue;
            if (questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER)
                continue;
            questStatus = sScriptMgr->GetDialogStatus(_player, questgiver);
            if (questStatus > 6)
                questStatus = getDialogStatus(_player, questgiver, defstatus);

            ObjectGuid guid = questgiver->GetGUID();

            data.WriteBit(guid[4]);
            data.WriteBit(guid[0]);
            data.WriteBit(guid[3]);
            data.WriteBit(guid[6]);
            data.WriteBit(guid[5]);
            data.WriteBit(guid[7]);
            data.WriteBit(guid[1]);
            data.WriteBit(guid[2]);

            byteData.WriteByteSeq(guid[6]);
            byteData.WriteByteSeq(guid[2]);
            byteData.WriteByteSeq(guid[7]);
            byteData.WriteByteSeq(guid[5]);
            byteData.WriteByteSeq(guid[4]);
            byteData << uint32(questStatus);
            byteData.WriteByteSeq(guid[1]);
            byteData.WriteByteSeq(guid[3]);
            byteData.WriteByteSeq(guid[0]);

            ++count;
        }
    }

    data.FlushBits();
    data.PutBits(pos, count, 21);
    data.append(byteData);

    SendPacket(&data);
}