aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2015-07-25 10:38:45 +0200
committerShauren <shauren.trinity@gmail.com>2015-07-25 10:38:45 +0200
commit21df17fd47d08c3015c9db6434e3659b2591842b (patch)
tree2a1168ccdf78e98eecf64179f604d63650580bab /src
parent7cff7f0fc0321c2f256d7c6bc191df10441b5b3c (diff)
Core/Misc: Removed ReadAsPacked/WriteAsPacked methods from ObjectGuid, they are not needed anymore as guids are always written packed
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Calendar/CalendarMgr.cpp16
-rw-r--r--src/server/game/Entities/Object/ObjectGuid.cpp43
-rw-r--r--src/server/game/Entities/Object/ObjectGuid.h17
-rw-r--r--src/server/game/Entities/Object/Updates/UpdateData.cpp2
-rw-r--r--src/server/game/Groups/Group.cpp2
-rw-r--r--src/server/game/Guilds/Guild.cpp2
-rw-r--r--src/server/game/Handlers/CalendarHandler.cpp14
-rw-r--r--src/server/game/Handlers/ItemHandler.cpp4
-rw-r--r--src/server/game/Spells/Spell.cpp53
-rw-r--r--src/server/game/Spells/Spell.h1
-rw-r--r--src/server/shared/Packets/ByteBuffer.h2
11 files changed, 43 insertions, 113 deletions
diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp
index c22709b843b..82c8ced3801 100644
--- a/src/server/game/Calendar/CalendarMgr.cpp
+++ b/src/server/game/Calendar/CalendarMgr.cpp
@@ -429,7 +429,7 @@ void CalendarMgr::SendCalendarEventInvite(CalendarInvite const& invite)
uint8 level = player ? player->getLevel() : Player::GetLevelFromDB(invitee);
WorldPacket data(SMSG_CALENDAR_EVENT_INVITE, 8 + 8 + 8 + 1 + 1 + 1 + (statusTime ? 4 : 0) + 1);
- data << invitee.WriteAsPacked();
+ data << invitee;
data << uint64(invite.GetEventId());
data << uint64(invite.GetInviteId());
data << uint8(level);
@@ -474,7 +474,7 @@ void CalendarMgr::SendCalendarEventUpdateAlert(CalendarEvent const& calendarEven
void CalendarMgr::SendCalendarEventStatus(CalendarEvent const& calendarEvent, CalendarInvite const& invite)
{
WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_STATUS, 8 + 8 + 4 + 4 + 1 + 1 + 4);
- data << invite.GetInviteeGUID().WriteAsPacked();
+ data << invite.GetInviteeGUID();
data << uint64(calendarEvent.GetEventId());
data.AppendPackedTime(calendarEvent.GetEventTime());
data << uint32(calendarEvent.GetFlags());
@@ -498,7 +498,7 @@ void CalendarMgr::SendCalendarEventRemovedAlert(CalendarEvent const& calendarEve
void CalendarMgr::SendCalendarEventInviteRemove(CalendarEvent const& calendarEvent, CalendarInvite const& invite, uint32 flags)
{
WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_REMOVED, 8 + 4 + 4 + 1);
- data << invite.GetInviteeGUID().WriteAsPacked();
+ data << invite.GetInviteeGUID();
data << uint64(invite.GetEventId());
data << uint32(flags);
data << uint8(1); // FIXME
@@ -509,7 +509,7 @@ void CalendarMgr::SendCalendarEventInviteRemove(CalendarEvent const& calendarEve
void CalendarMgr::SendCalendarEventModeratorStatusAlert(CalendarEvent const& calendarEvent, CalendarInvite const& invite)
{
WorldPacket data(SMSG_CALENDAR_EVENT_INVITE_MODERATOR_STATUS, 8 + 8 + 1 + 1);
- data << invite.GetInviteeGUID().WriteAsPacked();
+ data << invite.GetInviteeGUID();
data << uint64(invite.GetEventId());
data << uint8(invite.GetRank());
data << uint8(1); // Unk boolean - Display to client?
@@ -533,8 +533,8 @@ void CalendarMgr::SendCalendarEventInviteAlert(CalendarEvent const& calendarEven
data << uint8(invite.GetStatus());
data << uint8(invite.GetRank());
- data << calendarEvent.GetCreatorGUID().WriteAsPacked();
- data << invite.GetSenderGUID().WriteAsPacked();
+ data << calendarEvent.GetCreatorGUID();
+ data << invite.GetSenderGUID();
if (calendarEvent.IsGuildEvent() || calendarEvent.IsGuildAnnouncement())
{
@@ -556,7 +556,7 @@ void CalendarMgr::SendCalendarEvent(ObjectGuid guid, CalendarEvent const& calend
WorldPacket data(SMSG_CALENDAR_SEND_EVENT, 60 + eventInviteeList.size() * 32);
data << uint8(sendType);
- data << calendarEvent.GetCreatorGUID().WriteAsPacked();
+ data << calendarEvent.GetCreatorGUID();
data << uint64(calendarEvent.GetEventId());
data << calendarEvent.GetTitle();
data << calendarEvent.GetDescription();
@@ -581,7 +581,7 @@ void CalendarMgr::SendCalendarEvent(ObjectGuid guid, CalendarEvent const& calend
uint8 inviteeLevel = invitee ? invitee->getLevel() : Player::GetLevelFromDB(inviteeGuid);
ObjectGuid::LowType inviteeGuildId = invitee ? invitee->GetGuildId() : Player::GetGuildIdFromDB(inviteeGuid);
- data << inviteeGuid.WriteAsPacked();
+ data << inviteeGuid;
data << uint8(inviteeLevel);
data << uint8(calendarInvite->GetStatus());
data << uint8(calendarInvite->GetRank());
diff --git a/src/server/game/Entities/Object/ObjectGuid.cpp b/src/server/game/Entities/Object/ObjectGuid.cpp
index 4d607e59d1b..af0513e2d26 100644
--- a/src/server/game/Entities/Object/ObjectGuid.cpp
+++ b/src/server/game/Entities/Object/ObjectGuid.cpp
@@ -121,31 +121,37 @@ void ObjectGuid::SetRawValue(std::vector<uint8> const& guid)
void PackedGuid::Set(ObjectGuid const& guid)
{
+ _packedGuid.clear();
+ _packedGuid << guid;
+}
+
+ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid)
+{
uint8 lowMask = 0;
uint8 highMask = 0;
- _packedGuid.clear();
- _packedGuid << uint8(lowMask);
- _packedGuid << uint8(highMask);
+ buf.FlushBits(); // flush any unwritten bits to make wpos return a meaningful value
+ std::size_t pos = buf.wpos();
+ buf << uint8(lowMask);
+ buf << uint8(highMask);
uint8 packed[8];
- if (size_t packedSize = _packedGuid.PackUInt64(guid._low, &lowMask, packed))
- _packedGuid.append(packed, packedSize);
- if (size_t packedSize = _packedGuid.PackUInt64(guid._high, &highMask, packed))
- _packedGuid.append(packed, packedSize);
+ if (size_t packedSize = ByteBuffer::PackUInt64(guid._low, &lowMask, packed))
+ buf.append(packed, packedSize);
+ if (size_t packedSize = ByteBuffer::PackUInt64(guid._high, &highMask, packed))
+ buf.append(packed, packedSize);
- _packedGuid.put(0, lowMask);
- _packedGuid.put(1, highMask);
-}
+ buf.put(pos, lowMask);
+ buf.put(pos + 1, highMask);
-ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid)
-{
- buf << guid.WriteAsPacked();
return buf;
}
ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid)
{
- buf >> guid.ReadAsPacked();
+ uint8 lowMask, highMask;
+ buf >> lowMask >> highMask;
+ buf.ReadPackedUInt64(lowMask, guid._low);
+ buf.ReadPackedUInt64(highMask, guid._high);
return buf;
}
@@ -155,15 +161,6 @@ ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid)
return buf;
}
-ByteBuffer& operator>>(ByteBuffer& buf, PackedGuidReader const& guid)
-{
- uint8 lowMask, highMask;
- buf >> lowMask >> highMask;
- buf.ReadPackedUInt64(lowMask, guid.GuidPtr->_low);
- buf.ReadPackedUInt64(highMask, guid.GuidPtr->_high);
- return buf;
-}
-
std::ostream& operator<<(std::ostream& stream, ObjectGuid const& guid)
{
std::ostringstream tmp;
diff --git a/src/server/game/Entities/Object/ObjectGuid.h b/src/server/game/Entities/Object/ObjectGuid.h
index 281bc170c3a..23d6b4f4dde 100644
--- a/src/server/game/Entities/Object/ObjectGuid.h
+++ b/src/server/game/Entities/Object/ObjectGuid.h
@@ -180,19 +180,13 @@ GUID_TRAIT_MAP_SPECIFIC(HighGuid::AILockTicket)
class ObjectGuid;
class PackedGuid;
-struct PackedGuidReader
-{
- explicit PackedGuidReader(ObjectGuid& guid) : GuidPtr(&guid) { }
- ObjectGuid* GuidPtr;
-};
-
#pragma pack(push, 1)
class ObjectGuid
{
friend std::ostream& operator<<(std::ostream& stream, ObjectGuid const& guid);
- friend ByteBuffer& operator>>(ByteBuffer& buf, PackedGuidReader const& guid);
- friend class PackedGuid;
+ friend ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid);
+ friend ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid);
public:
static ObjectGuid const Empty;
@@ -212,15 +206,11 @@ class ObjectGuid
ObjectGuid() : _low(0), _high(0) { }
ObjectGuid(ObjectGuid const&) = default;
- PackedGuidReader ReadAsPacked() { return PackedGuidReader(*this); }
-
std::vector<uint8> GetRawValue() const;
void SetRawValue(std::vector<uint8> const& guid);
void SetRawValue(uint64 high, uint64 low) { _high = high; _low = low; }
void Clear() { _high = 0; _low = 0; }
- PackedGuid WriteAsPacked() const;
-
HighGuid GetHigh() const { return HighGuid((_high >> 58) & 0x3F); }
uint32 GetRealmId() const { return uint32((_high >> 42) & 0x1FFF); }
uint32 GetMapId() const { return uint32((_high >> 29) & 0x1FFF); }
@@ -393,12 +383,9 @@ ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid);
ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid);
ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid);
-ByteBuffer& operator>>(ByteBuffer& buf, PackedGuidReader const& guid);
std::ostream& operator<<(std::ostream& stream, ObjectGuid const& guid);
-inline PackedGuid ObjectGuid::WriteAsPacked() const { return PackedGuid(*this); }
-
namespace std
{
template<>
diff --git a/src/server/game/Entities/Object/Updates/UpdateData.cpp b/src/server/game/Entities/Object/Updates/UpdateData.cpp
index 98c3c428b6e..4ceb20d02aa 100644
--- a/src/server/game/Entities/Object/Updates/UpdateData.cpp
+++ b/src/server/game/Entities/Object/Updates/UpdateData.cpp
@@ -56,7 +56,7 @@ bool UpdateData::BuildPacket(WorldPacket* packet)
*packet << uint32(m_outOfRangeGUIDs.size());
for (GuidSet::const_iterator i = m_outOfRangeGUIDs.begin(); i != m_outOfRangeGUIDs.end(); ++i)
- *packet << i->WriteAsPacked();
+ *packet << *i;
}
*packet << uint32(m_data.size());
diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp
index ceb09344182..80c6c29a7ff 100644
--- a/src/server/game/Groups/Group.cpp
+++ b/src/server/game/Groups/Group.cpp
@@ -935,7 +935,7 @@ void Group::SendLooter(Creature* creature, Player* groupLooter)
data << creature->GetGUID();
if (GetLootMethod() == MASTER_LOOT && creature->loot.hasOverThresholdItem())
- data << GetMasterLooterGuid().WriteAsPacked();
+ data << GetMasterLooterGuid();
else
data << uint8(0);
diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp
index 4083a07523c..97a965da681 100644
--- a/src/server/game/Guilds/Guild.cpp
+++ b/src/server/game/Guilds/Guild.cpp
@@ -2553,7 +2553,7 @@ void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 max
if (member->GetGUID() != session->GetPlayer()->GetGUID() && level >= minLevel && level <= maxLevel && member->IsRankNotLower(minRank))
{
- data << member->GetGUID().WriteAsPacked();
+ data << member->GetGUID();
data << uint8(level);
++count;
}
diff --git a/src/server/game/Handlers/CalendarHandler.cpp b/src/server/game/Handlers/CalendarHandler.cpp
index debbec88e34..6fabecd2468 100644
--- a/src/server/game/Handlers/CalendarHandler.cpp
+++ b/src/server/game/Handlers/CalendarHandler.cpp
@@ -69,12 +69,12 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/)
if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent((*itr)->GetEventId()))
{
data << uint8(calendarEvent->IsGuildEvent());
- data << calendarEvent->GetCreatorGUID().WriteAsPacked();
+ data << calendarEvent->GetCreatorGUID();
}
else
{
data << uint8(0);
- data << (*itr)->GetSenderGUID().WriteAsPacked();
+ data << (*itr)->GetSenderGUID();
}
}
@@ -94,7 +94,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/)
Guild* guild = sGuildMgr->GetGuildById(calendarEvent->GetGuildId());
data << (guild ? guild->GetGUID() : ObjectGuid::Empty);
- data << calendarEvent->GetCreatorGUID().WriteAsPacked();
+ data << calendarEvent->GetCreatorGUID();
}
data << uint32(currTime); // server time
@@ -269,7 +269,7 @@ void WorldSession::HandleCalendarAddEvent(WorldPacket& recvData)
for (uint32 i = 0; i < inviteCount && i < MaxPlayerInvites; ++i)
{
- recvData >> invitee[i].ReadAsPacked();
+ recvData >> invitee[i];
recvData >> status[i] >> rank[i];
}
}
@@ -571,7 +571,7 @@ void WorldSession::HandleCalendarEventRemoveInvite(WorldPacket& recvData)
uint64 ownerInviteId; // isn't it sender's inviteId?
uint64 inviteId;
- recvData >> invitee.ReadAsPacked();
+ recvData >> invitee;
recvData >> inviteId >> ownerInviteId >> eventId;
TC_LOG_DEBUG("network", "CMSG_CALENDAR_REMOVE_INVITE [%s] EventId [" UI64FMTD
@@ -601,7 +601,7 @@ void WorldSession::HandleCalendarEventStatus(WorldPacket& recvData)
uint64 ownerInviteId; // isn't it sender's inviteId?
uint8 status;
- recvData >> invitee.ReadAsPacked();
+ recvData >> invitee;
recvData >> eventId >> inviteId >> ownerInviteId >> status;
TC_LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_STATUS [%s] EventId ["
UI64FMTD "] ownerInviteId [" UI64FMTD "], Invitee ([%s] id: ["
@@ -635,7 +635,7 @@ void WorldSession::HandleCalendarEventModeratorStatus(WorldPacket& recvData)
uint64 ownerInviteId; // isn't it sender's inviteId?
uint8 rank;
- recvData >> invitee.ReadAsPacked();
+ recvData >> invitee;
recvData >> eventId >> inviteId >> ownerInviteId >> rank;
TC_LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_MODERATOR_STATUS [%s] EventId ["
UI64FMTD "] ownerInviteId [" UI64FMTD "], Invitee ([%s] id: ["
diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp
index e6aecff9137..ef65436fd52 100644
--- a/src/server/game/Handlers/ItemHandler.cpp
+++ b/src/server/game/Handlers/ItemHandler.cpp
@@ -707,8 +707,8 @@ void WorldSession::HandleAutoStoreBagItemOpcode(WorldPackets::Item::AutoStoreBag
void WorldSession::SendEnchantmentLog(ObjectGuid target, ObjectGuid caster, uint32 itemId, uint32 enchantId)
{
WorldPacket data(SMSG_ENCHANTMENT_LOG, (8+8+4+4));
- data << target.WriteAsPacked();
- data << caster.WriteAsPacked();
+ data << target;
+ data << caster;
data << uint32(itemId);
data << uint32(enchantId);
GetPlayer()->SendMessageToSet(&data, true);
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index b16d6893175..b52b5264d0a 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -157,59 +157,6 @@ SpellCastTargets::SpellCastTargets(Unit* caster, WorldPackets::Spells::SpellCast
SpellCastTargets::~SpellCastTargets() { }
-void SpellCastTargets::Read(ByteBuffer& data, Unit* caster)
-{
- data >> m_targetMask;
-
- if (m_targetMask == TARGET_FLAG_NONE)
- return;
-
- if (m_targetMask & (TARGET_FLAG_UNIT | TARGET_FLAG_UNIT_MINIPET | TARGET_FLAG_GAMEOBJECT | TARGET_FLAG_CORPSE_ENEMY | TARGET_FLAG_CORPSE_ALLY))
- data >> m_objectTargetGUID.ReadAsPacked();
-
- if (m_targetMask & (TARGET_FLAG_ITEM | TARGET_FLAG_TRADE_ITEM))
- data >> m_itemTargetGUID.ReadAsPacked();
-
- if (m_targetMask & TARGET_FLAG_SOURCE_LOCATION)
- {
- data >> m_src._transportGUID.ReadAsPacked();
- if (!m_src._transportGUID.IsEmpty())
- data >> m_src._transportOffset.PositionXYZStream();
- else
- data >> m_src._position.PositionXYZStream();
- }
- else
- {
- m_src._transportGUID = caster->GetTransGUID();
- if (!m_src._transportGUID.IsEmpty())
- m_src._transportOffset.Relocate(caster->GetTransOffsetX(), caster->GetTransOffsetY(), caster->GetTransOffsetZ(), caster->GetTransOffsetO());
- else
- m_src._position.Relocate(caster);
- }
-
- if (m_targetMask & TARGET_FLAG_DEST_LOCATION)
- {
- data >> m_dst._transportGUID.ReadAsPacked();
- if (!m_dst._transportGUID.IsEmpty())
- data >> m_dst._transportOffset.PositionXYZStream();
- else
- data >> m_dst._position.PositionXYZStream();
- }
- else
- {
- m_dst._transportGUID = caster->GetTransGUID();
- if (!m_dst._transportGUID.IsEmpty())
- m_dst._transportOffset.Relocate(caster->GetTransOffsetX(), caster->GetTransOffsetY(), caster->GetTransOffsetZ(), caster->GetTransOffsetO());
- else
- m_dst._position.Relocate(caster);
- }
-
- if (m_targetMask & TARGET_FLAG_STRING)
- data >> m_strTarget;
-
- Update(caster);
-}
-
void SpellCastTargets::Write(WorldPackets::Spells::SpellTargetData& data)
{
data.Flags = m_targetMask;
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index 1b370c8fa28..183f4039711 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -149,7 +149,6 @@ class SpellCastTargets
SpellCastTargets(Unit* caster, WorldPackets::Spells::SpellCastRequest const& spellCastRequest);
~SpellCastTargets();
- void Read(ByteBuffer& data, Unit* caster);
void Write(WorldPackets::Spells::SpellTargetData& data);
uint32 GetTargetMask() const { return m_targetMask; }
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h
index 0fa500c7c65..417e2f4b7b4 100644
--- a/src/server/shared/Packets/ByteBuffer.h
+++ b/src/server/shared/Packets/ByteBuffer.h
@@ -658,7 +658,7 @@ class ByteBuffer
put<uint8>(pos, mask);
}
- size_t PackUInt64(uint64 value, uint8* mask, uint8* result) const
+ static size_t PackUInt64(uint64 value, uint8* mask, uint8* result)
{
size_t resultSize = 0;
*mask = 0;