aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/base/characters_database.sql22
-rw-r--r--sql/updates/characters/2014_10_23_00_characters.sql16
-rw-r--r--src/server/game/Achievements/AchievementMgr.cpp22
-rw-r--r--src/server/game/AuctionHouse/AuctionHouseMgr.cpp2
-rw-r--r--src/server/game/Calendar/CalendarMgr.cpp2
-rw-r--r--src/server/game/Chat/Channels/Channel.cpp5
-rw-r--r--src/server/game/Conditions/ConditionMgr.cpp6
-rw-r--r--src/server/game/DungeonFinding/LFGQueue.cpp16
-rw-r--r--src/server/game/Entities/Object/ObjectGuid.cpp49
-rw-r--r--src/server/game/Entities/Object/ObjectGuid.h86
-rw-r--r--src/server/game/Entities/Pet/Pet.cpp5
-rw-r--r--src/server/game/Entities/Player/Player.cpp17
-rw-r--r--src/server/game/Groups/Group.cpp18
-rw-r--r--src/server/game/Handlers/CharacterHandler.cpp8
-rw-r--r--src/server/game/Handlers/VoidStorageHandler.cpp16
-rw-r--r--src/server/game/Movement/Spline/MoveSpline.cpp2
-rw-r--r--src/server/game/Movement/Spline/MoveSplineInit.cpp2
-rw-r--r--src/server/game/Movement/Spline/MoveSplineInitArgs.h15
-rw-r--r--src/server/game/Spells/Spell.cpp8
-rw-r--r--src/server/game/Texts/CreatureTextMgr.h3
-rw-r--r--src/server/game/Tickets/TicketMgr.cpp2
-rw-r--r--src/server/scripts/Commands/cs_ticket.cpp2
-rw-r--r--src/server/shared/Packets/ByteBuffer.h65
23 files changed, 239 insertions, 150 deletions
diff --git a/sql/base/characters_database.sql b/sql/base/characters_database.sql
index f61701cc4bf..440ebbb7066 100644
--- a/sql/base/characters_database.sql
+++ b/sql/base/characters_database.sql
@@ -483,8 +483,8 @@ DROP TABLE IF EXISTS `character_aura`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `character_aura` (
`guid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier',
- `caster_guid` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'Full Global Unique Identifier',
- `item_guid` bigint(20) unsigned NOT NULL DEFAULT '0',
+ `caster_guid` binary(16) NOT NULL COMMENT 'Full Global Unique Identifier',
+ `item_guid` binary(16) unsigned NOT NULL DEFAULT '0',
`spell` mediumint(8) unsigned NOT NULL DEFAULT '0',
`effect_mask` tinyint(3) unsigned NOT NULL DEFAULT '0',
`recalculate_mask` tinyint(3) unsigned NOT NULL DEFAULT '0',
@@ -1705,14 +1705,14 @@ CREATE TABLE `groups` (
`lootMethod` tinyint(3) unsigned NOT NULL,
`looterGuid` int(10) unsigned NOT NULL,
`lootThreshold` tinyint(3) unsigned NOT NULL,
- `icon1` bigint(20) unsigned NOT NULL,
- `icon2` bigint(20) unsigned NOT NULL,
- `icon3` bigint(20) unsigned NOT NULL,
- `icon4` bigint(20) unsigned NOT NULL,
- `icon5` bigint(20) unsigned NOT NULL,
- `icon6` bigint(20) unsigned NOT NULL,
- `icon7` bigint(20) unsigned NOT NULL,
- `icon8` bigint(20) unsigned NOT NULL,
+ `icon1` binary(16) NOT NULL,
+ `icon2` binary(16) NOT NULL,
+ `icon3` binary(16) NOT NULL,
+ `icon4` binary(16) NOT NULL,
+ `icon5` binary(16) NOT NULL,
+ `icon6` binary(16) NOT NULL,
+ `icon7` binary(16) NOT NULL,
+ `icon8` binary(16) NOT NULL,
`groupType` tinyint(3) unsigned NOT NULL,
`difficulty` tinyint(3) unsigned NOT NULL DEFAULT '0',
`raiddifficulty` tinyint(3) unsigned NOT NULL DEFAULT '0',
@@ -2453,7 +2453,7 @@ DROP TABLE IF EXISTS `pet_aura`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `pet_aura` (
`guid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'Global Unique Identifier',
- `caster_guid` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'Full Global Unique Identifier',
+ `caster_guid` binary(16) NOT NULL DEFAULT '0' COMMENT 'Full Global Unique Identifier',
`spell` mediumint(8) unsigned NOT NULL DEFAULT '0',
`effect_mask` tinyint(3) unsigned NOT NULL DEFAULT '0',
`recalculate_mask` tinyint(3) unsigned NOT NULL DEFAULT '0',
diff --git a/sql/updates/characters/2014_10_23_00_characters.sql b/sql/updates/characters/2014_10_23_00_characters.sql
new file mode 100644
index 00000000000..e6ee7048ac6
--- /dev/null
+++ b/sql/updates/characters/2014_10_23_00_characters.sql
@@ -0,0 +1,16 @@
+TRUNCATE `character_aura`;
+TRUNCATE `pet_aura`;
+TRUNCATE `group_instance`;
+TRUNCATE `group_member`;
+TRUNCATE `groups`;
+ALTER TABLE `character_aura` CHANGE `caster_guid` `caster_guid` binary(16) NOT NULL COMMENT 'Full Global Unique Identifier';
+ALTER TABLE `character_aura` CHANGE `item_guid` `item_guid` binary(16) NOT NULL;
+ALTER TABLE `pet_aura` CHANGE `caster_guid` `caster_guid` binary(16) NOT NULL COMMENT 'Full Global Unique Identifier';
+ALTER TABLE `groups` CHANGE `icon1` `icon1` binary(16) NOT NULL;
+ALTER TABLE `groups` CHANGE `icon2` `icon2` binary(16) NOT NULL;
+ALTER TABLE `groups` CHANGE `icon3` `icon3` binary(16) NOT NULL;
+ALTER TABLE `groups` CHANGE `icon4` `icon4` binary(16) NOT NULL;
+ALTER TABLE `groups` CHANGE `icon5` `icon5` binary(16) NOT NULL;
+ALTER TABLE `groups` CHANGE `icon6` `icon6` binary(16) NOT NULL;
+ALTER TABLE `groups` CHANGE `icon7` `icon7` binary(16) NOT NULL;
+ALTER TABLE `groups` CHANGE `icon8` `icon8` binary(16) NOT NULL;
diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp
index cd2bc8b13d4..3d36b615b61 100644
--- a/src/server/game/Achievements/AchievementMgr.cpp
+++ b/src/server/game/Achievements/AchievementMgr.cpp
@@ -931,7 +931,7 @@ void AchievementMgr<Player>::SendCriteriaUpdate(AchievementCriteriaEntry const*
data << uint32(entry->ID);
// the counter is packed like a packed Guid
- data.appendPackGUID(progress->counter);
+ data.AppendPackedUInt64(progress->counter);
data << GetOwner()->GetPackGUID();
if (!entry->timeLimit)
@@ -947,10 +947,11 @@ void AchievementMgr<Player>::SendCriteriaUpdate(AchievementCriteriaEntry const*
template<>
void AchievementMgr<Guild>::SendCriteriaUpdate(AchievementCriteriaEntry const* entry, CriteriaProgress const* progress, uint32 /*timeElapsed*/, bool /*timedCompleted*/) const
{
+ /*
//will send response to criteria progress request
WorldPacket data(SMSG_GUILD_CRITERIA_DATA, 3 + 1 + 1 + 8 + 8 + 4 + 4 + 4 + 4 + 4);
- ObjectGuid counter(progress->counter); // for accessing every byte individually
+ ObjectGuid counter(0, progress->counter); // for accessing every byte individually
ObjectGuid guid = progress->CompletedGUID;
data.WriteBits(1, 21);
@@ -996,6 +997,7 @@ void AchievementMgr<Guild>::SendCriteriaUpdate(AchievementCriteriaEntry const* e
data.WriteByteSeq(guid[0]);
GetOwner()->BroadcastPacketIfTrackingAchievement(&data, entry->ID);
+ */
}
template<class T>
@@ -1006,6 +1008,7 @@ void AchievementMgr<T>::SendAllTrackedCriterias(Player* /*receiver*/, std::set<u
template<>
void AchievementMgr<Guild>::SendAllTrackedCriterias(Player* receiver, std::set<uint32> const& trackedCriterias) const
{
+ /*
ObjectGuid counter;
ObjectGuid guid;
uint32 trackedCriteriasCount = 0;
@@ -1034,7 +1037,7 @@ void AchievementMgr<Guild>::SendAllTrackedCriterias(Player* receiver, std::set<u
if (progress == m_criteriaProgress.end())
continue;
- counter.Set(progress->second.counter);
+ counter.SetRawValue(progress->second.counter);
guid = progress->second.CompletedGUID;
criteriaBits.WriteBit(counter[4]);
@@ -1084,6 +1087,7 @@ void AchievementMgr<Guild>::SendAllTrackedCriterias(Player* receiver, std::set<u
data.append(criteriaData);
receiver->GetSession()->SendPacket(&data);
+ */
}
/**
@@ -2031,6 +2035,7 @@ struct VisibleAchievementPred
template<class T>
void AchievementMgr<T>::SendAllAchievementData(Player* /*receiver*/) const
{
+ /*
VisibleAchievementPred isVisible;
size_t numCriteria = m_criteriaProgress.size();
size_t numAchievements = std::count_if(m_completedAchievements.begin(), m_completedAchievements.end(), isVisible);
@@ -2042,7 +2047,7 @@ void AchievementMgr<T>::SendAllAchievementData(Player* /*receiver*/) const
data.WriteBits(numCriteria, 21);
for (CriteriaProgressMap::const_iterator itr = m_criteriaProgress.begin(); itr != m_criteriaProgress.end(); ++itr)
{
- counter.Set(itr->second.counter);
+ counter.SetRawValue(itr->second.counter);
data.WriteBit(guid[4]);
data.WriteBit(counter[3]);
@@ -2098,6 +2103,7 @@ void AchievementMgr<T>::SendAllAchievementData(Player* /*receiver*/) const
}
SendPacket(&data);
+ */
}
template<>
@@ -2126,6 +2132,7 @@ void AchievementMgr<Guild>::SendAllAchievementData(Player* receiver) const
template<>
void AchievementMgr<Player>::SendAchievementInfo(Player* receiver, uint32 /*achievementId = 0 */) const
{
+ /*
ObjectGuid guid = GetOwner()->GetGUID();
ObjectGuid counter;
@@ -2145,7 +2152,7 @@ void AchievementMgr<Player>::SendAchievementInfo(Player* receiver, uint32 /*achi
data.WriteBit(guid[2]);
for (CriteriaProgressMap::const_iterator itr = m_criteriaProgress.begin(); itr != m_criteriaProgress.end(); ++itr)
{
- counter.Set(itr->second.counter);
+ counter.SetRawValue(itr->second.counter);
data.WriteBit(counter[5]);
data.WriteBit(counter[3]);
@@ -2211,11 +2218,13 @@ void AchievementMgr<Player>::SendAchievementInfo(Player* receiver, uint32 /*achi
data.WriteByteSeq(guid[5]);
receiver->GetSession()->SendPacket(&data);
+ */
}
template<>
void AchievementMgr<Guild>::SendAchievementInfo(Player* receiver, uint32 achievementId /*= 0*/) const
{
+ /*
//will send response to criteria progress request
AchievementCriteriaEntryList const* criteria = sAchievementMgr->GetAchievementCriteriaByAchievement(achievementId);
if (!criteria)
@@ -2252,7 +2261,7 @@ void AchievementMgr<Guild>::SendAchievementInfo(Player* receiver, uint32 achieve
if (progress == m_criteriaProgress.end())
continue;
- counter.Set(progress->second.counter);
+ counter.SetRawValue(progress->second.counter);
guid = progress->second.CompletedGUID;
criteriaBits.WriteBit(counter[4]);
@@ -2301,6 +2310,7 @@ void AchievementMgr<Guild>::SendAchievementInfo(Player* receiver, uint32 achieve
data.append(criteriaData);
receiver->GetSession()->SendPacket(&data);
+ */
}
template<class T>
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
index 60e52388357..78dc7e2d14c 100644
--- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
+++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
@@ -757,7 +757,7 @@ std::string AuctionEntry::BuildAuctionMailBody(uint64 lowGuid, uint32 bid, uint3
{
std::ostringstream strm;
strm.width(16);
- strm << std::right << std::hex << ObjectGuid(HIGHGUID_PLAYER, lowGuid).GetRawValue(); // HIGHGUID_PLAYER always present, even for empty guids
+ strm << std::right << std::hex << ObjectGuid(HIGHGUID_PLAYER, lowGuid); // HIGHGUID_PLAYER always present, even for empty guids
strm << std::dec << ':' << bid << ':' << buyout;
strm << ':' << deposit << ':' << cut;
return strm.str();
diff --git a/src/server/game/Calendar/CalendarMgr.cpp b/src/server/game/Calendar/CalendarMgr.cpp
index 21cdda14a41..d279390b3e8 100644
--- a/src/server/game/Calendar/CalendarMgr.cpp
+++ b/src/server/game/Calendar/CalendarMgr.cpp
@@ -400,7 +400,7 @@ uint32 CalendarMgr::GetPlayerNumPending(ObjectGuid guid)
std::string CalendarEvent::BuildCalendarMailSubject(ObjectGuid remover) const
{
std::ostringstream strm;
- strm << remover.GetRawValue() << ':' << _title;
+ strm << remover << ':' << _title;
return strm.str();
}
diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp
index b35857a8c52..d69230183a8 100644
--- a/src/server/game/Chat/Channels/Channel.cpp
+++ b/src/server/game/Chat/Channels/Channel.cpp
@@ -80,7 +80,8 @@ Channel::Channel(std::string const& name, uint32 channelId, uint32 team):
Tokenizer tokens(db_BannedList, ' ');
for (Tokenizer::const_iterator i = tokens.begin(); i != tokens.end(); ++i)
{
- ObjectGuid banned_guid(uint64(strtoull(*i, NULL, 10)));
+ std::string bannedGuidStr(*i);
+ ObjectGuid banned_guid(uint64(strtoull(bannedGuidStr.substr(0, 16).c_str(), NULL, 16)), uint64(strtoull(bannedGuidStr.substr(16).c_str(), NULL, 16)));
if (!banned_guid.IsEmpty())
{
TC_LOG_DEBUG("chat.system", "Channel(%s) loaded bannedStore %s", name.c_str(), banned_guid.ToString().c_str());
@@ -110,7 +111,7 @@ void Channel::UpdateChannelInDB() const
std::ostringstream banlist;
BannedContainer::const_iterator iter;
for (iter = bannedStore.begin(); iter != bannedStore.end(); ++iter)
- banlist << iter->GetRawValue() << ' ';
+ banlist << *iter << ' ';
std::string banListStr = banlist.str();
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
index 921b6832d67..d6507f6813c 100644
--- a/src/server/game/Conditions/ConditionMgr.cpp
+++ b/src/server/game/Conditions/ConditionMgr.cpp
@@ -166,9 +166,9 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
case INSTANCE_INFO_DATA:
condMeets = instance->GetData(ConditionValue1) == ConditionValue2;
break;
- case INSTANCE_INFO_GUID_DATA:
- condMeets = instance->GetGuidData(ConditionValue1) == ObjectGuid(uint64(ConditionValue2));
- break;
+ //case INSTANCE_INFO_GUID_DATA:
+ // condMeets = instance->GetGuidData(ConditionValue1) == ObjectGuid(uint64(ConditionValue2));
+ // break;
case INSTANCE_INFO_BOSS_STATE:
condMeets = instance->GetBossState(ConditionValue1) == EncounterState(ConditionValue2);
break;
diff --git a/src/server/game/DungeonFinding/LFGQueue.cpp b/src/server/game/DungeonFinding/LFGQueue.cpp
index c5ec92ba29a..e67757d3661 100644
--- a/src/server/game/DungeonFinding/LFGQueue.cpp
+++ b/src/server/game/DungeonFinding/LFGQueue.cpp
@@ -47,9 +47,9 @@ std::string ConcatenateGuids(GuidList const& check)
std::ostringstream o;
GuidSet::const_iterator it = guids.begin();
- o << it->GetRawValue();
+ o << *it;
for (++it; it != guids.end(); ++it)
- o << '|' << it->GetRawValue();
+ o << '|' << *it;
return o.str();
}
@@ -102,7 +102,7 @@ void LFGQueue::RemoveFromQueue(ObjectGuid guid)
RemoveFromCompatibles(guid);
std::ostringstream o;
- o << guid.GetRawValue();
+ o << guid;
std::string sguid = o.str();
LfgQueueDataContainer::iterator itDelete = QueueDataStore.end();
@@ -191,7 +191,7 @@ void LFGQueue::UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId)
void LFGQueue::RemoveFromCompatibles(ObjectGuid guid)
{
std::stringstream out;
- out << guid.GetRawValue();
+ out << guid;
std::string strGuid = out.str();
TC_LOG_DEBUG("lfg.queue.data.compatibles.remove", "Removing %s", guid.ToString().c_str());
@@ -436,7 +436,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(GuidList check)
{
std::ostringstream o;
for (LfgRolesMap::const_iterator it = debugRoles.begin(); it != debugRoles.end(); ++it)
- o << ", " << it->first.GetRawValue() << ": " << GetRolesString(it->second);
+ o << ", " << it->first << ": " << GetRolesString(it->second);
TC_LOG_DEBUG("lfg.queue.match.compatibility.check", "Guids: (%s) Roles not compatible%s", strGuids.c_str(), o.str().c_str());
SetCompatibles(strGuids, LFG_INCOMPATIBLES_NO_ROLES);
@@ -446,12 +446,12 @@ LfgCompatibility LFGQueue::CheckCompatibility(GuidList check)
GuidList::iterator itguid = check.begin();
proposalDungeons = QueueDataStore[*itguid].dungeons;
std::ostringstream o;
- o << ", " << itguid->GetRawValue() << ": (" << ConcatenateDungeons(proposalDungeons) << ")";
+ o << ", " << *itguid << ": (" << ConcatenateDungeons(proposalDungeons) << ")";
for (++itguid; itguid != check.end(); ++itguid)
{
LfgDungeonSet temporal;
LfgDungeonSet& dungeons = QueueDataStore[*itguid].dungeons;
- o << ", " << itguid->GetRawValue() << ": (" << ConcatenateDungeons(dungeons) << ")";
+ o << ", " << *itguid << ": (" << ConcatenateDungeons(dungeons) << ")";
std::set_intersection(proposalDungeons.begin(), proposalDungeons.end(), dungeons.begin(), dungeons.end(), std::inserter(temporal, temporal.begin()));
proposalDungeons = temporal;
}
@@ -639,7 +639,7 @@ void LFGQueue::FindBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueu
{
TC_LOG_DEBUG("lfg.queue.compatibles.find", "%s", itrQueue->first.ToString().c_str());
std::ostringstream o;
- o << itrQueue->first.GetRawValue();
+ o << itrQueue->first;
std::string sguid = o.str();
for (LfgCompatibleContainer::const_iterator itr = CompatibleMapStore.begin(); itr != CompatibleMapStore.end(); ++itr)
diff --git a/src/server/game/Entities/Object/ObjectGuid.cpp b/src/server/game/Entities/Object/ObjectGuid.cpp
index 81442ac37ad..9f40b914c58 100644
--- a/src/server/game/Entities/Object/ObjectGuid.cpp
+++ b/src/server/game/Entities/Object/ObjectGuid.cpp
@@ -51,7 +51,7 @@ char const* ObjectGuid::GetTypeName(HighGuid high)
std::string ObjectGuid::ToString() const
{
std::ostringstream str;
- str << "GUID Full: 0x" << std::hex << std::setw(16) << std::setfill('0') << _guid << std::dec;
+ str << "GUID Full: 0x" << std::hex << std::setw(16) << std::setfill('0') << _low << std::dec;
str << " Type: " << GetTypeName();
if (HasEntry())
str << (IsPet() ? " Pet number: " : " Entry: ") << GetEntry() << " ";
@@ -60,6 +60,36 @@ std::string ObjectGuid::ToString() const
return str.str();
}
+std::vector<uint8> ObjectGuid::GetRawValue() const
+{
+ std::vector<uint8> raw(16);
+ memcpy(raw.data(), this, sizeof(*this));
+ return raw;
+}
+
+void ObjectGuid::SetRawValue(std::vector<uint8> const& guid)
+{
+ ASSERT(guid.size() == sizeof(*this));
+ memcpy(this, guid.data(), sizeof(*this));
+}
+
+void PackedGuid::Set(ObjectGuid guid)
+{
+ uint8 lowMask = 0;
+ uint8 highMask = 0;
+ _packedGuid << uint8(lowMask);
+ _packedGuid << 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);
+
+ _packedGuid.put(0, lowMask);
+ _packedGuid.put(1, highMask);
+}
+
template<HighGuid high>
uint64 ObjectGuidGenerator<high>::Generate()
{
@@ -73,13 +103,13 @@ uint64 ObjectGuidGenerator<high>::Generate()
ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid)
{
- buf << uint64(guid.GetRawValue());
+ buf << guid.WriteAsPacked();
return buf;
}
ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid)
{
- guid.Set(buf.read<uint64>());
+ buf >> guid.ReadAsPacked();
return buf;
}
@@ -91,10 +121,21 @@ ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid)
ByteBuffer& operator>>(ByteBuffer& buf, PackedGuidReader const& guid)
{
- buf.readPackGUID(*reinterpret_cast<uint64*>(guid.GuidPtr));
+ 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;
+ tmp << std::hex << std::setw(16) << std::setfill('0') << guid._high << std::setw(16) << std::setfill('0') << guid._low;
+ stream << tmp.str();
+ return stream;
+}
+
template uint64 ObjectGuidGenerator<HIGHGUID_ITEM>::Generate();
template uint64 ObjectGuidGenerator<HIGHGUID_PLAYER>::Generate();
template uint64 ObjectGuidGenerator<HIGHGUID_GAMEOBJECT>::Generate();
diff --git a/src/server/game/Entities/Object/ObjectGuid.h b/src/server/game/Entities/Object/ObjectGuid.h
index 039cd6aad8b..6cefc8bc34e 100644
--- a/src/server/game/Entities/Object/ObjectGuid.h
+++ b/src/server/game/Entities/Object/ObjectGuid.h
@@ -21,6 +21,7 @@
#include "Common.h"
#include "ByteBuffer.h"
+#include <boost/functional/hash.hpp>
#include <functional>
@@ -82,34 +83,40 @@ struct PackedGuidReader
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;
+
public:
static ObjectGuid const Empty;
- ObjectGuid() { _guid = UI64LIT(0); }
- explicit ObjectGuid(uint64 guid) { _guid = guid; }
- ObjectGuid(HighGuid hi, uint32 entry, uint64 counter) { _guid = counter ? uint64(counter) | (uint64(entry) << 32) | (uint64(hi) << ((hi == HIGHGUID_CORPSE || hi == HIGHGUID_AREATRIGGER) ? 48 : 52)) : 0; }
- ObjectGuid(HighGuid hi, uint64 counter) { _guid = counter ? uint64(counter) | (uint64(hi) << ((hi == HIGHGUID_CORPSE || hi == HIGHGUID_AREATRIGGER) ? 48 : 52)) : 0; }
+ ObjectGuid() : _low(0), _high(0) { }
+ ObjectGuid(uint64 high, uint64 low) : _low(low), _high(high) { }
+ ObjectGuid(HighGuid hi, uint32 entry, uint64 counter) : _low(counter ? uint64(counter) | (uint64(entry) << 32) | (uint64(hi) << ((hi == HIGHGUID_CORPSE || hi == HIGHGUID_AREATRIGGER) ? 48 : 52)) : 0), _high(0) { }
+ ObjectGuid(HighGuid hi, uint64 counter) : _low(counter ? uint64(counter) | (uint64(hi) << ((hi == HIGHGUID_CORPSE || hi == HIGHGUID_AREATRIGGER) ? 48 : 52)) : 0), _high(0) { }
+ ObjectGuid(ObjectGuid const&) = default;
- operator uint64() const { return _guid; }
- DECLSPEC_DEPRECATED PackedGuidReader ReadAsPacked() ATTR_DEPRECATED { return PackedGuidReader(*this); }
+ PackedGuidReader ReadAsPacked() { return PackedGuidReader(*this); }
- void Set(uint64 guid) { _guid = guid; }
- void Clear() { _guid = 0; }
+ std::vector<uint8> GetRawValue() const;
+ void SetRawValue(std::vector<uint8> const& guid);
+ void Clear() { _low = 0; }
- DECLSPEC_DEPRECATED PackedGuid WriteAsPacked() const ATTR_DEPRECATED;
+ PackedGuid WriteAsPacked() const;
- uint64 GetRawValue() const { return _guid; }
HighGuid GetHigh() const
{
- uint32 temp = ((uint64(_guid) >> 48) & 0x0000FFFF);
+ uint32 temp = ((uint64(_low) >> 48) & 0x0000FFFF);
return HighGuid((temp == HIGHGUID_CORPSE || temp == HIGHGUID_AREATRIGGER) ? temp : ((temp >> 4) & 0x00000FFF));
}
- uint32 GetEntry() const { return HasEntry() ? uint32((_guid >> 32) & UI64LIT(0x00000000000FFFFF)) : 0; }
- uint32 GetCounter() const
+ uint32 GetEntry() const { return HasEntry() ? uint32((_low >> 32) & UI64LIT(0x00000000000FFFFF)) : 0; }
+ uint32 GetCounter() const
{
- return uint32(_guid & UI64LIT(0x00000000FFFFFFFF));
+ return uint32(_low & UI64LIT(0x00000000FFFFFFFF));
}
static uint32 GetMaxCounter(HighGuid /*high*/)
@@ -119,19 +126,19 @@ class ObjectGuid
uint32 GetMaxCounter() const { return GetMaxCounter(GetHigh()); }
- DECLSPEC_DEPRECATED uint8& operator[](uint32 index) ATTR_DEPRECATED
+ uint8& operator[](uint32 index)
{
- ASSERT(index < sizeof(uint64));
- return ((uint8*)&_guid)[index];
+ ASSERT(index < sizeof(uint64) * 2);
+ return ((uint8*)&_low)[index];
}
- DECLSPEC_DEPRECATED uint8 const& operator[](uint32 index) const ATTR_DEPRECATED
+ uint8 const& operator[](uint32 index) const
{
- ASSERT(index < sizeof(uint64));
- return ((uint8 const*)&_guid)[index];
+ ASSERT(index < sizeof(uint64) * 2);
+ return ((uint8 const*)&_low)[index];
}
- bool IsEmpty() const { return _guid == 0; }
+ bool IsEmpty() const { return _low == 0 && _high == 0; }
bool IsCreature() const { return GetHigh() == HIGHGUID_UNIT; }
bool IsPet() const { return GetHigh() == HIGHGUID_PET; }
bool IsVehicle() const { return GetHigh() == HIGHGUID_VEHICLE; }
@@ -180,9 +187,17 @@ class ObjectGuid
TypeID GetTypeId() const { return GetTypeId(GetHigh()); }
bool operator!() const { return IsEmpty(); }
- bool operator== (ObjectGuid const& guid) const { return GetRawValue() == guid.GetRawValue(); }
- bool operator!= (ObjectGuid const& guid) const { return GetRawValue() != guid.GetRawValue(); }
- bool operator< (ObjectGuid const& guid) const { return GetRawValue() < guid.GetRawValue(); }
+ bool operator== (ObjectGuid const& guid) const { return _low == guid._low && _high == guid._high; }
+ bool operator!= (ObjectGuid const& guid) const { return !(*this == guid); }
+ bool operator< (ObjectGuid const& guid) const
+ {
+ if (_high < guid._high)
+ return true;
+ else if (_high > guid._high)
+ return false;
+
+ return _low < guid._low;
+ }
static char const* GetTypeName(HighGuid high);
char const* GetTypeName() const { return !IsEmpty() ? GetTypeName(GetHigh()) : "None"; }
@@ -215,29 +230,30 @@ class ObjectGuid
explicit ObjectGuid(uint32 const&) = delete; // no implementation, used to catch wrong type assignment
- uint64 _guid;
+ uint64 _low;
+ uint64 _high;
};
+#pragma pack(pop)
+
// Some Shared defines
typedef std::set<ObjectGuid> GuidSet;
typedef std::list<ObjectGuid> GuidList;
typedef std::deque<ObjectGuid> GuidDeque;
typedef std::vector<ObjectGuid> GuidVector;
-// minimum buffer size for packed guid is 9 bytes
-#define PACKED_GUID_MIN_BUFFER_SIZE 9
+// maximum buffer size for packed guid is 18 bytes
+#define PACKED_GUID_MIN_BUFFER_SIZE 18
class PackedGuid
{
friend ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid);
public:
- explicit PackedGuid() : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid.appendPackGUID(0); }
- explicit PackedGuid(uint64 guid) : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid.appendPackGUID(guid); }
- explicit PackedGuid(ObjectGuid guid) : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid.appendPackGUID(guid.GetRawValue()); }
+ explicit PackedGuid() : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid << uint16(0); }
+ explicit PackedGuid(ObjectGuid guid) : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { Set(guid); }
- void Set(uint64 guid) { _packedGuid.wpos(0); _packedGuid.appendPackGUID(guid); }
- void Set(ObjectGuid guid) { _packedGuid.wpos(0); _packedGuid.appendPackGUID(guid.GetRawValue()); }
+ void Set(ObjectGuid guid);
size_t size() const { return _packedGuid.size(); }
@@ -251,7 +267,7 @@ class ObjectGuidGenerator
public:
explicit ObjectGuidGenerator(uint64 start = 1) : _nextGuid(start) { }
- void Set(uint32 val) { _nextGuid = val; }
+ void Set(uint64 val) { _nextGuid = val; }
uint64 Generate();
uint64 GetNextAfterMaxUsed() const { return _nextGuid; }
@@ -265,6 +281,8 @@ 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
@@ -275,7 +293,7 @@ namespace std
public:
size_t operator()(ObjectGuid const& key) const
{
- return hash<uint64>()(key.GetRawValue());
+ return boost::hash_range(reinterpret_cast<uint64 const*>(&key), reinterpret_cast<uint64 const*>(&key) + 2);
}
};
}
diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp
index 737cf23a62a..3934d7da9aa 100644
--- a/src/server/game/Entities/Pet/Pet.cpp
+++ b/src/server/game/Entities/Pet/Pet.cpp
@@ -1221,12 +1221,13 @@ void Pet::_LoadAuras(uint32 timediff)
if (result)
{
+ ObjectGuid caster_guid;
do
{
int32 damage[3];
int32 baseDamage[3];
Field* fields = result->Fetch();
- ObjectGuid caster_guid(fields[0].GetUInt64());
+ caster_guid.SetRawValue(fields[0].GetBinary());
// NULL guid stored - pet is the caster of the spell - see Pet::_SaveAuras
if (!caster_guid)
caster_guid = GetGUID();
@@ -1327,7 +1328,7 @@ void Pet::_SaveAuras(SQLTransaction& trans)
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_AURA);
stmt->setUInt32(index++, m_charmInfo->GetPetNumber());
- stmt->setUInt64(index++, casterGUID.GetRawValue());
+ stmt->setBinary(index++, casterGUID.GetRawValue());
stmt->setUInt32(index++, itr->second->GetId());
stmt->setUInt8(index++, effMask);
stmt->setUInt8(index++, recalculateMask);
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 26cd886c102..495e8109145 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -18041,12 +18041,13 @@ void Player::_LoadAuras(PreparedQueryResult result, uint32 timediff)
if (result)
{
+ ObjectGuid caster_guid;
do
{
Field* fields = result->Fetch();
int32 damage[3];
int32 baseDamage[3];
- ObjectGuid caster_guid(fields[0].GetUInt64());
+ caster_guid.SetRawValue(fields[0].GetBinary());
uint32 spellid = fields[1].GetUInt32();
uint8 effmask = fields[2].GetUInt8();
uint8 recalculatemask = fields[3].GetUInt8();
@@ -19772,8 +19773,8 @@ void Player::_SaveAuras(SQLTransaction& trans)
uint8 index = 0;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_AURA);
stmt->setUInt32(index++, GetGUID().GetCounter());
- stmt->setUInt64(index++, itr->second->GetCasterGUID().GetRawValue());
- stmt->setUInt64(index++, itr->second->GetCastItemGUID().GetRawValue());
+ stmt->setBinary(index++, itr->second->GetCasterGUID().GetRawValue());
+ stmt->setBinary(index++, itr->second->GetCastItemGUID().GetRawValue());
stmt->setUInt32(index++, itr->second->GetId());
stmt->setUInt8(index++, effMask);
stmt->setUInt8(index++, recalculateMask);
@@ -23172,7 +23173,7 @@ void Player::UpdateVisibilityOf(T* target, UpdateData& data, std::set<Unit*>& vi
m_clientGUIDs.erase(target->GetGUID());
#ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "Object %u (Type: %u, Entry: %u) is out of range for player %u. Distance = %f", target->GetGUIDLow(), target->GetTypeId(), target->GetEntry(), GetGUIDLow(), GetDistance(target));
+ TC_LOG_DEBUG("maps", "Object %u (%s) is out of range for %s. Distance = %f", target->GetGUID().ToString().c_str(), target->GetEntry(), GetGUID().ToString().c_str(), GetDistance(target));
#endif
}
}
@@ -23184,7 +23185,7 @@ void Player::UpdateVisibilityOf(T* target, UpdateData& data, std::set<Unit*>& vi
UpdateVisibilityOf_helper(m_clientGUIDs, target, visibleNow);
#ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "Object %u (Type: %u, Entry: %u) is visible now for player %u. Distance = %f", target->GetGUIDLow(), target->GetTypeId(), target->GetEntry(), GetGUIDLow(), GetDistance(target));
+ TC_LOG_DEBUG("maps", "Object %u (%s) is visible now for %s. Distance = %f", target->GetGUID().ToString().c_str(), target->GetEntry(), GetGUID().ToString().c_str(), GetDistance(target));
#endif
}
}
@@ -26420,7 +26421,7 @@ void Player::SendEquipmentSetList()
{
if (itr->second.state == EQUIPMENT_SET_DELETED)
continue;
- data.appendPackGUID(itr->second.Guid);
+ data.AppendPackedUInt64(itr->second.Guid);
data << uint32(itr->first);
data << itr->second.Name;
data << itr->second.IconName;
@@ -26428,7 +26429,7 @@ void Player::SendEquipmentSetList()
{
// ignored slots stored in IgnoreMask, client wants "1" as raw GUID, so no HIGHGUID_ITEM
if (itr->second.IgnoreMask & (1 << i))
- data.appendPackGUID(uint64(1));
+ data << ObjectGuid(uint64(0), uint64(1));
else
data << ObjectGuid(HIGHGUID_ITEM, 0, itr->second.Items[i]).WriteAsPacked();
}
@@ -26473,7 +26474,7 @@ void Player::SetEquipmentSet(uint32 index, EquipmentSet eqset)
WorldPacket data(SMSG_EQUIPMENT_SET_SAVED, 4 + 1);
data << uint32(index);
- data.appendPackGUID(eqslot.Guid);
+ data.AppendPackedUInt64(eqslot.Guid);
GetSession()->SendPacket(&data);
}
diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp
index 50700f5126a..e4fc401e15f 100644
--- a/src/server/game/Groups/Group.cpp
+++ b/src/server/game/Groups/Group.cpp
@@ -134,14 +134,14 @@ bool Group::Create(Player* leader)
stmt->setUInt8(index++, uint8(m_lootMethod));
stmt->setUInt32(index++, m_looterGuid.GetCounter());
stmt->setUInt8(index++, uint8(m_lootThreshold));
- stmt->setUInt64(index++, m_targetIcons[0].GetRawValue());
- stmt->setUInt64(index++, m_targetIcons[1].GetRawValue());
- stmt->setUInt64(index++, m_targetIcons[2].GetRawValue());
- stmt->setUInt64(index++, m_targetIcons[3].GetRawValue());
- stmt->setUInt64(index++, m_targetIcons[4].GetRawValue());
- stmt->setUInt64(index++, m_targetIcons[5].GetRawValue());
- stmt->setUInt64(index++, m_targetIcons[6].GetRawValue());
- stmt->setUInt64(index++, m_targetIcons[7].GetRawValue());
+ stmt->setBinary(index++, m_targetIcons[0].GetRawValue());
+ stmt->setBinary(index++, m_targetIcons[1].GetRawValue());
+ stmt->setBinary(index++, m_targetIcons[2].GetRawValue());
+ stmt->setBinary(index++, m_targetIcons[3].GetRawValue());
+ stmt->setBinary(index++, m_targetIcons[4].GetRawValue());
+ stmt->setBinary(index++, m_targetIcons[5].GetRawValue());
+ stmt->setBinary(index++, m_targetIcons[6].GetRawValue());
+ stmt->setBinary(index++, m_targetIcons[7].GetRawValue());
stmt->setUInt8(index++, uint8(m_groupType));
stmt->setUInt32(index++, uint8(m_dungeonDifficulty));
stmt->setUInt32(index++, uint8(m_raidDifficulty));
@@ -175,7 +175,7 @@ void Group::LoadGroupFromDB(Field* fields)
m_lootThreshold = ItemQualities(fields[3].GetUInt8());
for (uint8 i = 0; i < TARGETICONCOUNT; ++i)
- m_targetIcons[i].Set(fields[4 + i].GetUInt64());
+ m_targetIcons[i].SetRawValue(fields[4 + i].GetBinary());
m_groupType = GroupType(fields[12].GetUInt8());
if (m_groupType & GROUPTYPE_RAID)
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
index 24a39f53444..d20aa950d3e 100644
--- a/src/server/game/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Handlers/CharacterHandler.cpp
@@ -1534,7 +1534,7 @@ void WorldSession::HandleEquipmentSetSave(WorldPacket& recvData)
TC_LOG_DEBUG("network", "CMSG_EQUIPMENT_SET_SAVE");
uint64 setGuid;
- recvData.readPackGUID(setGuid);
+ recvData.ReadPackedUInt64(setGuid);
uint32 index;
recvData >> index;
@@ -1560,7 +1560,7 @@ void WorldSession::HandleEquipmentSetSave(WorldPacket& recvData)
recvData >> itemGuid.ReadAsPacked();
// equipment manager sends "1" (as raw GUID) for slots set to "ignore" (don't touch slot at equip set)
- if (itemGuid.GetRawValue() == 1)
+ if (itemGuid == ObjectGuid(uint64(0), uint64(1)))
{
// ignored slots saved as bit mask because we have no free special values for Items[i]
eqSet.IgnoreMask |= 1 << i;
@@ -1586,7 +1586,7 @@ void WorldSession::HandleEquipmentSetDelete(WorldPacket& recvData)
TC_LOG_DEBUG("network", "CMSG_EQUIPMENT_SET_DELETE");
uint64 setGuid;
- recvData.readPackGUID(setGuid);
+ recvData.ReadPackedUInt64(setGuid);
_player->DeleteEquipmentSet(setGuid);
}
@@ -1606,7 +1606,7 @@ void WorldSession::HandleEquipmentSetUse(WorldPacket& recvData)
TC_LOG_DEBUG("entities.player.items", "%s: srcbag %u, srcslot %u", itemGuid.ToString().c_str(), srcbag, srcslot);
// check if item slot is set to "ignored" (raw value == 1), must not be unequipped then
- if (itemGuid.GetRawValue() == 1)
+ if (itemGuid == ObjectGuid(uint64(0), uint64(1)))
continue;
// Only equip weapons in combat
diff --git a/src/server/game/Handlers/VoidStorageHandler.cpp b/src/server/game/Handlers/VoidStorageHandler.cpp
index a368369a167..2b914018e55 100644
--- a/src/server/game/Handlers/VoidStorageHandler.cpp
+++ b/src/server/game/Handlers/VoidStorageHandler.cpp
@@ -130,7 +130,7 @@ void WorldSession::HandleVoidStorageQuery(WorldPacket& recvData)
if (!item)
continue;
- ObjectGuid itemId(item->ItemId);
+ ObjectGuid itemId(HIGHGUID_ITEM, item->ItemId);
ObjectGuid creatorGuid = item->CreatorGuid;
data.WriteBit(creatorGuid[3]);
@@ -353,7 +353,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData)
for (std::vector<ObjectGuid>::iterator itr = itemIds.begin(); itr != itemIds.end(); ++itr)
{
uint8 slot;
- VoidStorageItem* itemVS = player->GetVoidStorageItem(*itr, slot);
+ VoidStorageItem* itemVS = player->GetVoidStorageItem(itr->GetCounter(), slot);
if (!itemVS)
{
TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - %s %s tried to withdraw an invalid item (id: %s)", player->GetGUID().ToString().c_str(), player->GetName().c_str(), itr->ToString().c_str());
@@ -387,7 +387,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData)
for (uint8 i = 0; i < depositCount; ++i)
{
- ObjectGuid itemId(depositItems[i].first.ItemId);
+ ObjectGuid itemId(HIGHGUID_ITEM, depositItems[i].first.ItemId);
ObjectGuid creatorGuid = depositItems[i].first.CreatorGuid;
data.WriteBit(creatorGuid[7]);
data.WriteBit(itemId[7]);
@@ -409,7 +409,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData)
for (uint8 i = 0; i < withdrawCount; ++i)
{
- ObjectGuid itemId(withdrawItems[i].ItemId);
+ ObjectGuid itemId(HIGHGUID_ITEM, withdrawItems[i].ItemId);
data.WriteBit(itemId[1]);
data.WriteBit(itemId[7]);
data.WriteBit(itemId[3]);
@@ -424,7 +424,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData)
for (uint8 i = 0; i < withdrawCount; ++i)
{
- ObjectGuid itemId(withdrawItems[i].ItemId);
+ ObjectGuid itemId(HIGHGUID_ITEM, withdrawItems[i].ItemId);
data.WriteByteSeq(itemId[3]);
data.WriteByteSeq(itemId[1]);
data.WriteByteSeq(itemId[0]);
@@ -437,7 +437,7 @@ void WorldSession::HandleVoidStorageTransfer(WorldPacket& recvData)
for (uint8 i = 0; i < depositCount; ++i)
{
- ObjectGuid itemId(depositItems[i].first.ItemId);
+ ObjectGuid itemId(HIGHGUID_ITEM, depositItems[i].first.ItemId);
ObjectGuid creatorGuid = depositItems[i].first.CreatorGuid;
data << uint32(depositItems[i].first.ItemSuffixFactor);
@@ -532,7 +532,7 @@ void WorldSession::HandleVoidSwapItem(WorldPacket& recvData)
}
uint8 oldSlot;
- if (!player->GetVoidStorageItem(itemId, oldSlot))
+ if (!player->GetVoidStorageItem(itemId.GetCounter(), oldSlot))
{
TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - %s %s requested swapping an invalid item (slot: %u, itemid: %s).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), newSlot, itemId.ToString().c_str());
return;
@@ -542,7 +542,7 @@ void WorldSession::HandleVoidSwapItem(WorldPacket& recvData)
bool usedDestSlot = player->GetVoidStorageItem(newSlot) != NULL;
ObjectGuid itemIdDest;
if (usedDestSlot)
- itemIdDest.Set(player->GetVoidStorageItem(newSlot)->ItemId);
+ itemIdDest = ObjectGuid(HIGHGUID_ITEM, player->GetVoidStorageItem(newSlot)->ItemId);
if (!player->SwapVoidStorageItem(oldSlot, newSlot))
{
diff --git a/src/server/game/Movement/Spline/MoveSpline.cpp b/src/server/game/Movement/Spline/MoveSpline.cpp
index 9c5700182fd..05e22b6a34a 100644
--- a/src/server/game/Movement/Spline/MoveSpline.cpp
+++ b/src/server/game/Movement/Spline/MoveSpline.cpp
@@ -289,7 +289,7 @@ std::string MoveSpline::ToString() const
if (splineflags.final_angle)
str << "facing angle: " << facing.angle;
else if (splineflags.final_target)
- str << "facing target: " << facing.target;
+ str << "facing target: " << facing.target.ToString();
else if (splineflags.final_point)
str << "facing point: " << facing.f.x << " " << facing.f.y << " " << facing.f.z;
str << std::endl;
diff --git a/src/server/game/Movement/Spline/MoveSplineInit.cpp b/src/server/game/Movement/Spline/MoveSplineInit.cpp
index 097f0299961..749b6be4ee5 100644
--- a/src/server/game/Movement/Spline/MoveSplineInit.cpp
+++ b/src/server/game/Movement/Spline/MoveSplineInit.cpp
@@ -188,7 +188,7 @@ namespace Movement
void MoveSplineInit::SetFacing(const Unit* target)
{
args.flags.EnableFacingTarget();
- args.facing.target = target->GetGUID().GetRawValue();
+ args.facing.target = target->GetGUID();
}
void MoveSplineInit::SetFacing(float angle)
diff --git a/src/server/game/Movement/Spline/MoveSplineInitArgs.h b/src/server/game/Movement/Spline/MoveSplineInitArgs.h
index 12c22898b6d..e6e1198aa07 100644
--- a/src/server/game/Movement/Spline/MoveSplineInitArgs.h
+++ b/src/server/game/Movement/Spline/MoveSplineInitArgs.h
@@ -20,6 +20,7 @@
#define TRINITYSERVER_MOVESPLINEINIT_ARGS_H
#include "MoveSplineFlag.h"
+#include "ObjectGuid.h"
#include <G3D/Vector3.h>
class Unit;
@@ -28,17 +29,13 @@ namespace Movement
{
typedef std::vector<Vector3> PointsArray;
- union FacingInfo
+ struct FacingInfo
{
- struct {
- float x, y, z;
- } f;
- uint64 target;
- float angle;
+ G3D::Vector3 f;
+ ObjectGuid target;
+ float angle;
- FacingInfo(float o) : angle(o) { }
- FacingInfo(uint64 t) : target(t) { }
- FacingInfo() { }
+ FacingInfo() : angle(0.0f) { }
};
struct MoveSplineInitArgs
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index c6ff769deb8..71798448292 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -330,7 +330,7 @@ void SpellCastTargets::SetItemTarget(Item* item)
void SpellCastTargets::SetTradeItemTarget(Player* caster)
{
- m_itemTargetGUID.Set(uint64(TRADE_SLOT_NONTRADED));
+ m_itemTargetGUID.SetRawValue({ uint8(TRADE_SLOT_NONTRADED), 0, 0, 0, 0, 0, 0, 0 });
m_itemTargetEntry = 0;
m_targetMask |= TARGET_FLAG_TRADE_ITEM;
@@ -453,7 +453,7 @@ void SpellCastTargets::Update(Unit* caster)
if (m_targetMask & TARGET_FLAG_ITEM)
m_itemTarget = player->GetItemByGuid(m_itemTargetGUID);
else if (m_targetMask & TARGET_FLAG_TRADE_ITEM)
- if (m_itemTargetGUID.GetRawValue() == TRADE_SLOT_NONTRADED) // here it is not guid but slot. Also prevents hacking slots
+ if (m_itemTargetGUID == ObjectGuid(uint64(0), uint64(TRADE_SLOT_NONTRADED))) // here it is not guid but slot. Also prevents hacking slots
if (TradeData* pTrade = player->GetTradeData())
m_itemTarget = pTrade->GetTraderData()->GetItem(TRADE_SLOT_NONTRADED);
@@ -5212,7 +5212,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if (m_targets.GetTargetMask() & TARGET_FLAG_TRADE_ITEM)
{
if (TradeData* pTrade = m_caster->ToPlayer()->GetTradeData())
- pTempItem = pTrade->GetTraderData()->GetItem(TradeSlots(m_targets.GetItemTargetGUID().GetRawValue())); // at this point item target guid contains the trade slot
+ pTempItem = pTrade->GetTraderData()->GetItem(TradeSlots(m_targets.GetItemTargetGUID().GetRawValue().at(0))); // at this point item target guid contains the trade slot
}
else if (m_targets.GetTargetMask() & TARGET_FLAG_ITEM)
pTempItem = m_caster->ToPlayer()->GetItemByGuid(m_targets.GetItemTargetGUID());
@@ -5541,7 +5541,7 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_NOT_TRADING;
// Item target guid contains trade slot until m_targets.UpdateTradeSlotItem() is called
- TradeSlots slot = TradeSlots(m_targets.GetItemTargetGUID().GetRawValue());
+ TradeSlots slot = TradeSlots(m_targets.GetItemTargetGUID().GetRawValue().at(0));
if (slot != TRADE_SLOT_NONTRADED)
return SPELL_FAILED_BAD_TARGETS;
diff --git a/src/server/game/Texts/CreatureTextMgr.h b/src/server/game/Texts/CreatureTextMgr.h
index 147228b51db..06efadb1dc7 100644
--- a/src/server/game/Texts/CreatureTextMgr.h
+++ b/src/server/game/Texts/CreatureTextMgr.h
@@ -165,7 +165,8 @@ class CreatureTextLocalizer
{
case CHAT_MSG_MONSTER_WHISPER:
case CHAT_MSG_RAID_BOSS_WHISPER:
- data.put<uint64>(whisperGUIDpos, player->GetGUID().GetRawValue());
+ // TODO: Fix this. GUIDs are now always written packed and can have different packed lengths
+ //data.put<uint64>(whisperGUIDpos, player->GetGUID().GetRawValue());
break;
default:
break;
diff --git a/src/server/game/Tickets/TicketMgr.cpp b/src/server/game/Tickets/TicketMgr.cpp
index 46ed256d24e..7611fb8ce2d 100644
--- a/src/server/game/Tickets/TicketMgr.cpp
+++ b/src/server/game/Tickets/TicketMgr.cpp
@@ -62,7 +62,7 @@ bool GmTicket::LoadFromDB(Field* fields)
_posY = fields[++index].GetFloat();
_posZ = fields[++index].GetFloat();
_lastModifiedTime = fields[++index].GetUInt32();
- _closedBy = ObjectGuid(uint64(fields[++index].GetInt32()));
+ _closedBy = ObjectGuid(uint64(0), uint64(fields[++index].GetInt32()));
_assignedTo = ObjectGuid(HIGHGUID_PLAYER, fields[++index].GetUInt32());
_comment = fields[++index].GetString();
_response = fields[++index].GetString();
diff --git a/src/server/scripts/Commands/cs_ticket.cpp b/src/server/scripts/Commands/cs_ticket.cpp
index a06bd95f6b6..3e2c11e2ddd 100644
--- a/src/server/scripts/Commands/cs_ticket.cpp
+++ b/src/server/scripts/Commands/cs_ticket.cpp
@@ -153,7 +153,7 @@ public:
return true;
}
- sTicketMgr->CloseTicket(ticket->GetId(), player ? player->GetGUID() : ObjectGuid(uint64(-1)));
+ sTicketMgr->CloseTicket(ticket->GetId(), player ? player->GetGUID() : ObjectGuid(uint64(0), uint64(-1)));
sTicketMgr->UpdateLastChange();
std::string msg = ticket->FormatMessageString(*handler, player ? player->GetName().c_str() : "Console", NULL, NULL, NULL, NULL);
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h
index de871c5e6df..13e96833c82 100644
--- a/src/server/shared/Packets/ByteBuffer.h
+++ b/src/server/shared/Packets/ByteBuffer.h
@@ -483,35 +483,24 @@ class ByteBuffer
_rpos += len;
}
- void readPackGUID(uint64& guid)
+ void ReadPackedUInt64(uint64& guid)
{
- if (rpos() + 1 > size())
- throw ByteBufferPositionException(false, _rpos, 1, size());
-
guid = 0;
+ ReadPackedUInt64(read<uint8>(), guid);
+ }
- uint8 guidmark = 0;
- (*this) >> guidmark;
-
- for (int i = 0; i < 8; ++i)
- {
- if (guidmark & (uint8(1) << i))
- {
- if (rpos() + 1 > size())
- throw ByteBufferPositionException(false, _rpos, 1, size());
-
- uint8 bit;
- (*this) >> bit;
- guid |= (uint64(bit) << (i * 8));
- }
- }
+ void ReadPackedUInt64(uint8 mask, uint64& value)
+ {
+ for (uint32 i = 0; i < 8; ++i)
+ if (mask & (uint8(1) << i))
+ value |= (uint64(read<uint8>()) << (i * 8));
}
std::string ReadString(uint32 length)
{
if (!length)
return std::string();
- char* buffer = new char[length + 1]();
+ char* buffer = new char[length + 1];
read((uint8*)buffer, length);
std::string retval = buffer;
delete[] buffer;
@@ -621,23 +610,37 @@ class ByteBuffer
*this << packed;
}
- void appendPackGUID(uint64 guid)
+ void AppendPackedUInt64(uint64 guid)
+ {
+ uint8 mask = 0;
+ size_t pos = wpos();
+ *this << uint8(mask);
+
+ uint8 packed[8];
+ if (size_t packedSize = PackUInt64(guid, &mask, packed))
+ append(packed, packedSize);
+
+ put<uint8>(pos, mask);
+ }
+
+ size_t PackUInt64(uint64 value, uint8* mask, uint8* result) const
{
- uint8 packGUID[8+1];
- packGUID[0] = 0;
- size_t size = 1;
- for (uint8 i = 0;guid != 0;++i)
+ size_t resultSize = 0;
+ *mask = 0;
+ memset(result, 0, 8);
+
+ for (uint8 i = 0; value != 0; ++i)
{
- if (guid & 0xFF)
+ if (value & 0xFF)
{
- packGUID[0] |= uint8(1 << i);
- packGUID[size] = uint8(guid & 0xFF);
- ++size;
+ *mask |= uint8(1 << i);
+ result[resultSize++] = uint8(value & 0xFF);
}
- guid >>= 8;
+ value >>= 8;
}
- append(packGUID, size);
+
+ return resultSize;
}
void AppendPackedTime(time_t time)