aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/DataStores/DBCEnums.h11
-rw-r--r--src/server/game/Handlers/AuctionHouseHandler.cpp2
-rw-r--r--src/server/game/Handlers/CollectionsHandler.cpp6
-rw-r--r--src/server/game/Handlers/MiscHandler.cpp2
-rw-r--r--src/server/game/Server/Packets/AuctionHousePackets.cpp199
-rw-r--r--src/server/game/Server/Packets/AuctionHousePackets.h6
-rw-r--r--src/server/game/Server/Packets/AuthenticationPackets.cpp52
-rw-r--r--src/server/game/Server/Packets/BattlegroundPackets.cpp53
-rw-r--r--src/server/game/Server/Packets/BattlegroundPackets.h1
-rw-r--r--src/server/game/Server/Packets/CharacterPackets.cpp9
-rw-r--r--src/server/game/Server/Packets/CollectionPackets.cpp7
-rw-r--r--src/server/game/Server/Packets/CollectionPackets.h17
-rw-r--r--src/server/game/Server/Packets/GuildPackets.cpp4
-rw-r--r--src/server/game/Server/Packets/MovementPackets.cpp15
-rw-r--r--src/server/game/Server/Packets/MovementPackets.h4
-rw-r--r--src/server/game/Server/Packets/QueryPackets.cpp32
-rw-r--r--src/server/game/Server/Packets/SocialPackets.cpp57
-rw-r--r--src/server/game/Server/Packets/SpellPackets.cpp163
-rw-r--r--src/server/game/Server/Packets/SystemPackets.cpp4
-rw-r--r--src/server/game/Server/Packets/WhoPackets.cpp92
-rw-r--r--src/server/game/Server/Packets/WhoPackets.h6
21 files changed, 351 insertions, 391 deletions
diff --git a/src/server/game/DataStores/DBCEnums.h b/src/server/game/DataStores/DBCEnums.h
index d782e687248..227b504bd4c 100644
--- a/src/server/game/DataStores/DBCEnums.h
+++ b/src/server/game/DataStores/DBCEnums.h
@@ -1104,6 +1104,17 @@ enum ItemBonusType
ITEM_BONUS_ITEM_HISTORY_SLOT = 38,
};
+enum class ItemCollectionType : uint8
+{
+ None = 0,
+ Toy = 1,
+ Heirloom = 2,
+ Transmog = 3,
+ TransmogSetFavorite = 4,
+ RuneforgeLegendaryAbility = 5,
+ TransmogIllusion = 6,
+};
+
enum class ItemContext : uint8
{
NONE = 0,
diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp
index bea51adb4f6..62dbabe2a05 100644
--- a/src/server/game/Handlers/AuctionHouseHandler.cpp
+++ b/src/server/game/Handlers/AuctionHouseHandler.cpp
@@ -1005,7 +1005,7 @@ void WorldSession::SendAuctionHello(ObjectGuid guid, Unit const* unit)
return;
WorldPackets::AuctionHouse::AuctionHelloResponse auctionHelloResponse;
- auctionHelloResponse.Guid = guid;
+ auctionHelloResponse.Auctioneer = guid;
auctionHelloResponse.OpenForBusiness = true; // 3.3.3: 1 - AH enabled, 0 - AH disabled
SendPacket(auctionHelloResponse.Write());
}
diff --git a/src/server/game/Handlers/CollectionsHandler.cpp b/src/server/game/Handlers/CollectionsHandler.cpp
index 1a0ce8be7d1..f3f3703c3b7 100644
--- a/src/server/game/Handlers/CollectionsHandler.cpp
+++ b/src/server/game/Handlers/CollectionsHandler.cpp
@@ -23,10 +23,10 @@ void WorldSession::HandleCollectionItemSetFavorite(WorldPackets::Collections::Co
{
switch (collectionItemSetFavorite.Type)
{
- case WorldPackets::Collections::TOYBOX:
+ case ItemCollectionType::Toy:
GetCollectionMgr()->ToySetFavorite(collectionItemSetFavorite.ID, collectionItemSetFavorite.IsFavorite);
break;
- case WorldPackets::Collections::APPEARANCE:
+ case ItemCollectionType::Transmog:
{
auto [hasAppearance, isTemporary] = GetCollectionMgr()->HasItemAppearance(collectionItemSetFavorite.ID);
if (!hasAppearance || isTemporary)
@@ -35,7 +35,7 @@ void WorldSession::HandleCollectionItemSetFavorite(WorldPackets::Collections::Co
GetCollectionMgr()->SetAppearanceIsFavorite(collectionItemSetFavorite.ID, collectionItemSetFavorite.IsFavorite);
break;
}
- case WorldPackets::Collections::TRANSMOG_SET:
+ case ItemCollectionType::TransmogSetFavorite:
break;
default:
break;
diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
index 5224a8fd4f3..4fa51586771 100644
--- a/src/server/game/Handlers/MiscHandler.cpp
+++ b/src/server/game/Handlers/MiscHandler.cpp
@@ -140,7 +140,7 @@ void WorldSession::HandleWhoOpcode(WorldPackets::Who::WhoRequestPkt& whoRequest)
uint32 gmLevelInWhoList = sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST);
WorldPackets::Who::WhoResponsePkt response;
- response.RequestID = whoRequest.RequestID;
+ response.Token = whoRequest.Token;
WhoListInfoVector const& whoList = sWhoListStorageMgr->GetWhoList();
for (WhoListPlayerInfo const& target : whoList)
diff --git a/src/server/game/Server/Packets/AuctionHousePackets.cpp b/src/server/game/Server/Packets/AuctionHousePackets.cpp
index 2d05019a5c7..3173a045b90 100644
--- a/src/server/game/Server/Packets/AuctionHousePackets.cpp
+++ b/src/server/game/Server/Packets/AuctionHousePackets.cpp
@@ -21,9 +21,7 @@
#include "ObjectGuid.h"
#include "Util.h"
-namespace WorldPackets
-{
-namespace AuctionHouse
+namespace WorldPackets::AuctionHouse
{
AuctionBucketKey& AuctionBucketKey::operator=(AuctionsBucketKey const& key)
{
@@ -42,15 +40,10 @@ AuctionBucketKey& AuctionBucketKey::operator=(AuctionsBucketKey const& key)
ByteBuffer& operator>>(ByteBuffer& data, AuctionBucketKey& itemKey)
{
data.ResetBitPos();
- itemKey.ItemID = data.ReadBits(20);
-
- if (data.ReadBit())
- itemKey.BattlePetSpeciesID.emplace();
-
- itemKey.ItemLevel = data.ReadBits(11);
-
- if (data.ReadBit())
- itemKey.ItemSuffix.emplace();
+ data >> Bits<20>(itemKey.ItemID);
+ data >> OptionalInit(itemKey.BattlePetSpeciesID);
+ data >> Bits<11>(itemKey.ItemLevel);
+ data >> OptionalInit(itemKey.ItemSuffix);
if (itemKey.BattlePetSpeciesID)
data >> *itemKey.BattlePetSpeciesID;
@@ -63,10 +56,10 @@ ByteBuffer& operator>>(ByteBuffer& data, AuctionBucketKey& itemKey)
ByteBuffer& operator<<(ByteBuffer& data, AuctionBucketKey const& itemKey)
{
- data.WriteBits(itemKey.ItemID, 20);
- data.WriteBit(itemKey.BattlePetSpeciesID.has_value());
- data.WriteBits(itemKey.ItemLevel, 11);
- data.WriteBit(itemKey.ItemSuffix.has_value());
+ data << Bits<20>(itemKey.ItemID);
+ data << OptionalInit(itemKey.BattlePetSpeciesID);
+ data << Bits<11>(itemKey.ItemLevel);
+ data << OptionalInit(itemKey.ItemSuffix);
data.FlushBits();
if (itemKey.BattlePetSpeciesID)
@@ -89,7 +82,7 @@ ByteBuffer& operator>>(ByteBuffer& data, AuctionListFilterSubClass& filterSubCla
ByteBuffer& operator>>(ByteBuffer& data, AuctionListFilterClass& filterClass)
{
data >> filterClass.ItemClass;
- filterClass.SubClassFilters.resize(data.ReadBits(5));
+ data >> BitsSize<5>(filterClass.SubClassFilters);
for (AuctionListFilterSubClass& filterSubClass : filterClass.SubClassFilters)
data >> filterSubClass;
@@ -161,12 +154,12 @@ ByteBuffer& operator<<(ByteBuffer& data, BucketInfo const& bucketInfo)
if (!bucketInfo.ItemModifiedAppearanceIDs.empty())
data.append(bucketInfo.ItemModifiedAppearanceIDs.data(), bucketInfo.ItemModifiedAppearanceIDs.size());
- data.WriteBit(bucketInfo.MaxBattlePetQuality.has_value());
- data.WriteBit(bucketInfo.MaxBattlePetLevel.has_value());
- data.WriteBit(bucketInfo.BattlePetBreedID.has_value());
- data.WriteBit(bucketInfo.BattlePetLevelMask.has_value());
- data.WriteBit(bucketInfo.ContainsOwnerItem);
- data.WriteBit(bucketInfo.ContainsOnlyCollectedAppearances);
+ data << OptionalInit(bucketInfo.MaxBattlePetQuality);
+ data << OptionalInit(bucketInfo.MaxBattlePetLevel);
+ data << OptionalInit(bucketInfo.BattlePetBreedID);
+ data << OptionalInit(bucketInfo.BattlePetLevelMask);
+ data << Bits<1>(bucketInfo.ContainsOwnerItem);
+ data << Bits<1>(bucketInfo.ContainsOnlyCollectedAppearances);
data.FlushBits();
if (bucketInfo.MaxBattlePetQuality)
@@ -186,21 +179,21 @@ ByteBuffer& operator<<(ByteBuffer& data, BucketInfo const& bucketInfo)
ByteBuffer& operator<<(ByteBuffer& data, AuctionItem const& auctionItem)
{
- data.WriteBit(auctionItem.Item.has_value());
- data.WriteBits(auctionItem.Enchantments.size(), 4);
- data.WriteBits(auctionItem.Gems.size(), 2);
- data.WriteBit(auctionItem.MinBid.has_value());
- data.WriteBit(auctionItem.MinIncrement.has_value());
- data.WriteBit(auctionItem.BuyoutPrice.has_value());
- data.WriteBit(auctionItem.UnitPrice.has_value());
- data.WriteBit(auctionItem.CensorServerSideInfo);
- data.WriteBit(auctionItem.CensorBidInfo);
- data.WriteBit(auctionItem.AuctionBucketKey.has_value());
- data.WriteBit(auctionItem.Creator.has_value());
+ data << OptionalInit(auctionItem.Item);
+ data << BitsSize<4>(auctionItem.Enchantments);
+ data << BitsSize<2>(auctionItem.Gems);
+ data << OptionalInit(auctionItem.MinBid);
+ data << OptionalInit(auctionItem.MinIncrement);
+ data << OptionalInit(auctionItem.BuyoutPrice);
+ data << OptionalInit(auctionItem.UnitPrice);
+ data << Bits<1>(auctionItem.CensorServerSideInfo);
+ data << Bits<1>(auctionItem.CensorBidInfo);
+ data << OptionalInit(auctionItem.AuctionBucketKey);
+ data << OptionalInit(auctionItem.Creator);
if (!auctionItem.CensorBidInfo)
{
- data.WriteBit(auctionItem.Bidder.has_value());
- data.WriteBit(auctionItem.BidAmount.has_value());
+ data << OptionalInit(auctionItem.Bidder);
+ data << OptionalInit(auctionItem.BidAmount);
}
data.FlushBits();
@@ -295,17 +288,15 @@ void AuctionBrowseQuery::Read()
for (uint8& knownPetMask : KnownPets)
_worldPacket >> knownPetMask;
- if (_worldPacket.ReadBit())
- TaintedBy.emplace();
-
- uint32 nameLength = _worldPacket.ReadBits(8);
- ItemClassFilters.resize(_worldPacket.ReadBits(3));
- Sorts.resize(_worldPacket.ReadBits(2));
+ _worldPacket >> OptionalInit(TaintedBy);
+ _worldPacket >> SizedString::BitsSize<8>(Name);
+ _worldPacket >> BitsSize<3>(ItemClassFilters);
+ _worldPacket >> BitsSize<2>(Sorts);
if (TaintedBy)
_worldPacket >> *TaintedBy;
- Name = _worldPacket.ReadString(nameLength);
+ _worldPacket >> SizedString::Data(Name);
for (AuctionListFilterClass& filterClass : ItemClassFilters)
_worldPacket >> filterClass;
@@ -316,11 +307,9 @@ void AuctionBrowseQuery::Read()
void AuctionCancelCommoditiesPurchase::Read()
{
_worldPacket >> Auctioneer;
- if (_worldPacket.ReadBit())
- {
- TaintedBy.emplace();
+ _worldPacket >> OptionalInit(TaintedBy);
+ if (TaintedBy)
_worldPacket >> *TaintedBy;
- }
}
void AuctionConfirmCommoditiesPurchase::Read()
@@ -328,11 +317,9 @@ void AuctionConfirmCommoditiesPurchase::Read()
_worldPacket >> Auctioneer;
_worldPacket >> ItemID;
_worldPacket >> Quantity;
- if (_worldPacket.ReadBit())
- {
- TaintedBy.emplace();
+ _worldPacket >> OptionalInit(TaintedBy);
+ if (TaintedBy)
_worldPacket >> *TaintedBy;
- }
}
void AuctionHelloRequest::Read()
@@ -344,12 +331,9 @@ void AuctionListBiddedItems::Read()
{
_worldPacket >> Auctioneer;
_worldPacket >> Offset;
-
- if (_worldPacket.ReadBit())
- TaintedBy.emplace();
-
- AuctionIDs.resize(_worldPacket.ReadBits(7));
- Sorts.resize(_worldPacket.ReadBits(2));
+ _worldPacket >> OptionalInit(TaintedBy);
+ _worldPacket >> BitsSize<7>(AuctionIDs);
+ _worldPacket >> BitsSize<2>(Sorts);
if (TaintedBy)
_worldPacket >> *TaintedBy;
@@ -364,12 +348,9 @@ void AuctionListBiddedItems::Read()
void AuctionListBucketsByBucketKeys::Read()
{
_worldPacket >> Auctioneer;
-
- if (_worldPacket.ReadBit())
- TaintedBy.emplace();
-
- BucketKeys.resize(_worldPacket.ReadBits(7));
- Sorts.resize(_worldPacket.ReadBits(2));
+ _worldPacket >> OptionalInit(TaintedBy);
+ _worldPacket >> BitsSize<7>(BucketKeys);
+ _worldPacket >> BitsSize<2>(Sorts);
if (TaintedBy)
_worldPacket >> *TaintedBy;
@@ -386,11 +367,8 @@ void AuctionListItemsByBucketKey::Read()
_worldPacket >> Auctioneer;
_worldPacket >> Offset;
_worldPacket >> Unknown830;
-
- if (_worldPacket.ReadBit())
- TaintedBy.emplace();
-
- Sorts.resize(_worldPacket.ReadBits(2));
+ _worldPacket >> OptionalInit(TaintedBy);
+ _worldPacket >> BitsSize<2>(Sorts);
_worldPacket >> BucketKey;
@@ -407,11 +385,8 @@ void AuctionListItemsByItemID::Read()
_worldPacket >> ItemID;
_worldPacket >> SuffixItemNameDescriptionID;
_worldPacket >> Offset;
-
- if (_worldPacket.ReadBit())
- TaintedBy.emplace();
-
- Sorts.resize(_worldPacket.ReadBits(2));
+ _worldPacket >> OptionalInit(TaintedBy);
+ _worldPacket >> BitsSize<2>(Sorts);
if (TaintedBy)
_worldPacket >> *TaintedBy;
@@ -424,11 +399,8 @@ void AuctionListOwnedItems::Read()
{
_worldPacket >> Auctioneer;
_worldPacket >> Offset;
-
- if (_worldPacket.ReadBit())
- TaintedBy.emplace();
-
- Sorts.resize(_worldPacket.ReadBits(2));
+ _worldPacket >> OptionalInit(TaintedBy);
+ _worldPacket >> BitsSize<2>(Sorts);
if (TaintedBy)
_worldPacket >> *TaintedBy;
@@ -442,11 +414,9 @@ void AuctionPlaceBid::Read()
_worldPacket >> Auctioneer;
_worldPacket >> AuctionID;
_worldPacket >> BidAmount;
- if (_worldPacket.ReadBit())
- {
- TaintedBy.emplace();
+ _worldPacket >> OptionalInit(TaintedBy);
+ if (TaintedBy)
_worldPacket >> *TaintedBy;
- }
}
void AuctionRemoveItem::Read()
@@ -454,11 +424,9 @@ void AuctionRemoveItem::Read()
_worldPacket >> Auctioneer;
_worldPacket >> AuctionID;
_worldPacket >> ItemID;
- if (_worldPacket.ReadBit())
- {
- TaintedBy.emplace();
+ _worldPacket >> OptionalInit(TaintedBy);
+ if (TaintedBy)
_worldPacket >> *TaintedBy;
- }
}
void AuctionReplicateItems::Read()
@@ -468,11 +436,9 @@ void AuctionReplicateItems::Read()
_worldPacket >> ChangeNumberCursor;
_worldPacket >> ChangeNumberTombstone;
_worldPacket >> Count;
- if (_worldPacket.ReadBit())
- {
- TaintedBy.emplace();
+ _worldPacket >> OptionalInit(TaintedBy);
+ if (TaintedBy)
_worldPacket >> *TaintedBy;
- }
}
void AuctionSellCommodity::Read()
@@ -480,11 +446,8 @@ void AuctionSellCommodity::Read()
_worldPacket >> Auctioneer;
_worldPacket >> UnitPrice;
_worldPacket >> RunTime;
-
- if (_worldPacket.ReadBit())
- TaintedBy.emplace();
-
- Items.resize(_worldPacket.ReadBits(6));
+ _worldPacket >> OptionalInit(TaintedBy);
+ _worldPacket >> BitsSize<6>(Items);
if (TaintedBy)
_worldPacket >> *TaintedBy;
@@ -499,11 +462,8 @@ void AuctionSellItem::Read()
_worldPacket >> MinBid;
_worldPacket >> BuyoutPrice;
_worldPacket >> RunTime;
-
- if (_worldPacket.ReadBit())
- TaintedBy.emplace();
-
- Items.resize(_worldPacket.ReadBits(6));
+ _worldPacket >> OptionalInit(TaintedBy);
+ _worldPacket >> BitsSize<6>(Items);
if (TaintedBy)
_worldPacket >> *TaintedBy;
@@ -514,7 +474,7 @@ void AuctionSellItem::Read()
void AuctionSetFavoriteItem::Read()
{
- IsNotFavorite = _worldPacket.ReadBit();
+ _worldPacket >> Bits<1>(IsNotFavorite);
_worldPacket >> Item;
}
@@ -523,18 +483,16 @@ void AuctionGetCommodityQuote::Read()
_worldPacket >> Auctioneer;
_worldPacket >> ItemID;
_worldPacket >> Quantity;
- if (_worldPacket.ReadBit())
- {
- TaintedBy.emplace();
+ _worldPacket >> OptionalInit(TaintedBy);
+ if (TaintedBy)
_worldPacket >> *TaintedBy;
- }
}
WorldPacket const* AuctionClosedNotification::Write()
{
_worldPacket << Info;
_worldPacket << float(ProceedsMailDelay);
- _worldPacket.WriteBit(Sold);
+ _worldPacket << Bits<1>(Sold);
_worldPacket.FlushBits();
return &_worldPacket;
@@ -556,9 +514,9 @@ WorldPacket const* AuctionCommandResult::Write()
WorldPacket const* AuctionGetCommodityQuoteResult::Write()
{
- _worldPacket.WriteBit(TotalPrice.has_value());
- _worldPacket.WriteBit(Quantity.has_value());
- _worldPacket.WriteBit(QuoteDuration.has_value());
+ _worldPacket << OptionalInit(TotalPrice);
+ _worldPacket << OptionalInit(Quantity);
+ _worldPacket << OptionalInit(QuoteDuration);
_worldPacket << int32(ItemID);
_worldPacket << uint32(DesiredDelay);
@@ -577,7 +535,7 @@ WorldPacket const* AuctionGetCommodityQuoteResult::Write()
WorldPacket const* AuctionFavoriteList::Write()
{
_worldPacket << uint32(DesiredDelay);
- _worldPacket.WriteBits(Items.size(), 7);
+ _worldPacket << BitsSize<7>(Items);
_worldPacket.FlushBits();
for (AuctionFavoriteInfo const& favoriteInfo : Items)
@@ -588,10 +546,10 @@ WorldPacket const* AuctionFavoriteList::Write()
WorldPacket const* AuctionHelloResponse::Write()
{
- _worldPacket << Guid;
- _worldPacket << uint32(PurchasedItemDeliveryDelay);
- _worldPacket << uint32(CancelledItemDeliveryDelay);
- _worldPacket.WriteBit(OpenForBusiness);
+ _worldPacket << Auctioneer;
+ _worldPacket << uint32(PurchaseDeliveryDelay);
+ _worldPacket << uint32(CancelDeliveryDelay);
+ _worldPacket << Bits<1>(OpenForBusiness);
_worldPacket.FlushBits();
return &_worldPacket;
@@ -601,7 +559,7 @@ WorldPacket const* AuctionListBiddedItemsResult::Write()
{
_worldPacket << uint32(Items.size());
_worldPacket << uint32(DesiredDelay);
- _worldPacket.WriteBit(HasMoreResults);
+ _worldPacket << Bits<1>(HasMoreResults);
_worldPacket.FlushBits();
for (AuctionItem const& item : Items)
@@ -616,8 +574,8 @@ WorldPacket const* AuctionListBucketsResult::Write()
_worldPacket << uint32(DesiredDelay);
_worldPacket << int32(Unknown830_0);
_worldPacket << int32(Unknown830_1);
- _worldPacket.WriteBits(AsUnderlyingType(BrowseMode), 1);
- _worldPacket.WriteBit(HasMoreResults);
+ _worldPacket << Bits<1>(BrowseMode);
+ _worldPacket << Bits<1>(HasMoreResults);
_worldPacket.FlushBits();
for (BucketInfo const& bucketInfo : Buckets)
@@ -637,8 +595,8 @@ WorldPacket const* AuctionListItemsResult::Write()
}
{
- _worldPacket.WriteBits(AsUnderlyingType(ListType), 2);
- _worldPacket.WriteBit(HasMoreResults);
+ _worldPacket << Bits<2>(ListType);
+ _worldPacket << Bits<1>(HasMoreResults);
_worldPacket.FlushBits();
_worldPacket << BucketKey;
@@ -653,7 +611,7 @@ WorldPacket const* AuctionListOwnedItemsResult::Write()
_worldPacket << int32(Items.size());
_worldPacket << int32(SoldItems.size());
_worldPacket << uint32(DesiredDelay);
- _worldPacket.WriteBit(HasMoreResults);
+ _worldPacket << Bits<1>(HasMoreResults);
_worldPacket.FlushBits();
for (AuctionItem const& item : Items)
@@ -705,4 +663,3 @@ WorldPacket const* AuctionWonNotification::Write()
return &_worldPacket;
}
}
-}
diff --git a/src/server/game/Server/Packets/AuctionHousePackets.h b/src/server/game/Server/Packets/AuctionHousePackets.h
index 852ed4a5917..a1e910929dd 100644
--- a/src/server/game/Server/Packets/AuctionHousePackets.h
+++ b/src/server/game/Server/Packets/AuctionHousePackets.h
@@ -412,9 +412,9 @@ namespace WorldPackets
WorldPacket const* Write() override;
- ObjectGuid Guid;
- uint32 PurchasedItemDeliveryDelay = 0;
- uint32 CancelledItemDeliveryDelay = 0;
+ ObjectGuid Auctioneer;
+ uint32 PurchaseDeliveryDelay = 0;
+ uint32 CancelDeliveryDelay = 0;
bool OpenForBusiness = true;
};
diff --git a/src/server/game/Server/Packets/AuthenticationPackets.cpp b/src/server/game/Server/Packets/AuthenticationPackets.cpp
index a820dcda90c..1d4f92ab10c 100644
--- a/src/server/game/Server/Packets/AuthenticationPackets.cpp
+++ b/src/server/game/Server/Packets/AuthenticationPackets.cpp
@@ -25,14 +25,14 @@
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Auth::VirtualRealmNameInfo const& virtualRealmInfo)
{
- data.WriteBit(virtualRealmInfo.IsLocal);
- data.WriteBit(virtualRealmInfo.IsInternalRealm);
- data.WriteBits(virtualRealmInfo.RealmNameActual.length(), 8);
- data.WriteBits(virtualRealmInfo.RealmNameNormalized.length(), 8);
+ data << WorldPackets::Bits<1>(virtualRealmInfo.IsLocal);
+ data << WorldPackets::Bits<1>(virtualRealmInfo.IsInternalRealm);
+ data << WorldPackets::SizedString::BitsSize<8>(virtualRealmInfo.RealmNameActual);
+ data << WorldPackets::SizedString::BitsSize<8>(virtualRealmInfo.RealmNameNormalized);
data.FlushBits();
- data.WriteString(virtualRealmInfo.RealmNameActual);
- data.WriteString(virtualRealmInfo.RealmNameNormalized);
+ data << WorldPackets::SizedString::Data(virtualRealmInfo.RealmNameActual);
+ data << WorldPackets::SizedString::Data(virtualRealmInfo.RealmNameNormalized);
return data;
}
@@ -89,12 +89,12 @@ void WorldPackets::Auth::AuthSession::Read()
_worldPacket >> RealmID;
_worldPacket.read(LocalChallenge.data(), LocalChallenge.size());
_worldPacket.read(Digest.data(), Digest.size());
- UseIPv6 = _worldPacket.ReadBit();
+ _worldPacket >> Bits<1>(UseIPv6);
_worldPacket >> realmJoinTicketSize;
if (realmJoinTicketSize)
{
RealmJoinTicket.resize(std::min(realmJoinTicketSize, uint32(_worldPacket.size() - _worldPacket.rpos())));
- _worldPacket.read(reinterpret_cast<uint8*>(&RealmJoinTicket[0]), RealmJoinTicket.size());
+ _worldPacket.read(RealmJoinTicket.data(), RealmJoinTicket.size());
}
}
@@ -103,8 +103,8 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Auth::AuthWaitInfo const&
data << uint32(waitInfo.WaitCount);
data << uint32(waitInfo.WaitTime);
data << uint32(waitInfo.AllowedFactionGroupForCharacterCreate);
- data.WriteBit(waitInfo.HasFCM);
- data.WriteBit(waitInfo.CanCreateOnlyIfExisting);
+ data << WorldPackets::Bits<1>(waitInfo.HasFCM);
+ data << WorldPackets::Bits<1>(waitInfo.CanCreateOnlyIfExisting);
data.FlushBits();
return data;
@@ -113,8 +113,8 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Auth::AuthWaitInfo const&
WorldPacket const* WorldPackets::Auth::AuthResponse::Write()
{
_worldPacket << uint32(Result);
- _worldPacket.WriteBit(SuccessInfo.has_value());
- _worldPacket.WriteBit(WaitInfo.has_value());
+ _worldPacket << OptionalInit(SuccessInfo);
+ _worldPacket << OptionalInit(WaitInfo);
_worldPacket.FlushBits();
if (SuccessInfo)
@@ -144,21 +144,21 @@ WorldPacket const* WorldPackets::Auth::AuthResponse::Write()
}
}
- _worldPacket.WriteBit(SuccessInfo->IsExpansionTrial);
- _worldPacket.WriteBit(SuccessInfo->ForceCharacterTemplate);
- _worldPacket.WriteBit(SuccessInfo->NumPlayersHorde.has_value());
- _worldPacket.WriteBit(SuccessInfo->NumPlayersAlliance.has_value());
- _worldPacket.WriteBit(SuccessInfo->ExpansionTrialExpiration.has_value());
- _worldPacket.WriteBit(SuccessInfo->NewBuildKeys.has_value());
+ _worldPacket << Bits<1>(SuccessInfo->IsExpansionTrial);
+ _worldPacket << Bits<1>(SuccessInfo->ForceCharacterTemplate);
+ _worldPacket << OptionalInit(SuccessInfo->NumPlayersHorde);
+ _worldPacket << OptionalInit(SuccessInfo->NumPlayersAlliance);
+ _worldPacket << OptionalInit(SuccessInfo->ExpansionTrialExpiration);
+ _worldPacket << OptionalInit(SuccessInfo->NewBuildKeys);
_worldPacket.FlushBits();
{
_worldPacket << uint32(SuccessInfo->GameTimeInfo.BillingType);
_worldPacket << uint32(SuccessInfo->GameTimeInfo.MinutesRemaining);
_worldPacket << uint32(SuccessInfo->GameTimeInfo.RealBillingType);
- _worldPacket.WriteBit(SuccessInfo->GameTimeInfo.IsInIGR); // inGameRoom check in function checking which lua event to fire when remaining time is near end - BILLING_NAG_DIALOG vs IGR_BILLING_NAG_DIALOG
- _worldPacket.WriteBit(SuccessInfo->GameTimeInfo.IsPaidForByIGR); // inGameRoom lua return from Script_GetBillingPlan
- _worldPacket.WriteBit(SuccessInfo->GameTimeInfo.IsCAISEnabled); // not used anywhere in the client
+ _worldPacket << Bits<1>(SuccessInfo->GameTimeInfo.IsInIGR); // inGameRoom check in function checking which lua event to fire when remaining time is near end - BILLING_NAG_DIALOG vs IGR_BILLING_NAG_DIALOG
+ _worldPacket << Bits<1>(SuccessInfo->GameTimeInfo.IsPaidForByIGR); // inGameRoom lua return from Script_GetBillingPlan
+ _worldPacket << Bits<1>(SuccessInfo->GameTimeInfo.IsCAISEnabled); // not used anywhere in the client
_worldPacket.FlushBits();
}
@@ -193,12 +193,12 @@ WorldPacket const* WorldPackets::Auth::AuthResponse::Write()
_worldPacket << uint8(templateClass.FactionGroup);
}
- _worldPacket.WriteBits(characterTemplate->Name.length(), 7);
- _worldPacket.WriteBits(characterTemplate->Description.length(), 10);
+ _worldPacket << SizedString::BitsSize<7>(characterTemplate->Name);
+ _worldPacket << SizedString::BitsSize<10>(characterTemplate->Description);
_worldPacket.FlushBits();
- _worldPacket.WriteString(characterTemplate->Name);
- _worldPacket.WriteString(characterTemplate->Description);
+ _worldPacket << SizedString::Data(characterTemplate->Name);
+ _worldPacket << SizedString::Data(characterTemplate->Description);
}
}
@@ -361,7 +361,7 @@ WorldPacket const* WorldPackets::Auth::EnterEncryptedMode::Write()
ed25519.SignWithContext(toSign, { EnableEncryptionContext.begin(), EnableEncryptionContext.end() }, signature);
_worldPacket.append(signature.data(), signature.size());
- _worldPacket.WriteBit(Enabled);
+ _worldPacket << Bits<1>(Enabled);
_worldPacket.FlushBits();
return &_worldPacket;
diff --git a/src/server/game/Server/Packets/BattlegroundPackets.cpp b/src/server/game/Server/Packets/BattlegroundPackets.cpp
index 84fbd6e0498..6f28c10782f 100644
--- a/src/server/game/Server/Packets/BattlegroundPackets.cpp
+++ b/src/server/game/Server/Packets/BattlegroundPackets.cpp
@@ -26,9 +26,9 @@ WorldPacket const* WorldPackets::Battleground::SeasonInfo::Write()
_worldPacket << int32(ConquestWeeklyProgressCurrencyID);
_worldPacket << int32(PvpSeasonID);
_worldPacket << int32(Unknown1027_1);
- _worldPacket.WriteBit(WeeklyRewardChestsEnabled);
- _worldPacket.WriteBit(CurrentArenaSeasonUsesTeams);
- _worldPacket.WriteBit(PreviousArenaSeasonUsesTeams);
+ _worldPacket << Bits<1>(WeeklyRewardChestsEnabled);
+ _worldPacket << Bits<1>(CurrentArenaSeasonUsesTeams);
+ _worldPacket << Bits<1>(PreviousArenaSeasonUsesTeams);
_worldPacket.FlushBits();
return &_worldPacket;
@@ -203,8 +203,9 @@ WorldPacket const* WorldPackets::Battleground::BattlefieldStatusActive::Write()
_worldPacket << uint32(Mapid);
_worldPacket << uint32(ShutdownTimer);
_worldPacket << uint32(StartTimer);
- _worldPacket.WriteBit(ArenaFaction != 0);
- _worldPacket.WriteBit(LeftEarly);
+ _worldPacket << Bits<1>(ArenaFaction != 0);
+ _worldPacket << Bits<1>(LeftEarly);
+ _worldPacket << Bits<1>(Brawl);
_worldPacket.FlushBits();
return &_worldPacket;
}
@@ -215,9 +216,9 @@ WorldPacket const* WorldPackets::Battleground::BattlefieldStatusQueued::Write()
_worldPacket << uint32(AverageWaitTime);
_worldPacket << uint32(WaitTime);
_worldPacket << int32(SpecSelected);
- _worldPacket.WriteBit(AsGroup);
- _worldPacket.WriteBit(EligibleForMatchmaking);
- _worldPacket.WriteBit(SuspendedQueue);
+ _worldPacket << Bits<1>(AsGroup);
+ _worldPacket << Bits<1>(EligibleForMatchmaking);
+ _worldPacket << Bits<1>(SuspendedQueue);
_worldPacket.FlushBits();
return &_worldPacket;
}
@@ -234,7 +235,7 @@ WorldPacket const* WorldPackets::Battleground::BattlefieldStatusFailed::Write()
void WorldPackets::Battleground::BattlefieldPort::Read()
{
_worldPacket >> Ticket;
- AcceptedInvite = _worldPacket.ReadBit();
+ _worldPacket >> Bits<1>(AcceptedInvite);
}
void WorldPackets::Battleground::BattlefieldListRequest::Read()
@@ -252,24 +253,24 @@ WorldPacket const* WorldPackets::Battleground::BattlefieldList::Write()
if (!Battlefields.empty())
_worldPacket.append(Battlefields.data(), Battlefields.size());
- _worldPacket.WriteBit(PvpAnywhere);
- _worldPacket.WriteBit(HasRandomWinToday);
+ _worldPacket << Bits<1>(PvpAnywhere);
+ _worldPacket << Bits<1>(HasRandomWinToday);
_worldPacket.FlushBits();
return &_worldPacket;
}
WorldPacket const* WorldPackets::Battleground::PVPOptionsEnabled::Write()
{
- _worldPacket.WriteBit(RatedBattlegrounds);
- _worldPacket.WriteBit(PugBattlegrounds);
- _worldPacket.WriteBit(WargameBattlegrounds);
- _worldPacket.WriteBit(WargameArenas);
- _worldPacket.WriteBit(RatedArenas);
- _worldPacket.WriteBit(ArenaSkirmish);
- _worldPacket.WriteBit(SoloShuffle);
- _worldPacket.WriteBit(RatedSoloShuffle);
- _worldPacket.WriteBit(BattlegroundBlitz);
- _worldPacket.WriteBit(RatedBattlegroundBlitz);
+ _worldPacket << Bits<1>(RatedBattlegrounds);
+ _worldPacket << Bits<1>(PugBattlegrounds);
+ _worldPacket << Bits<1>(WargameBattlegrounds);
+ _worldPacket << Bits<1>(WargameArenas);
+ _worldPacket << Bits<1>(RatedArenas);
+ _worldPacket << Bits<1>(ArenaSkirmish);
+ _worldPacket << Bits<1>(SoloShuffle);
+ _worldPacket << Bits<1>(RatedSoloShuffle);
+ _worldPacket << Bits<1>(BattlegroundBlitz);
+ _worldPacket << Bits<1>(RatedBattlegroundBlitz);
_worldPacket.FlushBits();
return &_worldPacket;
}
@@ -375,9 +376,9 @@ WorldPacket const* WorldPackets::Battleground::PVPMatchInitialize::Write()
_worldPacket << Duration;
_worldPacket << uint8(ArenaFaction);
_worldPacket << uint32(BattlemasterListID);
- _worldPacket.WriteBit(Registered);
- _worldPacket.WriteBit(AffectsRating);
- _worldPacket.WriteBit(DeserterPenalty.has_value());
+ _worldPacket << Bits<1>(Registered);
+ _worldPacket << Bits<1>(AffectsRating);
+ _worldPacket << OptionalInit(DeserterPenalty);
_worldPacket.FlushBits();
if (DeserterPenalty)
@@ -397,8 +398,8 @@ WorldPacket const* WorldPackets::Battleground::PVPMatchComplete::Write()
{
_worldPacket << uint8(Winner);
_worldPacket << Duration;
- _worldPacket.WriteBit(LogData.has_value());
- _worldPacket.WriteBits(SoloShuffleStatus, 2);
+ _worldPacket << OptionalInit(LogData);
+ _worldPacket << Bits<2>(SoloShuffleStatus);
_worldPacket.FlushBits();
if (LogData)
diff --git a/src/server/game/Server/Packets/BattlegroundPackets.h b/src/server/game/Server/Packets/BattlegroundPackets.h
index 61c473c2036..f15313c6da9 100644
--- a/src/server/game/Server/Packets/BattlegroundPackets.h
+++ b/src/server/game/Server/Packets/BattlegroundPackets.h
@@ -210,6 +210,7 @@ namespace WorldPackets
uint32 ShutdownTimer = 0;
uint8 ArenaFaction = 0;
bool LeftEarly = false;
+ bool Brawl = false;
uint32 StartTimer = 0;
uint32 Mapid = 0;
};
diff --git a/src/server/game/Server/Packets/CharacterPackets.cpp b/src/server/game/Server/Packets/CharacterPackets.cpp
index 9acbfe3654c..2a4d33569d9 100644
--- a/src/server/game/Server/Packets/CharacterPackets.cpp
+++ b/src/server/game/Server/Packets/CharacterPackets.cpp
@@ -236,12 +236,12 @@ ByteBuffer& operator<<(ByteBuffer& data, EnumCharactersResult::CharacterInfoBasi
for (ChrCustomizationChoice const& customization : charInfo.Customizations)
data << customization;
- data << BitsSize<6>(charInfo.Name);
+ data << SizedString::BitsSize<6>(charInfo.Name);
data << Bits<1>(charInfo.FirstLogin);
data.FlushBits();
- data.WriteString(charInfo.Name);
+ data << SizedString::Data(charInfo.Name);
return data;
}
@@ -263,13 +263,12 @@ ByteBuffer& operator<<(ByteBuffer& data, EnumCharactersResult::CharacterRestrict
data.append(restrictionsAndMails.MailSenderTypes.data(), restrictionsAndMails.MailSenderTypes.size());
for (std::string const& str : restrictionsAndMails.MailSenders)
- data << Bits<6>(str.length() + 1);
+ data << SizedCString::BitsSize<6>(str);
data.FlushBits();
for (std::string const& str : restrictionsAndMails.MailSenders)
- if (!str.empty())
- data << str;
+ data << SizedCString::Data(str);
return data;
}
diff --git a/src/server/game/Server/Packets/CollectionPackets.cpp b/src/server/game/Server/Packets/CollectionPackets.cpp
index 14b3e193d45..9df53877bb8 100644
--- a/src/server/game/Server/Packets/CollectionPackets.cpp
+++ b/src/server/game/Server/Packets/CollectionPackets.cpp
@@ -16,10 +16,11 @@
*/
#include "CollectionPackets.h"
+#include "PacketUtilities.h"
void WorldPackets::Collections::CollectionItemSetFavorite::Read()
{
- Type = _worldPacket.read<CollectionType>();
- ID = _worldPacket.read<uint32>();
- IsFavorite = _worldPacket.ReadBit();
+ _worldPacket >> As<uint32>(Type);
+ _worldPacket >> ID;
+ _worldPacket >> Bits<1>(IsFavorite);
}
diff --git a/src/server/game/Server/Packets/CollectionPackets.h b/src/server/game/Server/Packets/CollectionPackets.h
index aac6228af89..c6a972d5bae 100644
--- a/src/server/game/Server/Packets/CollectionPackets.h
+++ b/src/server/game/Server/Packets/CollectionPackets.h
@@ -15,23 +15,16 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef CollectionPackets_h__
-#define CollectionPackets_h__
+#ifndef TRINITYCORE_COLLECTION_PACKETS_H
+#define TRINITYCORE_COLLECTION_PACKETS_H
+#include "DBCEnums.h"
#include "Packet.h"
namespace WorldPackets
{
namespace Collections
{
- enum CollectionType : int32
- {
- NONE = -1,
- TOYBOX = 1,
- APPEARANCE = 3,
- TRANSMOG_SET = 4
- };
-
class CollectionItemSetFavorite final : public ClientPacket
{
public:
@@ -39,11 +32,11 @@ namespace WorldPackets
void Read() override;
- CollectionType Type = NONE;
+ ItemCollectionType Type = ItemCollectionType::None;
uint32 ID = 0;
bool IsFavorite = false;
};
}
}
-#endif // CollectionPackets_h__
+#endif // TRINITYCORE_COLLECTION_PACKETS_H
diff --git a/src/server/game/Server/Packets/GuildPackets.cpp b/src/server/game/Server/Packets/GuildPackets.cpp
index 52f2a953e61..eddb27b988a 100644
--- a/src/server/game/Server/Packets/GuildPackets.cpp
+++ b/src/server/game/Server/Packets/GuildPackets.cpp
@@ -91,10 +91,10 @@ WorldPacket const* WorldPackets::Guild::GuildCommandResult::Write()
_worldPacket << int32(Result);
_worldPacket << int32(Command);
- _worldPacket.WriteBits(Name.length(), 8);
+ _worldPacket << SizedString::BitsSize<8>(Name);
_worldPacket.FlushBits();
- _worldPacket.WriteString(Name);
+ _worldPacket << SizedString::Data(Name);
return &_worldPacket;
}
diff --git a/src/server/game/Server/Packets/MovementPackets.cpp b/src/server/game/Server/Packets/MovementPackets.cpp
index bb028596fc2..1dd15b811a0 100644
--- a/src/server/game/Server/Packets/MovementPackets.cpp
+++ b/src/server/game/Server/Packets/MovementPackets.cpp
@@ -674,8 +674,10 @@ WorldPacket const* WorldPackets::Movement::TransferPending::Write()
{
_worldPacket << int32(MapID);
_worldPacket << OldMapPosition;
- _worldPacket.WriteBit(Ship.has_value());
- _worldPacket.WriteBit(TransferSpellID.has_value());
+ _worldPacket << OptionalInit(Ship);
+ _worldPacket << OptionalInit(TransferSpellID);
+ _worldPacket.FlushBits();
+
if (Ship)
{
_worldPacket << uint32(Ship->ID);
@@ -685,7 +687,6 @@ WorldPacket const* WorldPackets::Movement::TransferPending::Write()
if (TransferSpellID)
_worldPacket << int32(*TransferSpellID);
- _worldPacket.FlushBits();
return &_worldPacket;
}
@@ -1054,7 +1055,7 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MoveSetCompound
data << uint32(stateChange.MessageID);
data << uint32(stateChange.SequenceIndex);
data.WriteBit(stateChange.Speed.has_value());
- data.WriteBit(stateChange.SpeedRange.has_value());
+ data.WriteBit(stateChange.Range.has_value());
data.WriteBit(stateChange.KnockBack.has_value());
data.WriteBit(stateChange.VehicleRecID.has_value());
data.WriteBit(stateChange.CollisionHeight.has_value());
@@ -1070,10 +1071,10 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MoveSetCompound
if (stateChange.Speed)
data << float(*stateChange.Speed);
- if (stateChange.SpeedRange)
+ if (stateChange.Range)
{
- data << float(stateChange.SpeedRange->Min);
- data << float(stateChange.SpeedRange->Max);
+ data << float(stateChange.Range->Min);
+ data << float(stateChange.Range->Max);
}
if (stateChange.KnockBack)
diff --git a/src/server/game/Server/Packets/MovementPackets.h b/src/server/game/Server/Packets/MovementPackets.h
index 8a4917fcffa..8fd12c98d4e 100644
--- a/src/server/game/Server/Packets/MovementPackets.h
+++ b/src/server/game/Server/Packets/MovementPackets.h
@@ -707,7 +707,7 @@ namespace WorldPackets
float InitVertSpeed = 0.0f;
};
- struct SpeedRange
+ struct StateChangeRangeInfo
{
float Min = 0.0f;
float Max = 0.0f;
@@ -720,7 +720,7 @@ namespace WorldPackets
uint32 MessageID = 0;
uint32 SequenceIndex = 0;
Optional<float> Speed;
- Optional<MoveSetCompoundState::SpeedRange> SpeedRange;
+ Optional<StateChangeRangeInfo> Range;
Optional<KnockBackInfo> KnockBack;
Optional<int32> VehicleRecID;
Optional<CollisionHeightInfo> CollisionHeight;
diff --git a/src/server/game/Server/Packets/QueryPackets.cpp b/src/server/game/Server/Packets/QueryPackets.cpp
index 1006e285f03..f5e257552e2 100644
--- a/src/server/game/Server/Packets/QueryPackets.cpp
+++ b/src/server/game/Server/Packets/QueryPackets.cpp
@@ -69,30 +69,27 @@ void QueryCreature::Read()
WorldPacket const* QueryCreatureResponse::Write()
{
_worldPacket << uint32(CreatureID);
- _worldPacket.WriteBit(Allow);
+ _worldPacket << Bits<1>(Allow);
_worldPacket.FlushBits();
if (Allow)
{
- _worldPacket.WriteBits(Stats.Title.length() + 1, 11);
- _worldPacket.WriteBits(Stats.TitleAlt.length() + 1, 11);
- _worldPacket.WriteBits(Stats.CursorName.length() + 1, 6);
- _worldPacket.WriteBit(Stats.Leader);
+ _worldPacket << SizedCString::BitsSize<11>(Stats.Title);
+ _worldPacket << SizedCString::BitsSize<11>(Stats.TitleAlt);
+ _worldPacket << SizedCString::BitsSize<6>(Stats.CursorName);
+ _worldPacket << Bits<1>(Stats.Leader);
for (std::size_t i = 0; i < Stats.Name.size(); ++i)
{
- _worldPacket.WriteBits(Stats.Name[i].length() + 1, 11);
- _worldPacket.WriteBits(Stats.NameAlt[i].length() + 1, 11);
+ _worldPacket << SizedCString::BitsSize<11>(Stats.Name[i]);
+ _worldPacket << SizedCString::BitsSize<11>(Stats.NameAlt[i]);
}
for (std::size_t i = 0; i < Stats.Name.size(); ++i)
{
- if (!Stats.Name[i].empty())
- _worldPacket << Stats.Name[i];
-
- if (!Stats.NameAlt[i].empty())
- _worldPacket << Stats.NameAlt[i];
+ _worldPacket << SizedCString::Data(Stats.Name[i]);
+ _worldPacket << SizedCString::Data(Stats.NameAlt[i]);
}
_worldPacket.append(Stats.Flags.data(), Stats.Flags.size());
@@ -123,14 +120,9 @@ WorldPacket const* QueryCreatureResponse::Write()
_worldPacket << int32(Stats.WidgetSetID);
_worldPacket << int32(Stats.WidgetSetUnitConditionID);
- if (!Stats.Title.empty())
- _worldPacket << Stats.Title;
-
- if (!Stats.TitleAlt.empty())
- _worldPacket << Stats.TitleAlt;
-
- if (!Stats.CursorName.empty())
- _worldPacket << Stats.CursorName;
+ _worldPacket << SizedCString::Data(Stats.Title);
+ _worldPacket << SizedCString::Data(Stats.TitleAlt);
+ _worldPacket << SizedCString::Data(Stats.CursorName);
if (!Stats.QuestItems.empty())
_worldPacket.append(Stats.QuestItems.data(), Stats.QuestItems.size());
diff --git a/src/server/game/Server/Packets/SocialPackets.cpp b/src/server/game/Server/Packets/SocialPackets.cpp
index 839a9ea91f0..ab49dae6794 100644
--- a/src/server/game/Server/Packets/SocialPackets.cpp
+++ b/src/server/game/Server/Packets/SocialPackets.cpp
@@ -16,15 +16,18 @@
*/
#include "SocialPackets.h"
+#include "PacketUtilities.h"
#include "SocialMgr.h"
#include "World.h"
-void WorldPackets::Social::SendContactList::Read()
+namespace WorldPackets::Social
+{
+void SendContactList::Read()
{
_worldPacket >> Flags;
}
-WorldPackets::Social::ContactInfo::ContactInfo(ObjectGuid const& guid, FriendInfo const& friendInfo)
+ContactInfo::ContactInfo(ObjectGuid const& guid, FriendInfo const& friendInfo)
{
Guid = guid;
WowAccountGuid = friendInfo.WowAccountGuid;
@@ -38,7 +41,7 @@ WorldPackets::Social::ContactInfo::ContactInfo(ObjectGuid const& guid, FriendInf
ClassID = friendInfo.Class;
}
-ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Social::ContactInfo const& contact)
+ByteBuffer& operator<<(ByteBuffer& data, ContactInfo const& contact)
{
data << contact.Guid;
data << contact.WowAccountGuid;
@@ -49,17 +52,18 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Social::ContactInfo const
data << uint32(contact.AreaID);
data << uint32(contact.Level);
data << uint32(contact.ClassID);
- data.WriteBits(contact.Notes.length(), 10);
+ data << SizedString::BitsSize<10>(contact.Notes);
data.FlushBits();
- data.WriteString(contact.Notes);
+
+ data << SizedString::Data(contact.Notes);
return data;
}
-WorldPacket const* WorldPackets::Social::ContactList::Write()
+WorldPacket const* ContactList::Write()
{
_worldPacket << uint32(Flags);
- _worldPacket.WriteBits(Contacts.size(), 8);
+ _worldPacket << BitsSize<8>(Contacts);
_worldPacket.FlushBits();
for (ContactInfo const& contact : Contacts)
@@ -68,7 +72,7 @@ WorldPacket const* WorldPackets::Social::ContactList::Write()
return &_worldPacket;
}
-void WorldPackets::Social::FriendStatus::Initialize(ObjectGuid const& guid, FriendsResult result, FriendInfo const& friendInfo)
+void FriendStatus::Initialize(ObjectGuid const& guid, FriendsResult result, FriendInfo const& friendInfo)
{
VirtualRealmAddress = GetVirtualRealmAddress();
Notes = friendInfo.Note;
@@ -81,7 +85,7 @@ void WorldPackets::Social::FriendStatus::Initialize(ObjectGuid const& guid, Frie
FriendResult = result;
}
-WorldPacket const* WorldPackets::Social::FriendStatus::Write()
+WorldPacket const* FriendStatus::Write()
{
_worldPacket << uint8(FriendResult);
_worldPacket << Guid;
@@ -91,14 +95,15 @@ WorldPacket const* WorldPackets::Social::FriendStatus::Write()
_worldPacket << uint32(AreaID);
_worldPacket << uint32(Level);
_worldPacket << uint32(ClassID);
- _worldPacket.WriteBits(Notes.length(), 10);
+ _worldPacket << SizedString::BitsSize<10>(Notes);
_worldPacket.FlushBits();
- _worldPacket.WriteString(Notes);
+
+ _worldPacket << SizedString::Data(Notes);
return &_worldPacket;
}
-ByteBuffer& operator>>(ByteBuffer& data, WorldPackets::Social::QualifiedGUID& qGuid)
+ByteBuffer& operator>>(ByteBuffer& data, QualifiedGUID& qGuid)
{
data >> qGuid.VirtualRealmAddress;
data >> qGuid.Guid;
@@ -106,41 +111,43 @@ ByteBuffer& operator>>(ByteBuffer& data, WorldPackets::Social::QualifiedGUID& qG
return data;
}
-void WorldPackets::Social::AddFriend::Read()
+void AddFriend::Read()
{
- uint32 nameLength = _worldPacket.ReadBits(9);
- uint32 noteslength = _worldPacket.ReadBits(9);
- Name = _worldPacket.ReadString(nameLength);
- Notes = _worldPacket.ReadString(noteslength);
+ _worldPacket >> SizedString::BitsSize<9>(Name);
+ _worldPacket >> SizedString::BitsSize<9>(Notes);
+ _worldPacket >> SizedString::Data(Name);
+ _worldPacket >> SizedString::Data(Notes);
}
-void WorldPackets::Social::DelFriend::Read()
+void DelFriend::Read()
{
_worldPacket >> Player;
}
-void WorldPackets::Social::SetContactNotes::Read()
+void SetContactNotes::Read()
{
_worldPacket >> Player;
- Notes = _worldPacket.ReadString(_worldPacket.ReadBits(10));
+ _worldPacket >> SizedString::BitsSize<10>(Notes);
+ _worldPacket >> SizedString::Data(Notes);
}
-void WorldPackets::Social::AddIgnore::Read()
+void AddIgnore::Read()
{
- uint32 nameLength = _worldPacket.ReadBits(9);
+ _worldPacket >> SizedString::BitsSize<9>(Name);
_worldPacket >> AccountGUID;
- Name = _worldPacket.ReadString(nameLength);
+ _worldPacket >> SizedString::Data(Name);
}
-void WorldPackets::Social::DelIgnore::Read()
+void DelIgnore::Read()
{
_worldPacket >> Player;
}
WorldPacket const* WorldPackets::Social::SocialContractRequestResponse::Write()
{
- _worldPacket.WriteBit(ShowSocialContract);
+ _worldPacket << Bits<1>(ShowSocialContract);
_worldPacket.FlushBits();
return &_worldPacket;
}
+}
diff --git a/src/server/game/Server/Packets/SpellPackets.cpp b/src/server/game/Server/Packets/SpellPackets.cpp
index fd82be2f14f..58e0bd45ad8 100644
--- a/src/server/game/Server/Packets/SpellPackets.cpp
+++ b/src/server/game/Server/Packets/SpellPackets.cpp
@@ -48,7 +48,7 @@ WorldPacket const* SendKnownSpells::Write()
{
_worldPacket.reserve(1 + 4 * KnownSpells.size() + 4 * FavoriteSpells.size());
- _worldPacket.WriteBit(InitialLogin);
+ _worldPacket << Bits<1>(InitialLogin);
_worldPacket << uint32(KnownSpells.size());
_worldPacket << uint32(FavoriteSpells.size());
@@ -140,7 +140,7 @@ ByteBuffer& operator<<(ByteBuffer& data, AuraInfo const& aura)
WorldPacket const* AuraUpdate::Write()
{
- _worldPacket.WriteBit(UpdateAll);
+ _worldPacket << Bits<1>(UpdateAll);
_worldPacket << BitsSize<9>(Auras);
for (AuraInfo const& aura : Auras)
_worldPacket << aura;
@@ -161,30 +161,29 @@ ByteBuffer& operator>>(ByteBuffer& buffer, SpellTargetData& targetData)
{
buffer.ResetBitPos();
- targetData.Flags = buffer.ReadBits(28);
- bool hasSrcLocation = buffer.ReadBit();
- bool hasDstLocation = buffer.ReadBit();
- bool hasOrientation = buffer.ReadBit();
- bool hasMapID = buffer.ReadBit();
- uint32 nameLength = buffer.ReadBits(7);
+ buffer >> Bits<28>(targetData.Flags);
+ buffer >> OptionalInit(targetData.SrcLocation);
+ buffer >> OptionalInit(targetData.DstLocation);
+ buffer >> OptionalInit(targetData.Orientation);
+ buffer >> OptionalInit(targetData.MapID);
+ buffer >> SizedString::BitsSize<7>(targetData.Name);
buffer >> targetData.Unit;
buffer >> targetData.Item;
- if (hasSrcLocation)
- buffer >> targetData.SrcLocation.emplace();
+ if (targetData.SrcLocation)
+ buffer >> *targetData.SrcLocation;
- if (hasDstLocation)
- buffer >> targetData.DstLocation.emplace();
+ if (targetData.DstLocation)
+ buffer >> *targetData.DstLocation;
- if (hasOrientation)
- targetData.Orientation = buffer.read<float>();
+ if (targetData.Orientation)
+ buffer >> *targetData.Orientation;
- if (hasMapID)
- targetData.MapID = buffer.read<int32>();
-
- targetData.Name = buffer.ReadString(nameLength);
+ if (targetData.MapID)
+ buffer >> *targetData.MapID;
+ buffer >> SizedString::Data(targetData.Name);
return buffer;
}
@@ -200,8 +199,9 @@ ByteBuffer& operator>>(ByteBuffer& data, SpellCraftingReagent& optionalReagent)
data >> optionalReagent.ItemID;
data >> optionalReagent.DataSlotIndex;
data >> optionalReagent.Quantity;
- if (data.ReadBit())
- optionalReagent.Source = data.read<uint8>();
+ data >> OptionalInit(optionalReagent.Source);
+ if (optionalReagent.Source)
+ data >> *optionalReagent.Source;
return data;
}
@@ -230,14 +230,14 @@ ByteBuffer& operator>>(ByteBuffer& buffer, SpellCastRequest& request)
for (SpellExtraCurrencyCost& optionalCurrency : request.OptionalCurrencies)
buffer >> optionalCurrency;
- request.SendCastFlags = buffer.ReadBits(5);
- bool hasMoveUpdate = buffer.ReadBit();
- request.Weight.resize(buffer.ReadBits(2));
- bool hasCraftingOrderID = buffer.ReadBit();
+ buffer >> Bits<5>(request.SendCastFlags);
+ buffer >> OptionalInit(request.MoveUpdate);
+ buffer >> BitsSize<2>(request.Weight);
+ buffer >> OptionalInit(request.CraftingOrderID);
buffer >> request.Target;
- if (hasCraftingOrderID)
- request.CraftingOrderID = buffer.read<uint64>();
+ if (request.CraftingOrderID)
+ buffer >> *request.CraftingOrderID;
for (SpellCraftingReagent& optionalReagent : request.OptionalReagents)
buffer >> optionalReagent;
@@ -245,13 +245,13 @@ ByteBuffer& operator>>(ByteBuffer& buffer, SpellCastRequest& request)
for (SpellCraftingReagent& optionalReagent : request.RemovedModifications)
buffer >> optionalReagent;
- if (hasMoveUpdate)
- buffer >> request.MoveUpdate.emplace();
+ if (request.MoveUpdate)
+ buffer >> *request.MoveUpdate;
for (SpellWeight& weight : request.Weight)
{
buffer.ResetBitPos();
- weight.Type = buffer.ReadBits(2);
+ buffer >> Bits<2>(weight.Type);
buffer >> weight.ID;
buffer >> weight.Quantity;
}
@@ -295,12 +295,12 @@ ByteBuffer& operator<<(ByteBuffer& data, TargetLocation const& targetLocation)
ByteBuffer& operator<<(ByteBuffer& data, SpellTargetData const& spellTargetData)
{
- data.WriteBits(spellTargetData.Flags, 28);
- data.WriteBit(spellTargetData.SrcLocation.has_value());
- data.WriteBit(spellTargetData.DstLocation.has_value());
- data.WriteBit(spellTargetData.Orientation.has_value());
- data.WriteBit(spellTargetData.MapID.has_value());
- data.WriteBits(spellTargetData.Name.size(), 7);
+ data << Bits<28>(spellTargetData.Flags);
+ data << OptionalInit(spellTargetData.SrcLocation);
+ data << OptionalInit(spellTargetData.DstLocation);
+ data << OptionalInit(spellTargetData.Orientation);
+ data << OptionalInit(spellTargetData.MapID);
+ data << SizedString::BitsSize<7>(spellTargetData.Name);
data.FlushBits();
data << spellTargetData.Unit;
@@ -313,13 +313,12 @@ ByteBuffer& operator<<(ByteBuffer& data, SpellTargetData const& spellTargetData)
data << *spellTargetData.DstLocation;
if (spellTargetData.Orientation)
- data << *spellTargetData.Orientation;
+ data << float(*spellTargetData.Orientation);
if (spellTargetData.MapID)
- data << *spellTargetData.MapID;
-
- data.WriteString(spellTargetData.Name);
+ data << int32(*spellTargetData.MapID);
+ data << SizedString::Data(spellTargetData.Name);
return data;
}
@@ -394,13 +393,13 @@ ByteBuffer& operator<<(ByteBuffer& data, SpellCastData const& spellCastData)
data << uint8(spellCastData.DestLocSpellCastIndex);
data << spellCastData.Immunities;
data << spellCastData.Predict;
- data.WriteBits(spellCastData.HitTargets.size(), 16);
- data.WriteBits(spellCastData.MissTargets.size(), 16);
- data.WriteBits(spellCastData.HitStatus.size(), 16);
- data.WriteBits(spellCastData.MissStatus.size(), 16);
- data.WriteBits(spellCastData.RemainingPower.size(), 9);
- data.WriteBit(spellCastData.RemainingRunes.has_value());
- data.WriteBits(spellCastData.TargetPoints.size(), 16);
+ data << BitsSize<16>(spellCastData.HitTargets);
+ data << BitsSize<16>(spellCastData.MissTargets);
+ data << BitsSize<16>(spellCastData.HitStatus);
+ data << BitsSize<16>(spellCastData.MissStatus);
+ data << BitsSize<9>(spellCastData.RemainingPower);
+ data << OptionalInit(spellCastData.RemainingRunes);
+ data << BitsSize<16>(spellCastData.TargetPoints);
data.FlushBits();
data << spellCastData.Target;
@@ -451,10 +450,10 @@ WorldPacket const* SpellGo::Write()
ByteBuffer& operator<<(ByteBuffer& data, LearnedSpellInfo const& learnedSpellInfo)
{
data << int32(learnedSpellInfo.SpellID);
- data.WriteBit(learnedSpellInfo.Favorite);
- data.WriteBit(learnedSpellInfo.EquipableSpellInvSlot.has_value());
- data.WriteBit(learnedSpellInfo.Superceded.has_value());
- data.WriteBit(learnedSpellInfo.TraitDefinitionID.has_value());
+ data << Bits<1>(learnedSpellInfo.Favorite);
+ data << OptionalInit(learnedSpellInfo.EquipableSpellInvSlot);
+ data << OptionalInit(learnedSpellInfo.Superceded);
+ data << OptionalInit(learnedSpellInfo.TraitDefinitionID);
data.FlushBits();
if (learnedSpellInfo.EquipableSpellInvSlot)
@@ -473,7 +472,7 @@ WorldPacket const* LearnedSpells::Write()
{
_worldPacket << uint32(ClientLearnedSpellData.size());
_worldPacket << uint32(SpecializationID);
- _worldPacket.WriteBit(SuppressMessaging);
+ _worldPacket << Bits<1>(SuppressMessaging);
_worldPacket.FlushBits();
for (LearnedSpellInfo const& spell : ClientLearnedSpellData)
@@ -570,7 +569,7 @@ WorldPacket const* UnlearnedSpells::Write()
for (uint32 spellId : SpellID)
_worldPacket << uint32(spellId);
- _worldPacket.WriteBit(SuppressMessaging);
+ _worldPacket << Bits<1>(SuppressMessaging);
_worldPacket.FlushBits();
return &_worldPacket;
@@ -579,7 +578,7 @@ WorldPacket const* UnlearnedSpells::Write()
WorldPacket const* CooldownEvent::Write()
{
_worldPacket << int32(SpellID);
- _worldPacket.WriteBit(IsPet);
+ _worldPacket << Bits<1>(IsPet);
_worldPacket.FlushBits();
return &_worldPacket;
@@ -591,7 +590,7 @@ WorldPacket const* ClearCooldowns::Write()
if (!SpellID.empty())
_worldPacket.append(SpellID.data(), SpellID.size());
- _worldPacket.WriteBit(IsPet);
+ _worldPacket << Bits<1>(IsPet);
_worldPacket.FlushBits();
return &_worldPacket;
@@ -600,8 +599,8 @@ WorldPacket const* ClearCooldowns::Write()
WorldPacket const* ClearCooldown::Write()
{
_worldPacket << uint32(SpellID);
- _worldPacket.WriteBit(ClearOnHold);
- _worldPacket.WriteBit(IsPet);
+ _worldPacket << Bits<1>(ClearOnHold);
+ _worldPacket << Bits<1>(IsPet);
_worldPacket.FlushBits();
return &_worldPacket;
@@ -611,8 +610,8 @@ WorldPacket const* ModifyCooldown::Write()
{
_worldPacket << int32(SpellID);
_worldPacket << int32(DeltaTime);
- _worldPacket.WriteBit(IsPet);
- _worldPacket.WriteBit(WithoutCategoryCooldown);
+ _worldPacket << Bits<1>(IsPet);
+ _worldPacket << Bits<1>(WithoutCategoryCooldown);
_worldPacket.FlushBits();
return &_worldPacket;
@@ -645,9 +644,9 @@ ByteBuffer& operator<<(ByteBuffer& data, SpellHistoryEntry const& historyEntry)
data << int32(historyEntry.RecoveryTime);
data << int32(historyEntry.CategoryRecoveryTime);
data << float(historyEntry.ModRate);
- data.WriteBit(historyEntry.RecoveryTimeStartOffset.has_value());
- data.WriteBit(historyEntry.CategoryRecoveryTimeStartOffset.has_value());
- data.WriteBit(historyEntry.OnHold);
+ data << OptionalInit(historyEntry.RecoveryTimeStartOffset);
+ data << OptionalInit(historyEntry.CategoryRecoveryTimeStartOffset);
+ data << Bits<1>(historyEntry.OnHold);
if (historyEntry.RecoveryTimeStartOffset)
data << uint32(*historyEntry.RecoveryTimeStartOffset);
if (historyEntry.CategoryRecoveryTimeStartOffset)
@@ -668,7 +667,7 @@ WorldPacket const* SendSpellHistory::Write()
WorldPacket const* ClearAllSpellCharges::Write()
{
- _worldPacket.WriteBit(IsPet);
+ _worldPacket << Bits<1>(IsPet);
_worldPacket.FlushBits();
return &_worldPacket;
@@ -677,7 +676,7 @@ WorldPacket const* ClearAllSpellCharges::Write()
WorldPacket const* ClearSpellCharges::Write()
{
_worldPacket << int32(Category);
- _worldPacket.WriteBit(IsPet);
+ _worldPacket << Bits<1>(IsPet);
_worldPacket.FlushBits();
return &_worldPacket;
@@ -689,7 +688,7 @@ WorldPacket const* SetSpellCharges::Write()
_worldPacket << uint32(NextRecoveryTime);
_worldPacket << uint8(ConsumedCharges);
_worldPacket << float(ChargeModRate);
- _worldPacket.WriteBit(IsPet);
+ _worldPacket << Bits<1>(IsPet);
_worldPacket.FlushBits();
return &_worldPacket;
@@ -739,7 +738,7 @@ WorldPacket const* CancelSpellVisualKit::Write()
{
_worldPacket << Source;
_worldPacket << int32(SpellVisualKitID);
- _worldPacket.WriteBit(MountedVisual);
+ _worldPacket << Bits<1>(MountedVisual);
_worldPacket.FlushBits();
return &_worldPacket;
@@ -756,7 +755,7 @@ WorldPacket const* PlayOrphanSpellVisual::Write()
_worldPacket << float(TravelSpeed);
_worldPacket << float(LaunchDelay);
_worldPacket << float(MinDuration);
- _worldPacket.WriteBit(SpeedAsTime);
+ _worldPacket << Bits<1>(SpeedAsTime);
_worldPacket.FlushBits();
return &_worldPacket;
@@ -775,7 +774,7 @@ WorldPacket const* PlaySpellVisual::Write()
_worldPacket << uint16(ReflectStatus);
_worldPacket << float(LaunchDelay);
_worldPacket << float(MinDuration);
- _worldPacket.WriteBit(SpeedAsTime);
+ _worldPacket << Bits<1>(SpeedAsTime);
_worldPacket.FlushBits();
return &_worldPacket;
@@ -787,7 +786,7 @@ WorldPacket const* PlaySpellVisualKit::Write()
_worldPacket << int32(KitRecID);
_worldPacket << int32(KitType);
_worldPacket << uint32(Duration);
- _worldPacket.WriteBit(MountedVisual);
+ _worldPacket << Bits<1>(MountedVisual);
_worldPacket.FlushBits();
return &_worldPacket;
@@ -833,8 +832,8 @@ WorldPacket const* SpellChannelStart::Write()
_worldPacket << int32(SpellID);
_worldPacket << Visual;
_worldPacket << uint32(ChannelDuration);
- _worldPacket.WriteBit(InterruptImmunities.has_value());
- _worldPacket.WriteBit(HealPrediction.has_value());
+ _worldPacket << OptionalInit(InterruptImmunities);
+ _worldPacket << OptionalInit(HealPrediction);
_worldPacket.FlushBits();
if (InterruptImmunities)
@@ -871,8 +870,8 @@ WorldPacket const* SpellEmpowerStart::Write()
for (Duration<Milliseconds, uint32> stageDuration : StageDurations)
_worldPacket << stageDuration;
- _worldPacket.WriteBit(InterruptImmunities.has_value());
- _worldPacket.WriteBit(HealPrediction.has_value());
+ _worldPacket << OptionalInit(InterruptImmunities);
+ _worldPacket << OptionalInit(HealPrediction);
_worldPacket.FlushBits();
if (InterruptImmunities)
@@ -929,12 +928,12 @@ WorldPacket const* ResurrectRequest::Write()
_worldPacket << uint32(ResurrectOffererVirtualRealmAddress);
_worldPacket << uint32(PetNumber);
_worldPacket << int32(SpellID);
- _worldPacket.WriteBits(Name.length(), 11);
- _worldPacket.WriteBit(UseTimer);
- _worldPacket.WriteBit(Sickness);
+ _worldPacket << SizedString::BitsSize<11>(Name);
+ _worldPacket << Bits<1>(UseTimer);
+ _worldPacket << Bits<1>(Sickness);
_worldPacket.FlushBits();
- _worldPacket.WriteString(Name);
+ _worldPacket << SizedString::Data(Name);
return &_worldPacket;
}
@@ -994,7 +993,7 @@ WorldPacket const* MirrorImageCreatureData::Write()
void SpellClick::Read()
{
_worldPacket >> SpellClickUnitGuid;
- TryAutoDismount = _worldPacket.ReadBit();
+ _worldPacket >> Bits<1>(TryAutoDismount);
}
WorldPacket const* ResyncRunes::Write()
@@ -1038,11 +1037,11 @@ void UpdateMissileTrajectory::Read()
_worldPacket >> Speed;
_worldPacket >> FirePos;
_worldPacket >> ImpactPos;
- bool hasStatus = _worldPacket.ReadBit();
+ _worldPacket >> OptionalInit(Status);
_worldPacket.ResetBitPos();
- if (hasStatus)
- _worldPacket >> Status.emplace();
+ if (Status)
+ _worldPacket >> *Status;
}
WorldPacket const* SpellDelayed::Write()
@@ -1093,7 +1092,7 @@ WorldPacket const* MissileCancel::Write()
{
_worldPacket << OwnerGUID;
_worldPacket << int32(SpellID);
- _worldPacket.WriteBit(Reverse);
+ _worldPacket << Bits<1>(Reverse);
_worldPacket.FlushBits();
return &_worldPacket;
@@ -1102,7 +1101,7 @@ WorldPacket const* MissileCancel::Write()
void TradeSkillSetFavorite::Read()
{
_worldPacket >> RecipeID;
- IsFavorite = _worldPacket.ReadBit();
+ _worldPacket >> Bits<1>(IsFavorite);
}
void KeyboundOverride::Read()
diff --git a/src/server/game/Server/Packets/SystemPackets.cpp b/src/server/game/Server/Packets/SystemPackets.cpp
index b380f4e9fc5..c6f7b85fcd4 100644
--- a/src/server/game/Server/Packets/SystemPackets.cpp
+++ b/src/server/game/Server/Packets/SystemPackets.cpp
@@ -148,7 +148,7 @@ WorldPacket const* FeatureSystemStatus::Write()
_worldPacket << Bits<1>(false); // unused 10.2.7
_worldPacket << Bits<1>(GuildEventsEditsEnabled);
_worldPacket << Bits<1>(GuildTradeSkillsEnabled);
- _worldPacket << BitsSize<7>(Unknown1027);
+ _worldPacket << SizedString::BitsSize<7>(Unknown1027);
_worldPacket << Bits<1>(BNSendWhisperUseV2Services);
_worldPacket << Bits<1>(BNSendGameDataUseV2Services);
_worldPacket << Bits<1>(IsAccountCurrencyTransferEnabled);
@@ -192,7 +192,7 @@ WorldPacket const* FeatureSystemStatus::Write()
_worldPacket << int32(SessionAlert->DisplayTime);
}
- _worldPacket.WriteString(Unknown1027);
+ _worldPacket << SizedString::Data(Unknown1027);
{
_worldPacket << Bits<1>(Squelch.IsSquelched);
diff --git a/src/server/game/Server/Packets/WhoPackets.cpp b/src/server/game/Server/Packets/WhoPackets.cpp
index 418ea67c4f4..5126482fe24 100644
--- a/src/server/game/Server/Packets/WhoPackets.cpp
+++ b/src/server/game/Server/Packets/WhoPackets.cpp
@@ -17,88 +17,85 @@
#include "WhoPackets.h"
-void WorldPackets::Who::WhoIsRequest::Read()
+namespace WorldPackets::Who
{
- CharName = _worldPacket.ReadString(_worldPacket.ReadBits(6));
+void WhoIsRequest::Read()
+{
+ _worldPacket >> SizedString::BitsSize<6>(CharName);
+ _worldPacket >> SizedString::Data(CharName);
}
-WorldPacket const* WorldPackets::Who::WhoIsResponse::Write()
+WorldPacket const* WhoIsResponse::Write()
{
- _worldPacket.WriteBits(AccountName.length(), 11);
+ _worldPacket << SizedString::BitsSize<11>(AccountName);
_worldPacket.FlushBits();
- _worldPacket.WriteString(AccountName);
+ _worldPacket << SizedString::Data(AccountName);
return &_worldPacket;
}
-ByteBuffer& operator>>(ByteBuffer& data, WorldPackets::Who::WhoWord& word)
+ByteBuffer& operator>>(ByteBuffer& data, WhoWord& word)
{
- word.Word = data.ReadString(data.ReadBits(7));
data.ResetBitPos();
+ data >> SizedString::BitsSize<7>(word.Word);
+ data >> SizedString::Data(word.Word);
return data;
}
-ByteBuffer& operator>>(ByteBuffer& data, Optional<WorldPackets::Who::WhoRequestServerInfo>& serverInfo)
+ByteBuffer& operator>>(ByteBuffer& data, WhoRequestServerInfo& serverInfo)
{
- serverInfo.emplace();
-
- data >> serverInfo->FactionGroup;
- data >> serverInfo->Locale;
- data >> serverInfo->RequesterVirtualRealmAddress;
+ data >> serverInfo.FactionGroup;
+ data >> serverInfo.Locale;
+ data >> serverInfo.RequesterVirtualRealmAddress;
return data;
}
-ByteBuffer& operator>>(ByteBuffer& data, WorldPackets::Who::WhoRequest& request)
+ByteBuffer& operator>>(ByteBuffer& data, WhoRequest& request)
{
data >> request.MinLevel;
data >> request.MaxLevel;
data >> request.RaceFilter.RawValue;
data >> request.ClassFilter;
-
- uint32 nameLength = data.ReadBits(6);
- uint32 virtualRealmNameLength = data.ReadBits(9);
- uint32 guildNameLength = data.ReadBits(7);
- uint32 guildVirtualRealmNameLength = data.ReadBits(9);
- request.Words.resize(data.ReadBits(3));
-
- request.ShowEnemies = data.ReadBit();
- request.ShowArenaPlayers = data.ReadBit();
- request.ExactName = data.ReadBit();
-
- bool hasWhoRequest = data.ReadBit();
- data.ResetBitPos();
+ data >> SizedString::BitsSize<6>(request.Name);
+ data >> SizedString::BitsSize<9>(request.VirtualRealmName);
+ data >> SizedString::BitsSize<7>(request.Guild);
+ data >> SizedString::BitsSize<9>(request.GuildVirtualRealmName);
+ data >> BitsSize<3>(request.Words);
+ data >> Bits<1>(request.ShowEnemies);
+ data >> Bits<1>(request.ShowArenaPlayers);
+ data >> Bits<1>(request.ExactName);
+ data >> OptionalInit(request.ServerInfo);
for (size_t i = 0; i < request.Words.size(); ++i)
data >> request.Words[i];
- request.Name = data.ReadString(nameLength);
- request.VirtualRealmName = data.ReadString(virtualRealmNameLength);
- request.Guild = data.ReadString(guildNameLength);
- request.GuildVirtualRealmName = data.ReadString(guildVirtualRealmNameLength);
+ data >> SizedString::Data(request.Name);
+ data >> SizedString::Data(request.VirtualRealmName);
+ data >> SizedString::Data(request.Guild);
+ data >> SizedString::Data(request.GuildVirtualRealmName);
- if (hasWhoRequest)
- data >> request.ServerInfo;
+ if (request.ServerInfo)
+ data >> *request.ServerInfo;
return data;
}
-void WorldPackets::Who::WhoRequestPkt::Read()
+void WhoRequestPkt::Read()
{
- Areas.resize(_worldPacket.ReadBits(4));
- IsFromAddOn = _worldPacket.ReadBit();
-
+ _worldPacket >> BitsSize<4>(Areas);
+ _worldPacket >> Bits<1>(IsAddon);
_worldPacket >> Request;
- _worldPacket >> RequestID;
+ _worldPacket >> Token;
_worldPacket >> Origin;
for (size_t i = 0; i < Areas.size(); ++i)
_worldPacket >> Areas[i];
}
-ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Who::WhoEntry const& entry)
+ByteBuffer& operator<<(ByteBuffer& data, WhoEntry const& entry)
{
data << entry.PlayerData;
@@ -106,30 +103,31 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Who::WhoEntry const& entr
data << uint32(entry.GuildVirtualRealmAddress);
data << int32(entry.AreaID);
- data.WriteBits(entry.GuildName.length(), 7);
- data.WriteBit(entry.IsGM);
+ data << SizedString::BitsSize<7>(entry.GuildName);
+ data << Bits<1>(entry.IsGM);
data.FlushBits();
- data.WriteString(entry.GuildName);
+ data << SizedString::Data(entry.GuildName);
return data;
}
-ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Who::WhoResponse const& response)
+ByteBuffer& operator<<(ByteBuffer& data, WhoResponse const& response)
{
- data.WriteBits(response.Entries.size(), 6);
+ data << BitsSize<6>(response.Entries);
data.FlushBits();
- for (WorldPackets::Who::WhoEntry const& whoEntry : response.Entries)
+ for (WhoEntry const& whoEntry : response.Entries)
data << whoEntry;
return data;
}
-WorldPacket const* WorldPackets::Who::WhoResponsePkt::Write()
+WorldPacket const* WhoResponsePkt::Write()
{
- _worldPacket << uint32(RequestID);
+ _worldPacket << uint32(Token);
_worldPacket << Response;
return &_worldPacket;
}
+}
diff --git a/src/server/game/Server/Packets/WhoPackets.h b/src/server/game/Server/Packets/WhoPackets.h
index 9f4d2ddf172..39f9c8bb272 100644
--- a/src/server/game/Server/Packets/WhoPackets.h
+++ b/src/server/game/Server/Packets/WhoPackets.h
@@ -84,9 +84,9 @@ namespace WorldPackets
void Read() override;
WhoRequest Request;
- uint32 RequestID = 0;
+ uint32 Token = 0;
uint8 Origin = 0; // 1 = Social, 2 = Chat, 3 = Item
- bool IsFromAddOn = false;
+ bool IsAddon = false;
Array<int32, 10> Areas;
};
@@ -112,7 +112,7 @@ namespace WorldPackets
WorldPacket const* Write() override;
- uint32 RequestID = 0;
+ uint32 Token = 0;
WhoResponse Response;
};
}