Exemplo n.º 1
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);
}
Exemplo n.º 2
0
void PlayerMenu::SendQuestGiverQuestList(QEmote eEmote, const std::string& Title, uint64 npcGUID)
{
    ObjectGuid guid = npcGUID;
    ByteBuffer byteData;

    WorldPacket data(SMSG_QUESTGIVER_QUEST_LIST, 100);    // guess size
    data.WriteBits(Title.size(), 11);
    data.WriteBitSeq<2, 7>(guid);
    data.WriteBits(_questMenu.GetMenuItemCount(), 19);

    uint32 count = 0;
    for (; count < _questMenu.GetMenuItemCount(); ++count)
    {
        QuestMenuItem const& qmi = _questMenu.GetItem(count);

        uint32 questID = qmi.QuestId;

        if (Quest const* quest = sObjectMgr->GetQuestTemplate(questID))
        {
            Player* plr = _session->GetPlayer();
            std::string title = quest->GetTitle();

            int loc_idx = _session->GetSessionDbLocaleIndex();
            if (loc_idx >= 0)
                if (QuestLocale const* ql = sObjectMgr->GetQuestLocale(questID))
                    ObjectMgr::GetLocaleString(ql->Title, loc_idx, title);

            uint32 questStat = plr ? plr->GetQuestStatus(questID) : 0;

            if (questStat == QUEST_STATUS_COMPLETE || questStat == QUEST_STATUS_INCOMPLETE)
                questStat = quest->IsRepeatable() ? 0 : 4;
            else if (questStat == QUEST_STATE_NONE)
                questStat = 2;

            data.WriteBits(title.size(), 9);
            data.WriteBit(quest->IsRepeatable());

            byteData << uint32(questStat);                      // quest icon
            byteData << uint32(quest->GetFlags());              // quest flags
            byteData << uint32(questID);
            byteData << uint32(0);                              // quest flags 2
            byteData << int32(quest->GetQuestLevel());          // quest level
            byteData.WriteString(title);                        // quest title
        }
    }

    data.WriteBitSeq<5, 6, 3, 1, 0, 4>(guid);
    data.FlushBits();

    data.append(byteData);
    data << uint32(eEmote._Delay);                         // player emote
    data.WriteByteSeq<5, 7, 2, 6, 1>(guid);
    data.WriteString(Title);
    data.WriteByteSeq<3, 4>(guid);
    data << uint32(eEmote._Emote);                         // NPC emote
    data.WriteByteSeq<0>(guid);

    _session->SendPacket(&data);
    TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u", GUID_LOPART(npcGUID));
}
Exemplo n.º 3
0
	void Client::Print( const char *msg ) const {
		ByteBuffer msgBuffer;
		if ( msgBuffer.WriteString( msg ) == ByteBuffer::Error::Success ) {
			Network::XSPacket msgPacket( Network::ID_XS_SV2CL_PRINT );
			msgPacket.data = msgBuffer.GetMemory( &msgPacket.dataLen );
			connection.Send( msgPacket );
		}
	}
