mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/PacketIO: Remove overriding Underlying type from ByteBuffer reads in favor of PacketUtilities::As
This commit is contained in:
@@ -282,7 +282,7 @@ void AuctionBrowseQuery::Read()
|
||||
_worldPacket >> MaxLevel;
|
||||
_worldPacket >> Unused1007_1;
|
||||
_worldPacket >> Unused1007_2;
|
||||
Filters = _worldPacket.read<AuctionHouseFilterMask, uint32>();
|
||||
_worldPacket >> As<uint32>(Filters);
|
||||
|
||||
uint32 knownPetsSize = _worldPacket.read<uint32>();
|
||||
uint32 const sizeLimit = sBattlePetSpeciesStore.GetNumRows() / (sizeof(decltype(KnownPets)::value_type) * 8) + 1;
|
||||
|
||||
@@ -30,7 +30,7 @@ void WorldPackets::Item::BuyItem::Read()
|
||||
_worldPacket >> Quantity;
|
||||
_worldPacket >> Muid;
|
||||
_worldPacket >> Slot;
|
||||
ItemType = _worldPacket.read<ItemVendorType, int32>();
|
||||
_worldPacket >> As<int32>(ItemType);
|
||||
_worldPacket >> Item;
|
||||
}
|
||||
|
||||
@@ -378,15 +378,15 @@ void WorldPackets::Item::RemoveNewItem::Read()
|
||||
void WorldPackets::Item::ChangeBagSlotFlag::Read()
|
||||
{
|
||||
_worldPacket >> BagIndex;
|
||||
FlagToChange = _worldPacket.read<BagSlotFlags, uint32>();
|
||||
On = _worldPacket.ReadBit();
|
||||
_worldPacket >> As<uint32>(FlagToChange);
|
||||
_worldPacket >> Bits<1>(On);
|
||||
}
|
||||
|
||||
void WorldPackets::Item::ChangeBankBagSlotFlag::Read()
|
||||
{
|
||||
_worldPacket >> BagIndex;
|
||||
FlagToChange = _worldPacket.read<BagSlotFlags, uint32>();
|
||||
On = _worldPacket.ReadBit();
|
||||
_worldPacket >> As<uint32>(FlagToChange);
|
||||
_worldPacket >> Bits<1>(On);
|
||||
}
|
||||
|
||||
void WorldPackets::Item::SetBackpackAutosortDisabled::Read()
|
||||
|
||||
@@ -771,7 +771,7 @@ WorldPacket const* WorldPackets::Misc::StartTimer::Write()
|
||||
|
||||
void WorldPackets::Misc::QueryCountdownTimer::Read()
|
||||
{
|
||||
TimerType = _worldPacket.read<CountdownTimerType, int32>();
|
||||
_worldPacket >> As<int32>(TimerType);
|
||||
}
|
||||
|
||||
void WorldPackets::Misc::ConversationLineStarted::Read()
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "MoveSpline.h"
|
||||
#include "MoveSplineFlag.h"
|
||||
#include "MovementTypedefs.h"
|
||||
#include "PacketUtilities.h"
|
||||
#include "Unit.h"
|
||||
#include "Util.h"
|
||||
|
||||
@@ -975,7 +976,7 @@ void WorldPackets::Movement::MoveSetCollisionHeightAck::Read()
|
||||
_worldPacket >> Data;
|
||||
_worldPacket >> Height;
|
||||
_worldPacket >> MountDisplayID;
|
||||
Reason = _worldPacket.read<UpdateCollisionHeightReason, uint8>();
|
||||
_worldPacket >> As<uint8>(Reason);
|
||||
}
|
||||
|
||||
void WorldPackets::Movement::MoveTimeSkipped::Read()
|
||||
|
||||
@@ -288,7 +288,7 @@ namespace WorldPackets
|
||||
|
||||
friend ByteBuffer& operator>>(ByteBuffer& data, Timestamp& timestamp)
|
||||
{
|
||||
timestamp._value = data.read<time_t, Underlying>();
|
||||
timestamp._value = static_cast<time_t>(data.read<Underlying>());
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ ByteBuffer& operator<<(ByteBuffer& data, TraitSubTreeCache const& traitSubTreeCa
|
||||
ByteBuffer& operator>>(ByteBuffer& data, TraitConfig& traitConfig)
|
||||
{
|
||||
data >> traitConfig.ID;
|
||||
traitConfig.Type = data.read<TraitConfigType, int32>();
|
||||
data >> As<int32>(traitConfig.Type);
|
||||
uint32 entriesSize = data.read<uint32>();
|
||||
if (entriesSize > 100)
|
||||
throw PacketArrayMaxCapacityException(entriesSize, 100);
|
||||
@@ -128,7 +128,7 @@ ByteBuffer& operator>>(ByteBuffer& data, TraitConfig& traitConfig)
|
||||
{
|
||||
case TraitConfigType::Combat:
|
||||
data >> traitConfig.ChrSpecializationID;
|
||||
traitConfig.CombatConfigFlags = data.read<TraitCombatConfigFlags, int32>();
|
||||
data >> As<int32>(traitConfig.CombatConfigFlags);
|
||||
data >> traitConfig.LocalIdentifier;
|
||||
break;
|
||||
case TraitConfigType::Profession:
|
||||
|
||||
@@ -433,24 +433,24 @@ class TC_SHARED_API ByteBuffer
|
||||
_rpos += skip;
|
||||
}
|
||||
|
||||
template <typename T, typename Underlying = T>
|
||||
template <typename T>
|
||||
T read()
|
||||
{
|
||||
ResetBitPos();
|
||||
T r = read<T, Underlying>(_rpos);
|
||||
_rpos += sizeof(Underlying);
|
||||
T r = read<T>(_rpos);
|
||||
_rpos += sizeof(T);
|
||||
return r;
|
||||
}
|
||||
|
||||
template <typename T, typename Underlying = T>
|
||||
template <typename T>
|
||||
T read(size_t pos) const
|
||||
{
|
||||
if (pos + sizeof(Underlying) > size())
|
||||
throw ByteBufferPositionException(pos, sizeof(Underlying), size());
|
||||
Underlying val;
|
||||
std::memcpy(&val, &_storage[pos], sizeof(Underlying));
|
||||
if (pos + sizeof(T) > size())
|
||||
throw ByteBufferPositionException(pos, sizeof(T), size());
|
||||
T val;
|
||||
std::memcpy(&val, &_storage[pos], sizeof(T));
|
||||
EndianConvert(val);
|
||||
return static_cast<T>(val);
|
||||
return val;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
||||
Reference in New Issue
Block a user