@@ -3780,7 +3780,7 @@ bool Player::ResetTalents(bool involuntarily /*= false*/)
37803780 SetFreeTalentPoints(talentPointsForLevel);
37813781
37823782 if (involuntarily)
3783- SendDirectMessage(WorldPackets::Talents ::InvoluntarilyReset(false).Write());
3783+ SendDirectMessage(WorldPackets::Talent ::InvoluntarilyReset(false).Write());
37843784
37853785 return true;
37863786}
@@ -9179,7 +9179,7 @@ void Player::SetBindPoint(ObjectGuid guid) const
91799179
91809180void Player::SendTalentWipeConfirm(ObjectGuid trainerGuid) const
91819181{
9182- SendDirectMessage(WorldPackets::Talents ::RespecWipeConfirm(trainerGuid, ResetTalentsCost()).Write());
9182+ SendDirectMessage(WorldPackets::Talent ::RespecWipeConfirm(trainerGuid, ResetTalentsCost()).Write());
91839183}
91849184
91859185void Player::ResetPetTalents()
@@ -25275,11 +25275,11 @@ bool Player::CanSeeSpellClickOn(Creature const* c) const
2527525275 return false;
2527625276}
2527725277
25278- void Player::BuildPlayerTalentsInfoData(WorldPacket* data )
25278+ void Player::BuildPlayerTalentsInfoData(WorldPackets::Talent::TalentInfoUpdate& talentInfo )
2527925279{
25280- *data << uint32( GetFreeTalentPoints()); // unspentTalentPoints
25281- *data << uint8 (GetSpecsCount()); // talent group count (0, 1 or 2)
25282- *data << uint8( GetActiveSpec()); // talent group index (0 or 1)
25280+ talentInfo.UnspentTalentPoints = GetFreeTalentPoints(); // unspentTalentPoints
25281+ talentInfo.TalentGroups.resize (GetSpecsCount()); // talent group count (0, 1 or 2)
25282+ talentInfo.ActiveGroup = GetActiveSpec(); // talent group index (0 or 1)
2528325283
2528425284 if (GetSpecsCount())
2528525285 {
@@ -25289,9 +25289,7 @@ void Player::BuildPlayerTalentsInfoData(WorldPacket* data)
2528925289 // loop through all specs (only 1 for now)
2529025290 for (uint32 specIdx = 0; specIdx < GetSpecsCount(); ++specIdx)
2529125291 {
25292- uint8 talentIdCount = 0;
25293- size_t pos = data->wpos();
25294- *data << uint8(talentIdCount); // [PH], talentIdCount
25292+ WorldPackets::Talent::TalentGroupInfo& talentGroupInfo = talentInfo.TalentGroups[specIdx];
2529525293
2529625294 // find class talent tabs (all players have 3 talent tabs)
2529725295 uint32 const* talentTabIds = GetTalentTabPages(GetClass());
@@ -25302,19 +25300,19 @@ void Player::BuildPlayerTalentsInfoData(WorldPacket* data)
2530225300
2530325301 for (uint32 talentId = 0; talentId < sTalentStore.GetNumRows(); ++talentId)
2530425302 {
25305- TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId);
25306- if (!talentInfo )
25303+ TalentEntry const* talent = sTalentStore.LookupEntry(talentId);
25304+ if (!talent )
2530725305 continue;
2530825306
2530925307 // skip another tab talents
25310- if (talentInfo ->TabID != talentTabId)
25308+ if (talent ->TabID != talentTabId)
2531125309 continue;
2531225310
2531325311 // find max talent rank (0~4)
2531425312 int8 curtalent_maxrank = -1;
25315- for (int8 rank = MAX_TALENT_RANK- 1; rank >= 0; --rank)
25313+ for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank)
2531625314 {
25317- if (talentInfo ->SpellRank[rank] && HasTalent(talentInfo ->SpellRank[rank], specIdx))
25315+ if (talent ->SpellRank[rank] && HasTalent(talent ->SpellRank[rank], specIdx))
2531825316 {
2531925317 curtalent_maxrank = rank;
2532025318 break;
@@ -25325,40 +25323,23 @@ void Player::BuildPlayerTalentsInfoData(WorldPacket* data)
2532525323 if (curtalent_maxrank < 0)
2532625324 continue;
2532725325
25328- *data << uint32(talentInfo->ID); // Talent.dbc
25329- *data << uint8(curtalent_maxrank); // talentMaxRank (0-4)
25330-
25331- ++talentIdCount;
25326+ talentGroupInfo.Talents.push_back({ .TalentID = talent->ID, .Rank = curtalent_maxrank });
2533225327 }
2533325328 }
2533425329
25335- data->put<uint8>(pos, talentIdCount); // put real count
25336-
25337- *data << uint8(MAX_GLYPH_SLOT_INDEX); // glyphs count
25338-
2533925330 for (uint8 i = 0; i < MAX_GLYPH_SLOT_INDEX; ++i)
25340- *data << uint16( GetGlyph(specIdx, i)); // GlyphProperties.dbc
25331+ talentGroupInfo.GlyphIDs[i] = GetGlyph(specIdx, i); // GlyphProperties.dbc
2534125332 }
2534225333 }
2534325334}
2534425335
25345- void Player::BuildPetTalentsInfoData(WorldPacket* data)
25336+ void Player::BuildPetTalentsInfoData(WorldPackets::Talent::PetTalentInfoUpdate& petTalentInfo) const
2534625337{
25347- uint32 unspentTalentPoints = 0;
25348- size_t pointsPos = data->wpos();
25349- *data << uint32(unspentTalentPoints); // [PH], unspentTalentPoints
25350-
25351- uint8 talentIdCount = 0;
25352- size_t countPos = data->wpos();
25353- *data << uint8(talentIdCount); // [PH], talentIdCount
25354-
2535525338 Pet* pet = GetPet();
2535625339 if (!pet)
2535725340 return;
2535825341
25359- unspentTalentPoints = pet->GetFreeTalentPoints();
25360-
25361- data->put<uint32>(pointsPos, unspentTalentPoints); // put real points
25342+ petTalentInfo.UnspentTalentPoints = pet->GetFreeTalentPoints();
2536225343
2536325344 CreatureTemplate const* ci = pet->GetCreatureTemplate();
2536425345 if (!ci)
@@ -25379,19 +25360,19 @@ void Player::BuildPetTalentsInfoData(WorldPacket* data)
2537925360
2538025361 for (uint32 talentId = 0; talentId < sTalentStore.GetNumRows(); ++talentId)
2538125362 {
25382- TalentEntry const* talentInfo = sTalentStore.LookupEntry(talentId);
25383- if (!talentInfo )
25363+ TalentEntry const* talent = sTalentStore.LookupEntry(talentId);
25364+ if (!talent )
2538425365 continue;
2538525366
2538625367 // skip another tab talents
25387- if (talentInfo ->TabID != talentTabId)
25368+ if (talent ->TabID != talentTabId)
2538825369 continue;
2538925370
2539025371 // find max talent rank (0~4)
2539125372 int8 curtalent_maxrank = -1;
25392- for (int8 rank = MAX_TALENT_RANK- 1; rank >= 0; --rank)
25373+ for (int8 rank = MAX_TALENT_RANK - 1; rank >= 0; --rank)
2539325374 {
25394- if (talentInfo ->SpellRank[rank] && pet->HasSpell(talentInfo ->SpellRank[rank]))
25375+ if (talent ->SpellRank[rank] && pet->HasSpell(talent ->SpellRank[rank]))
2539525376 {
2539625377 curtalent_maxrank = rank;
2539725378 break;
@@ -25402,70 +25383,23 @@ void Player::BuildPetTalentsInfoData(WorldPacket* data)
2540225383 if (curtalent_maxrank < 0)
2540325384 continue;
2540425385
25405- *data << uint32(talentInfo->ID); // Talent.dbc
25406- *data << uint8(curtalent_maxrank); // talentMaxRank (0-4)
25407-
25408- ++talentIdCount;
25386+ petTalentInfo.Talents.push_back({ .TalentID = talent->ID, .Rank = curtalent_maxrank });
2540925387 }
2541025388
25411- data->put<uint8>(countPos, talentIdCount); // put real count
25412-
2541325389 break;
2541425390 }
2541525391}
2541625392
2541725393void Player::SendTalentsInfoData(bool pet)
2541825394{
25419- WorldPacket data(SMSG_TALENTS_INFO, 50) ;
25420- data << uint8(pet ? 1 : 0);
25395+ WorldPackets::Talent::UpdateTalentData updateTalentData ;
25396+
2542125397 if (pet)
25422- BuildPetTalentsInfoData(&data );
25398+ BuildPetTalentsInfoData(updateTalentData.Info.emplace<1>() );
2542325399 else
25424- BuildPlayerTalentsInfoData(&data);
25425- SendDirectMessage(&data);
25426- }
25427-
25428- void Player::BuildEnchantmentsInfoData(WorldPacket* data)
25429- {
25430- uint32 slotUsedMask = 0;
25431- size_t slotUsedMaskPos = data->wpos();
25432- *data << uint32(slotUsedMask); // slotUsedMask < 0x80000
25433-
25434- for (uint32 i = 0; i < EQUIPMENT_SLOT_END; ++i)
25435- {
25436- Item* item = GetItemByPos(INVENTORY_SLOT_BAG_0, i);
25437-
25438- if (!item)
25439- continue;
25440-
25441- slotUsedMask |= (1 << i);
25442-
25443- *data << uint32(item->GetEntry()); // item entry
25444-
25445- uint16 enchantmentMask = 0;
25446- size_t enchantmentMaskPos = data->wpos();
25447- *data << uint16(enchantmentMask); // enchantmentMask < 0x1000
25448-
25449- for (uint32 j = 0; j < MAX_ENCHANTMENT_SLOT; ++j)
25450- {
25451- uint32 enchId = item->GetEnchantmentId(EnchantmentSlot(j));
25452-
25453- if (!enchId)
25454- continue;
25455-
25456- enchantmentMask |= (1 << j);
25457-
25458- *data << uint16(enchId); // enchantmentId?
25459- }
25460-
25461- data->put<uint16>(enchantmentMaskPos, enchantmentMask);
25462-
25463- *data << int16(item->GetItemRandomPropertyId()); // Random item property id
25464- *data << item->GetGuidValue(ITEM_FIELD_CREATOR).WriteAsPacked(); // item creator
25465- *data << uint32(item->GetItemSuffixFactor()); // SuffixFactor
25466- }
25400+ BuildPlayerTalentsInfoData(updateTalentData.Info.emplace<0>());
2546725401
25468- data->put<uint32>(slotUsedMaskPos, slotUsedMask );
25402+ SendDirectMessage(updateTalentData.Write() );
2546925403}
2547025404
2547125405void Player::SendEquipmentSetList()
0 commit comments