Exemplo n.º 4
0
bool IdleUser::Save(ByteBuffer& bb) const
{
    bb.WriteString(_name);
    bb.WriteUInt32(_id);
    bb.WriteUInt8((uint8)_type);
    bb.WriteUInt32(_elapsedTime);

    return true;
}
Exemplo n.º 5
0
ByteBuffer BytecodeHeader::GetByteBuffer()
{
  ByteBuffer buffer;

  auto bodyOffsetReservation = buffer.Reserve(4);

  // Write string constants
  buffer.WriteU32(constStringTable->constants.size());

  for (auto &key : constStringTable->constants)
    buffer.WriteString(key.val);

  // Write numeric constants
  buffer.WriteU32(constNumberTable->constants.size());

  for (auto &key : constNumberTable->constants)
    buffer.WriteU32(*reinterpret_cast<uint32_t *>(&key.val));

  buffer.WriteU32(buffer.GetLength(), bodyOffsetReservation);

  // Write function names and offsets

  return buffer;
}
Exemplo n.º 6
0
void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
{
    std::string questTitle = quest->GetTitle();
    std::string questDetails = quest->GetDetails();
    std::string questObjectives = quest->GetObjectives();
    std::string questEndText = quest->GetEndText();
    std::string questCompletedText = quest->GetCompletedText();
    std::string questGiverTextWindow = quest->GetQuestGiverTextWindow();
    std::string questGiverTargetName = quest->GetQuestGiverTargetName();
    std::string questTurnTextWindow = quest->GetQuestTurnTextWindow();
    std::string questTurnTargetName = quest->GetQuestTurnTargetName();

    /*std::string questObjectiveText[QUEST_OBJECTIVES_COUNT];
    for (uint32 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
        questObjectiveText[i] = quest->ObjectiveText[i];*/

    int32 locale = _session->GetSessionDbLocaleIndex();
    if (locale >= 0)
    {
        if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
        {
            ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
            ObjectMgr::GetLocaleString(localeData->Details, locale, questDetails);
            ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives);
            ObjectMgr::GetLocaleString(localeData->EndText, locale, questEndText);
            ObjectMgr::GetLocaleString(localeData->CompletedText, locale, questCompletedText);
            ObjectMgr::GetLocaleString(localeData->QuestGiverTextWindow, locale, questGiverTextWindow);
            ObjectMgr::GetLocaleString(localeData->QuestGiverTargetName, locale, questGiverTargetName);
            ObjectMgr::GetLocaleString(localeData->QuestTurnTextWindow, locale, questTurnTextWindow);
            ObjectMgr::GetLocaleString(localeData->QuestTurnTargetName, locale, questTurnTargetName);

            // TODO SKYBRO: Fix objective locale text
            /*for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
                ObjectMgr::GetLocaleString(localeData->ObjectiveText[i], locale, questObjectiveText[i]);*/
        }
    }

    uint32 rewChoiceItemDisplayId[QUEST_REWARD_CHOICES_COUNT];
    for (uint8 i = 0; i < QUEST_REWARD_CHOICES_COUNT; i++)
    {
        if (ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(quest->RewardChoiceItemId[i]))
            rewChoiceItemDisplayId[i] = itemTemplate->DisplayInfoID;
        else
            rewChoiceItemDisplayId[i] = 0;
    }

    WorldPacket data(SMSG_QUEST_QUERY_RESPONSE, 100);       // guess size
    data.WriteBit(1);                                       // has data
    data.WriteBits(questDetails.size(), 12);
    data.WriteBits(quest->GetQuestObjectiveCount(), 19);

    ByteBuffer objData;
    for (auto const &questObjective : quest->m_questObjectives)
    {
        data.WriteBits(questObjective->Description.size(), 8);
        data.WriteBits(questObjective->VisualEffects.size(), 22);

        objData << uint32(questObjective->Id);
        objData << uint32(questObjective->ObjectId);
        objData << uint32(questObjective->Flags);
        objData << int32(questObjective->Amount);
        objData.WriteString(questObjective->Description);
        objData << uint8(questObjective->Index);
        objData << uint8(questObjective->Type);

        for (auto const &visualEffect : questObjective->VisualEffects)
            objData << uint32(visualEffect);
    }

    data.WriteBits(questCompletedText.size(), 11);
    data.WriteBits(questGiverTargetName.size(), 8);
    data.WriteBits(questTurnTextWindow.size(), 10);
    data.WriteBits(questObjectives.size(), 12);
    data.WriteBits(questEndText.size(), 9);
    data.WriteBits(questTurnTargetName.size(), 8);
    data.WriteBits(questGiverTextWindow.size(), 10);
    data.WriteBits(questTitle.size(), 9);
    data.FlushBits();

    data << uint32(quest->RewardItemIdCount[2]);
    data << int32(quest->GetRewSpellCast());
    data << float(quest->GetRewHonorMultiplier());
    data.append(objData);
    data << uint32(quest->GetSrcItemId());
    data << uint32(0);                                              // 2965, itemSourceReq related
    data << float(quest->GetPointY());
    data.WriteString(questTurnTargetName);
    data << uint32(quest->GetNextQuestInChain());
    data.WriteString(questEndText);
    data << uint32(quest->RewardChoiceItemId[2]);

    for (uint32 i = 0; i < QUEST_REWARD_CURRENCY_COUNT; ++i)
    {
        data << uint32(quest->RewardCurrencyCount[i]);
        data << uint32(quest->RewardCurrencyId[i]);
    }

    data << uint32(quest->GetMinLevel());
    data << float(quest->GetPointX());
    data << uint32(quest->RewardItemId[3]);

    for (uint32 i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
    {
        data << uint32(quest->RewardFactionValueId[i]);
        data << uint32(quest->RewardFactionValueIdOverride[i]);
        data << uint32(quest->RewardFactionId[i]);
    }

    data << uint32(quest->GetBonusTalents());
    data << uint32(rewChoiceItemDisplayId[2]);
    data << uint32(quest->GetQuestGiverPortrait());
    data << uint32(quest->GetQuestTurnInPortrait());
    data << uint32(quest->RewardChoiceItemCount[4]);
    data << uint32(0);                                              // 2962
    data.WriteString(questTitle);
    data << uint32(quest->RewardItemIdCount[0]);
    data << uint32(0);                                              // 2964
    data << uint32(rewChoiceItemDisplayId[0]);
    data << uint32(quest->GetRewardSkillId());
    data << uint32(quest->GetMinimapTargetMark());
    data << uint32(rewChoiceItemDisplayId[3]);
    data << uint32(rewChoiceItemDisplayId[4]);
    data << uint32(quest->RewardChoiceItemCount[1]);
    data << uint32(quest->GetQuestId());
    data << uint32(quest->RewardItemId[1]);
    data << uint32(quest->RewardItemIdCount[1]);
    data << uint32(quest->RewardItemId[2]);
    data << uint32(quest->GetRewardSkillPoints());
    data << uint32(0);                                              // 2963
    data << uint32(quest->RewardChoiceItemId[1]);
    data << uint32(quest->GetRewardPackage());
    data << uint32(quest->GetRewardReputationMask());
    data.WriteString(questTurnTextWindow);
    data << uint32(quest->GetSoundTurnIn());
    data << uint32(quest->GetXPId());
    data << uint32(quest->GetFlags() & QUEST_ALLOWED_FLAGS_MASK);
    data.WriteString(questCompletedText);
    data << uint32(quest->GetQuestLevel());
    data << uint32(0);                                              // 2966
    data << uint32(quest->GetSuggestedPlayers());
    data << uint32(quest->GetPointMapId());
    data << uint32(quest->GetRewMoneyMaxLevel());
    data << uint32(0);
    data << uint32(0);                                              // 2961
    data << uint32(rewChoiceItemDisplayId[5]);
    data << uint32(quest->GetZoneOrSort());
    data << uint32(quest->RewardItemId[0]);
    data << uint32(quest->GetXPId());
    data.WriteString(questDetails);
    data << uint32(quest->RewardChoiceItemCount[0]);
    data.WriteString(questGiverTargetName);
    data << uint32(rewChoiceItemDisplayId[1]);
    data << uint32(quest->RewardChoiceItemId[0]);
    data << uint32(quest->GetQuestMethod());
    data << uint32(quest->GetRewHonorAddition());
    data << uint32(quest->GetCharTitleId());
    data.WriteString(questGiverTextWindow);
    data << uint32(quest->GetRewardMoney());
    data << uint32(quest->GetType());
    data.WriteString(questObjectives);
    data << uint32(quest->GetRewSpell());
    data << uint32(quest->RewardChoiceItemId[3]);
    data << uint32(0);                                              // 2960
    data << uint32(quest->RewardChoiceItemCount[5]);
    data << uint32(quest->RewardChoiceItemCount[3]);
    data << uint32(quest->RewardItemIdCount[3]);
    data << uint32(quest->GetSoundAccept());
    data << uint32(quest->RewardChoiceItemId[5]);
    data << uint32(0);                                              // 2959
    data << uint32(quest->RewardChoiceItemCount[2]);
    data << uint32(quest->GetPointOpt());
    data << uint32(quest->RewardChoiceItemId[4]);
    data << uint32(quest->GetQuestId());

    _session->SendPacket(&data);
    TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u", quest->GetQuestId());
}
//called when player lists his received mails
void WorldSession::HandleGetMailList(WorldPacket& recvData)
{
    ObjectGuid mailbox;

    recvData >> mailbox;

    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 << guid;

        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 << guid;
        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();
}
Exemplo n.º 8
0
void WorldSession::HandleGuildFinderBrowse(WorldPacket& recvPacket)
{
    TC_LOG_DEBUG("network", "WORLD: Received CMSG_LF_GUILD_BROWSE");

    uint32 classRoles = 0;
    uint32 availability = 0;
    uint32 guildInterests = 0;
    uint32 playerLevel = 0;

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

    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);
        packet.FlushBits();
        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);
        packet.FlushBits();
        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.WriteBitSeq<4>(guildGUID);
        data.WriteBits(guild->GetName().size(), 7);
        data.WriteBitSeq<0, 1>(guildGUID);
        data.WriteBits(guildSettings.GetComment().size(), 10);
        data.WriteBitSeq<2, 7, 3, 6, 5>(guildGUID);

        bufferData << uint8(sGuildFinderMgr->HasRequest(player->GetGUIDLow(), guild->GetGUID()));
        bufferData << uint32(guild->GetLevel());
        bufferData << uint32(guildSettings.GetInterests());
        bufferData << uint32(0);                                                                    // Unk
        bufferData << uint32(guild->GetEmblemInfo().GetBorderStyle());
        bufferData.WriteByteSeq<1, 4>(guildGUID);
        bufferData << uint32(guild->GetEmblemInfo().GetStyle());
        bufferData.WriteByteSeq<3>(guildGUID);
        bufferData << uint32(50397223);                                                             // Unk Flags
        bufferData << uint32(guild->GetEmblemInfo().GetColor());
        bufferData.WriteString(guild->GetName());
        bufferData << uint32(guildSettings.GetClassRoles());
        bufferData << uint32(guildSettings.GetAvailability());
        bufferData.WriteString(guildSettings.GetComment());
        bufferData.WriteByteSeq<6, 7>(guildGUID);
        bufferData << uint8(0);                                                                     // Cached
        bufferData.WriteByteSeq<5, 0>(guildGUID);
        bufferData << uint32(guild->GetEmblemInfo().GetBorderColor());
        bufferData << uint32(guild->GetMembersCount());
        bufferData << uint32(guild->GetAchievementMgr().GetAchievementPoints());
        bufferData.WriteByteSeq<2>(guildGUID);
        bufferData << int32(guild->GetEmblemInfo().GetBackgroundColor());
    }

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

    player->SendDirectMessage(&data);
}
Exemplo n.º 9
0
void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
{
    std::string questTitle = quest->GetTitle();
    std::string questDetails = quest->GetDetails();
    std::string questObjectives = quest->GetObjectives();
    std::string questEndText = quest->GetEndText();
    std::string questCompletedText = quest->GetCompletedText();
    std::string questGiverTextWindow = quest->GetQuestGiverTextWindow();
    std::string questGiverTargetName = quest->GetQuestGiverTargetName();
    std::string questTurnTextWindow = quest->GetQuestTurnTextWindow();
    std::string questTurnTargetName = quest->GetQuestTurnTargetName();

    int32 locale = _session->GetSessionDbLocaleIndex();
    if (locale >= 0)
    {
        if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
        {
            ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
            ObjectMgr::GetLocaleString(localeData->Details, locale, questDetails);
            ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives);
            ObjectMgr::GetLocaleString(localeData->EndText, locale, questEndText);
            ObjectMgr::GetLocaleString(localeData->CompletedText, locale, questCompletedText);
            ObjectMgr::GetLocaleString(localeData->QuestGiverTextWindow, locale, questGiverTextWindow);
            ObjectMgr::GetLocaleString(localeData->QuestGiverTargetName, locale, questGiverTargetName);
            ObjectMgr::GetLocaleString(localeData->QuestTurnTextWindow, locale, questTurnTextWindow);
            ObjectMgr::GetLocaleString(localeData->QuestTurnTargetName, locale, questTurnTargetName);
        }
    }

    if (sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS))
        AddQuestLevelToTitle(questTitle, quest->GetQuestLevel());

    WorldPacket data(SMSG_QUEST_QUERY_RESPONSE, 100);   // guess size
    data << uint32(quest->GetQuestId());

    data.WriteBit(1);                                   // has data
    data.WriteBits(questTurnTextWindow.size(), 10);
    data.WriteBits(questTitle.size(), 9);
    data.WriteBits(questCompletedText.size(), 11);
    data.WriteBits(questDetails.size(), 12);
    data.WriteBits(questTurnTargetName.size(), 8);
    data.WriteBits(questGiverTargetName.size(), 8);
    data.WriteBits(questGiverTextWindow.size(), 10);
    data.WriteBits(questEndText.size(), 9);
    data.WriteBits(quest->m_questObjectives.size(), 19);
    data.WriteBits(questObjectives.size(), 12);

    ByteBuffer objData;
    for (QuestObjectiveSet::const_iterator citr = quest->m_questObjectives.begin(); citr != quest->m_questObjectives.end(); citr++)
    {
        QuestObjective const* questObjective = *citr;

        std::string descriptionText = questObjective->Description;
        if (locale > 0)
            if (QuestObjectiveLocale const* questObjectiveLocale = sObjectMgr->GetQuestObjectiveLocale(questObjective->Id))
                ObjectMgr::GetLocaleString(questObjectiveLocale->Description, locale, descriptionText);

        data.WriteBits(descriptionText.size(), 8);
        data.WriteBits(questObjective->VisualEffects.size(), 22);

        objData << int32(questObjective->Amount);
        objData << uint32(questObjective->Id);
        objData.WriteString(descriptionText);
        objData << uint32(questObjective->Flags);
        objData << uint8(questObjective->Index);
        objData << uint8(questObjective->Type);
        objData << uint32(questObjective->ObjectId);

        for (VisualEffectVec::const_iterator citrEffects = questObjective->VisualEffects.begin(); citrEffects != questObjective->VisualEffects.end(); citrEffects++)
            objData << uint32(*citrEffects);
    }

    data.FlushBits();

    bool hiddenReward = quest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS);

    // values need rechecking and zero values need more research
    data.append(objData);
    data << uint32(quest->RequiredSourceItemId[0]);
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemId[4]);
    data << uint32(hiddenReward ? 0 : quest->RewardItemId[3]);
    data << uint32(hiddenReward ? 0 : quest->RewardItemIdCount[1]);
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemCount[2]);

    for (uint32 i = 0; i < QUEST_REWARD_CURRENCY_COUNT; i++)
    {
        data << uint32(quest->RewardCurrencyId[i]);
        data << uint32(quest->RewardCurrencyCount[i]);
    }

    data << uint32(quest->GetBonusTalents());                               // bonus talents
    data << float(quest->GetPointY());
    data << uint32(quest->GetSoundTurnIn());

    for (int i = 0; i < QUEST_REPUTATIONS_COUNT; i++)
    {
        data << uint32(quest->RewardFactionValueId[i]);                     // columnid+1 QuestFactionReward.dbc?
        data << uint32(quest->RewardFactionValueIdOverride[i]);             // unknown usage
        data << uint32(quest->RewardFactionId[i]);                          // reward factions ids
    }

    data << uint32(hiddenReward ? 0 : quest->GetRewMoney());                // reward money (below max lvl)
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemCount[4]);
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemCount[1]);
    data << uint32(quest->GetFlags2());
    data.WriteString(questEndText);
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemId[1]);
    data << uint32(quest->GetRewMoneyMaxLevel());                           // used in XP calculation at client
    data << uint32(hiddenReward ? 0 : quest->RewardItemId[0]);
    data.WriteString(questCompletedText);
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemId[3]);
    data << uint32(quest->GetRewHonorAddition());                           // rewarded honor points
    data.WriteString(questGiverTextWindow);
    data.WriteString(questObjectives);
    data << uint32(quest->GetRewardSkillPoints());                          // reward skill points
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemId[5]);
    data << uint32(quest->GetSuggestedPlayers());                           // suggested players count
    data << uint32(quest->GetQuestId());                                    // quest id
    data << uint32(quest->RequiredSourceItemId[1]);
    data << uint32(hiddenReward ? 0 : quest->RewardItemId[1]);
    data << int32(quest->GetMinLevel());                                    // min level
    data << uint32(quest->GetRewardReputationMask());                       // rep mask (unsure on what it does)
    data << uint32(quest->GetPointOpt());
    data << int32(quest->GetQuestLevel());                                  // may be -1, static data, in other cases must be used dynamic level: Player::GetQuestLevel (0 is not known, but assuming this is no longer valid for quest intended for client)
    data << uint32(quest->GetQuestMethod());                                // Accepted values: 0, 1 or 2. 0 == IsAutoComplete() (skip objectives/details)
    data << uint32(quest->RequiredSourceItemCount[2]);
    data << uint32(quest->GetXPId());                                       // seems to always have the same value as the first XP ID field
    data.WriteString(questDetails);
    data << uint32(hiddenReward ? 0 : quest->RewardItemIdCount[0]);
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemCount[5]);
    data << uint32(hiddenReward ? 0 : quest->RewardItemIdCount[2]);
    data << uint32(quest->GetRewSpellCast());                               // casted spell
    data << uint32(0);                                                      // unknown
    data.WriteString(questTurnTargetName);
    data << uint32(0);                                                      // unknown
    data << uint32(quest->RequiredSourceItemCount[1]);
    data << uint32(quest->RequiredSourceItemId[2]);
    data << uint32(quest->GetQuestTurnInPortrait());
    data.WriteString(questTitle);
    data << uint32(quest->GetType());                                       // quest type
    data << uint32(quest->GetXPId());                                       // used for calculating rewarded experience
    data << uint32(0);                                                      // unknown
    data << uint32(0);                                                      // unknown
    data << uint32(quest->GetPointMapId());
    data << uint32(quest->GetNextQuestInChain());                           // client will request this quest from NPC, if not 0
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemId[0]);
    data.WriteString(questGiverTargetName);
    data << uint32(0);                                                      // unknown
    data << uint32(quest->RequiredSourceItemId[3]);
    data << float(quest->GetPointX());
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemId[2]);
    data << uint32(0);                                                      // unknown
    data << uint32(hiddenReward ? 0 : quest->RewardItemIdCount[3]);
    data << uint32(quest->GetSoundAccept());
    data << uint32(hiddenReward ? 0 : quest->RewardItemId[2]);
    data << float(quest->GetRewHonorMultiplier());
    data << uint32(quest->GetCharTitleId());                                // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
    data.WriteString(questTurnTextWindow);
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemCount[3]);
    data << uint32(quest->RequiredSourceItemCount[0]);
    data << int32(quest->GetZoneOrSort());                                  // zone or sort to display in quest log
    data << uint32(quest->GetRewardSkillId());                              // reward skill id
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemCount[0]);
    data << uint32(quest->GetRewSpell());                                   // reward spell, this spell will display (icon) (casted if RewSpellCast == 0)
    data << uint32(quest->GetQuestGiverPortrait());
    data << uint32(0);                                                      // unknown
    data << uint32(quest->RequiredSourceItemCount[3]);
    data << uint32(quest->GetFlags() & 0xFFFF);                             // quest flags
    data << uint32(quest->GetRewardPackageItemId());
    data << uint32(quest->GetSrcItemId());                                  // source item id

    _session->SendPacket(&data);

    TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u", quest->GetQuestId());
}
Exemplo n.º 10
0
void PlayerMenu::SendQuestGiverQuestList(QEmote eEmote, const std::string& Title, uint64 npcGUID)
{
    ByteBuffer questData;
    ObjectGuid guid = npcGUID;

    WorldPacket data(SMSG_QUESTGIVER_QUEST_LIST, 100);      // guess size
    data << uint32(eEmote._Emote);                          // NPC emote
    data << uint32(eEmote._Delay);                          // player emote

    data.WriteBit(guid[2]);
    data.WriteBits(Title.size(), 11);
    data.WriteBit(guid[6]);
    data.WriteBit(guid[0]);

    uint32 count = 0;
    size_t countPos = data.bitwpos();
    data.WriteBits(count, 19);

    // Store this instead of checking the Singleton every loop iteration
    bool questLevelInTitle = sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS);

    for (uint32 i = 0; i < _questMenu.GetMenuItemCount(); ++i)
    {
        QuestMenuItem const& qmi = _questMenu.GetItem(i);

        uint32 questID = qmi.QuestId;

        if (Quest const* quest = sObjectMgr->GetQuestTemplate(questID))
        {
            ++count;
            std::string title = quest->GetTitle();

            int32 locale = _session->GetSessionDbLocaleIndex();
            if (locale >= 0)
                if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID))
                    ObjectMgr::GetLocaleString(localeData->Title, locale, title);

            if (questLevelInTitle)
                AddQuestLevelToTitle(title, quest->GetQuestLevel());

            data.WriteBit(0);                               // unknown bit
            data.WriteBits(title.size(), 9);

            questData << uint32(quest->GetFlags());
            questData << uint32(questID);
            questData.WriteString(title);
            questData << uint32(quest->GetFlags2());
            questData << uint32(qmi.QuestIcon);
            questData << uint32(quest->GetQuestLevel());
        }
    }

    data.WriteBit(guid[1]);
    data.WriteBit(guid[3]);
    data.WriteBit(guid[4]);
    data.WriteBit(guid[5]);
    data.WriteBit(guid[7]);
    data.PutBits(countPos, count, 19);
    data.FlushBits();

    data.WriteByteSeq(guid[1]);
    data.WriteByteSeq(guid[0]);
    data.WriteByteSeq(guid[6]);
    data.WriteByteSeq(guid[7]);
    data.append(questData);
    data.WriteByteSeq(guid[5]);
    data.WriteByteSeq(guid[3]);
    data.WriteByteSeq(guid[2]);
    data.WriteString(Title);
    data.WriteByteSeq(guid[4]);

    _session->SendPacket(&data);

    TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUESTGIVER_QUEST_LIST NPC Guid=%u", GUID_LOPART(npcGUID));
}
Exemplo n.º 11
0
void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
{
    std::string questTitle = quest->GetTitle();
    std::string questDetails = quest->GetDetails();
    std::string questObjectives = quest->GetObjectives();
    std::string questEndText = quest->GetEndText();
    std::string questCompletedText = quest->GetCompletedText();
    std::string questGiverTextWindow = quest->GetQuestGiverTextWindow();
    std::string questGiverTargetName = quest->GetQuestGiverTargetName();
    std::string questTurnTextWindow = quest->GetQuestTurnTextWindow();
    std::string questTurnTargetName = quest->GetQuestTurnTargetName();

    std::string questObjectiveText[QUEST_OBJECTIVES_COUNT];
    for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
        questObjectiveText[i] = quest->ObjectiveText[i];

    int32 locale = _session->GetSessionDbLocaleIndex();
    if (locale >= 0)
    {
        if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
        {
            ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
            ObjectMgr::GetLocaleString(localeData->Details, locale, questDetails);
            ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives);
            ObjectMgr::GetLocaleString(localeData->EndText, locale, questEndText);
            ObjectMgr::GetLocaleString(localeData->CompletedText, locale, questCompletedText);
            ObjectMgr::GetLocaleString(localeData->QuestGiverTextWindow, locale, questGiverTextWindow);
            ObjectMgr::GetLocaleString(localeData->QuestGiverTargetName, locale, questGiverTargetName);
            ObjectMgr::GetLocaleString(localeData->QuestTurnTextWindow, locale, questTurnTextWindow);
            ObjectMgr::GetLocaleString(localeData->QuestTurnTargetName, locale, questTurnTargetName);

            for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
                ObjectMgr::GetLocaleString(localeData->ObjectiveText[i], locale, questObjectiveText[i]);
        }
    }

    if (sWorld->getBoolConfig(CONFIG_UI_QUESTLEVELS_IN_DIALOGS))
        AddQuestLevelToTitle(questTitle, quest->GetQuestLevel());

    WorldPacket data(SMSG_QUEST_QUERY_RESPONSE, 100);   // guess size
    data << uint32(quest->GetQuestId());

    data.WriteBit(1);                                   // has data
    data.WriteBits(questTurnTextWindow.size(), 10);
    data.WriteBits(questTitle.size(), 9);
    data.WriteBits(questCompletedText.size(), 11);
    data.WriteBits(questDetails.size(), 12);
    data.WriteBits(questTurnTargetName.size(), 8);
    data.WriteBits(questGiverTargetName.size(), 8);
    data.WriteBits(questGiverTextWindow.size(), 10);
    data.WriteBits(questEndText.size(), 9);

    size_t objPos = data.bitwpos();
    data.WriteBits(0, 19);
    data.WriteBits(questObjectives.size(), 12);

    /*
     *  -- Objective Structure --
     *  -- Bits --
     *  bits22 - unknown counter
     *  bits8  - objective text length
     *  -- Bytes --
     *  uint32 - unknown
     *  string - objective text (WoW string, not null terminated and no length prefix)
     *  uint8  - objective type (see QuestObjectiveType enum)
     *  uint8  - objective index
     *  int32  - objective count (value required to complete objective)
     *  uint   - unknown
     *  uint   - objective Id (NPC, GO, item, spell, currency or faction Id)
     */

    ByteBuffer objData;
    uint8 objCount = 0;

    for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++)
    {
        if (quest->RequiredNpcOrGo[i] != 0)
        {
            int32 requiredObjId = quest->RequiredNpcOrGo[i];

            data.WriteBits(questObjectiveText[i].size(), 8);
            data.WriteBits(0, 22);

            objData << int32(quest->RequiredNpcOrGoCount[i]);
            objData << uint32(0);
            objData.WriteString(questObjectiveText[i]);
            objData << uint32(0);
            objData << uint8(objCount);
            objData << uint8(requiredObjId < 0 ? QUEST_OBJECTIVE_TYPE_GO : QUEST_OBJECTIVE_TYPE_NPC);
            objData << uint32(requiredObjId < 0 ? requiredObjId * -1 : requiredObjId);

            objCount++;
        }
    }

    for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++)
    {
        if (quest->RequiredItemId[i] != 0)
        {
            // better way of doing this?
            std::string objText = i < 4 ? questObjectiveText[i] : "";

            data.WriteBits(objText.size(), 8);
            data.WriteBits(0, 22);

            objData << int32(quest->RequiredItemCount[i]);
            objData << uint32(0);
            objData.WriteString(objText);
            objData << uint32(0);
            objData << uint8(objCount);
            objData << uint8(QUEST_OBJECTIVE_TYPE_ITEM);
            objData << uint32(quest->RequiredItemId[i]);

            objCount++;
        }
    }

    for (uint8 i = 0; i < QUEST_REQUIRED_CURRENCY_COUNT; i++)
    {
        if (quest->RequiredCurrencyId[i] != 0)
        {
            data.WriteBits(0, 8);
            data.WriteBits(0, 22);

            objData << int32(quest->RequiredCurrencyCount[i]);
            objData << uint32(0);
            objData << uint32(0);
            objData << uint8(0xFF);
            objData << uint8(QUEST_OBJECTIVE_TYPE_CURRENCY);
            objData << uint32(quest->RequiredCurrencyId[i]);

            objCount++;
        }
    }

    if (quest->GetRequiredSpell() != 0)
    {
        data.WriteBits(questObjectiveText[objCount].size(), 8);
        data.WriteBits(0, 22);

        objData << int32(1);
        objData << uint32(0);
        objData.WriteString(questObjectiveText[objCount]);
        objData << uint32(0);
        objData << uint8(0xFF);
        objData << uint8(QUEST_OBJECTIVE_TYPE_SPELL);
        objData << uint32(quest->GetRequiredSpell());

        objCount++;
    }

    if (quest->GetRepObjectiveFaction() != 0)
    {
        data.WriteBits(0, 8);
        data.WriteBits(0, 22);

        objData << int32(quest->GetRepObjectiveValue());
        objData << uint32(0);
        objData << uint32(0);
        objData << uint8(0xFF);
        objData << uint8(QUEST_OBJECTIVE_TYPE_FACTION_REP);
        objData << uint32(quest->GetRepObjectiveFaction());

        objCount++;
    }

    if (quest->GetRepObjectiveFaction2() != 0)
    {
        data.WriteBits(0, 8);
        data.WriteBits(0, 22);

        objData << int32(quest->GetRepObjectiveValue2());
        objData << uint32(0);
        objData << uint32(0);
        objData << uint8(0xFF);
        objData << uint8(QUEST_OBJECTIVE_TYPE_FACTION_REP2);
        objData << uint32(quest->GetRepObjectiveFaction2());

        objCount++;
    }

    // only seen in quests 13233 (No Mercy!) and 13234 (Make Them Pay!)
    if (quest->GetPlayersSlain() != 0)
    {
        data.WriteBits(0, 8);
        data.WriteBits(0, 22);

        objData << int32(quest->GetPlayersSlain());
        objData << uint32(0);
        objData << uint32(0);
        objData << uint8(objCount);
        objData << uint8(QUEST_OBJECTIVE_TYPE_PLAYER);
        objData << uint32(0x149);   // unsure on this value

        objCount++;
    }

    if (objCount > 0)
        data.PutBits(objPos, objCount, 19);

    data.FlushBits();

    bool hiddenReward = quest->HasFlag(QUEST_FLAGS_HIDDEN_REWARDS);

    // values need rechecking and zero values need more research
    data.append(objData);
    data << uint32(quest->RequiredSourceItemId[0]);
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemId[4]);
    data << uint32(hiddenReward ? 0 : quest->RewardItemId[3]);
    data << uint32(hiddenReward ? 0 : quest->RewardItemIdCount[1]);
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemCount[2]);

    for (uint32 i = 0; i < QUEST_REWARD_CURRENCY_COUNT; i++)
    {
        data << uint32(quest->RewardCurrencyId[i]);
        data << uint32(quest->RewardCurrencyCount[i]);
    }

    data << uint32(quest->GetBonusTalents());                               // bonus talents
    data << float(quest->GetPointY());
    data << uint32(quest->GetSoundTurnIn());

    for (int i = 0; i < QUEST_REPUTATIONS_COUNT; i++)
    {
        data << uint32(quest->RewardFactionValueId[i]);                     // columnid+1 QuestFactionReward.dbc?
        data << uint32(quest->RewardFactionValueIdOverride[i]);             // unknown usage
        data << uint32(quest->RewardFactionId[i]);                          // reward factions ids
    }

    data << uint32(hiddenReward ? 0 : quest->GetRewOrReqMoney());           // reward money (below max lvl)
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemCount[4]);
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemCount[1]);
    data << uint32(quest->GetFlags2());
    data.WriteString(questEndText);
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemId[1]);
    data << uint32(quest->GetRewMoneyMaxLevel());                           // used in XP calculation at client
    data << uint32(hiddenReward ? 0 : quest->RewardItemId[0]);
    data.WriteString(questCompletedText);
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemId[3]);
    data << uint32(quest->GetRewHonorAddition());                           // rewarded honor points
    data.WriteString(questGiverTextWindow);
    data.WriteString(questObjectives);
    data << uint32(quest->GetRewardSkillPoints());                          // reward skill points
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemId[5]);
    data << uint32(quest->GetSuggestedPlayers());                           // suggested players count
    data << uint32(quest->GetQuestId());                                    // quest id
    data << uint32(quest->RequiredSourceItemId[1]);
    data << uint32(hiddenReward ? 0 : quest->RewardItemId[1]);
    data << int32(quest->GetMinLevel());                                    // min level
    data << uint32(quest->GetRewardReputationMask());                       // rep mask (unsure on what it does)
    data << uint32(quest->GetPointOpt());
    data << int32(quest->GetQuestLevel());                                  // may be -1, static data, in other cases must be used dynamic level: Player::GetQuestLevel (0 is not known, but assuming this is no longer valid for quest intended for client)
    data << uint32(quest->GetQuestMethod());                                // Accepted values: 0, 1 or 2. 0 == IsAutoComplete() (skip objectives/details)
    data << uint32(quest->RequiredSourceItemCount[2]);
    data << uint32(quest->GetXPId());                                       // seems to always have the same value as the first XP ID field
    data.WriteString(questDetails);
    data << uint32(hiddenReward ? 0 : quest->RewardItemIdCount[0]);
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemCount[5]);
    data << uint32(hiddenReward ? 0 : quest->RewardItemIdCount[2]);
    data << uint32(quest->GetRewSpellCast());                               // casted spell
    data << uint32(0);                                                      // unknown
    data.WriteString(questTurnTargetName);
    data << uint32(0);                                                      // unknown
    data << uint32(quest->RequiredSourceItemCount[1]);
    data << uint32(quest->RequiredSourceItemId[2]);
    data << uint32(quest->GetQuestTurnInPortrait());
    data.WriteString(questTitle);
    data << uint32(quest->GetType());                                       // quest type
    data << uint32(quest->GetXPId());                                       // used for calculating rewarded experience
    data << uint32(0);                                                      // unknown
    data << uint32(0);                                                      // unknown
    data << uint32(quest->GetPointMapId());
    data << uint32(quest->GetNextQuestInChain());                           // client will request this quest from NPC, if not 0
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemId[0]);
    data.WriteString(questGiverTargetName);
    data << uint32(0);                                                      // unknown
    data << uint32(quest->RequiredSourceItemId[3]);
    data << float(quest->GetPointX());
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemId[2]);
    data << uint32(0);                                                      // unknown
    data << uint32(hiddenReward ? 0 : quest->RewardItemIdCount[3]);
    data << uint32(quest->GetSoundAccept());
    data << uint32(hiddenReward ? 0 : quest->RewardItemId[2]);
    data << float(quest->GetRewHonorMultiplier());
    data << uint32(quest->GetCharTitleId());                                // CharTitleId, new 2.4.0, player gets this title (id from CharTitles)
    data.WriteString(questTurnTextWindow);
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemCount[3]);
    data << uint32(quest->RequiredSourceItemCount[0]);
    data << int32(quest->GetZoneOrSort());                                  // zone or sort to display in quest log
    data << uint32(quest->GetRewardSkillId());                              // reward skill id
    data << uint32(hiddenReward ? 0 : quest->RewardChoiceItemCount[0]);
    data << uint32(quest->GetRewSpell());                                   // reward spell, this spell will display (icon) (casted if RewSpellCast == 0)
    data << uint32(quest->GetQuestGiverPortrait());
    data << uint32(0);                                                      // unknown
    data << uint32(quest->RequiredSourceItemCount[3]);
    data << uint32(quest->GetFlags() & 0xFFFF);                             // quest flags
    data << uint32(quest->GetRewardPackageItemId());
    data << uint32(quest->GetSrcItemId());                                  // source item id

    /*
     *  -- Missing Values from Cata could be an unknown --
     *  quest->GetMinimapTargetMark()
     *  quest->GetRewArenaPoints()
     *  quest->GetSrcItemCount()
     */

    _session->SendPacket(&data);
    TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUEST_QUERY_RESPONSE questid=%u", quest->GetQuestId());
}
Exemplo n.º 12
0
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);
}